public class Log extends Object
Modifier and Type | Field and Description |
---|---|
static int |
DEBUG
Constant indicating the logging level Debug is the default and the lowest level
followed by info, warning and error
|
static int |
ERROR
Constant indicating the logging level Debug is the default and the lowest level
followed by info, warning and error
|
static int |
INFO
Constant indicating the logging level Debug is the default and the lowest level
followed by info, warning and error
|
static int |
REPORTING_DEBUG
Indicates that log reporting to the cloud should occur regardless of whether an error occurred
|
static int |
REPORTING_NONE
Indicates that log reporting to the cloud should be disabled
|
static int |
REPORTING_PRODUCTION
Indicates that log reporting to the cloud should occur only if an error occurred
|
static int |
WARNING
Constant indicating the logging level Debug is the default and the lowest level
followed by info, warning and error
|
Modifier | Constructor and Description |
---|---|
protected |
Log()
Prevent new Log() syntax.
|
Modifier and Type | Method and Description |
---|---|
static void |
bindCrashProtection(boolean consumeError)
Binds pro based crash protection logic that will send out an email in case of an exception thrown on the EDT
|
protected Writer |
createWriter()
Default method for creating the output writer into which we write, this method
creates a simple log file using the file connector
|
static void |
deleteLog()
Deletes the current log file
|
static void |
e(Throwable t)
This method is a shorthand form for logThrowable
|
String |
getFileURL()
Indicates the URL where the log file is saved
|
static Log |
getInstance()
Returns the singleton instance of the log
|
static int |
getLevel()
Returns the logging level for printing log details, the lower the value
the more verbose would the printouts be
|
static String |
getLogContent()
Deprecated.
this was practical in old J2ME devices but hasn't been maintained in ages, use sendLog() instead
|
static int |
getReportingLevel()
Indicates the level of log reporting, this allows developers to send device logs to the cloud
thus tracking crashes or functionality in the device.
|
protected String |
getThreadAndTimeStamp()
Returns a simple string containing a timestamp and thread name.
|
static long |
getUniqueDeviceId()
Deprecated.
this will no longer work. Use
getUniqueDeviceKey() |
static String |
getUniqueDeviceKey()
Returns a server generated unique device id that is cached locally and is only valid per application.
|
static void |
install(Log newInstance)
Installs a log subclass that can replace the logging destination/behavior
|
static boolean |
isCrashBound()
Returns true if the user bound crash protection
|
boolean |
isFileWriteEnabled()
Indicates whether GCF's file writing should be used to generate the log file
|
protected void |
logThrowable(Throwable t)
Logs an exception to the log, by default print is called with the exception
details, on supported devices the stack trace is also physically written to
the log
|
static void |
p(String text)
Default println method invokes the print instance method, uses DEBUG level
|
static void |
p(String text,
int level)
Default println method invokes the print instance method, uses given level
|
protected void |
print(String text,
int level)
Default log implementation prints to the console and the file connector
if applicable.
|
static void |
sendLog()
Sends the current log to the cloud.
|
static void |
sendLogAsync()
Sends the current log to the cloud and returns immediately
|
void |
setFileURL(String fileURL)
Indicates the URL where the log file is saved
|
void |
setFileWriteEnabled(boolean fileWriteEnabled)
Indicates whether GCF's file writing should be used to generate the log file
|
static void |
setLevel(int level)
Sets the logging level for printing log details, the lower the value
the more verbose would the printouts be
|
static void |
setReportingLevel(int level)
Indicates the level of log reporting, this allows developers to send device logs to the cloud
thus tracking crashes or functionality in the device.
|
static void |
showLog()
Deprecated.
this method is an outdated method that's no longer supported
|
void |
trackFileSystem()
Activates the filesystem tracking of file open/close operations
|
public static final int DEBUG
public static final int INFO
public static final int WARNING
public static final int ERROR
public static int REPORTING_NONE
public static int REPORTING_DEBUG
public static int REPORTING_PRODUCTION
public static void setReportingLevel(int level)
level
- one of REPORTING_NONE, REPORTING_DEBUG, REPORTING_PRODUCTIONpublic static int getReportingLevel()
public static long getUniqueDeviceId()
getUniqueDeviceKey()
public static String getUniqueDeviceKey()
public static void sendLog()
public static void sendLogAsync()
public static void install(Log newInstance)
newInstance
- the new instance for the Log objectpublic static void p(String text)
text
- the text to printpublic static void p(String text, int level)
text
- the text to printlevel
- one of DEBUG, INFO, WARNING, ERRORpublic static void e(Throwable t)
t
- the exceptionprotected void logThrowable(Throwable t)
t
- protected void print(String text, int level)
text
- the text to printlevel
- one of DEBUG, INFO, WARNING, ERRORprotected Writer createWriter() throws IOException
IOException
- when thrown by the connectorpublic static void deleteLog()
protected String getThreadAndTimeStamp()
public static void setLevel(int level)
level
- one of DEBUG, INFO, WARNING, ERRORpublic static int getLevel()
public static String getLogContent()
public static void showLog()
public static Log getInstance()
public boolean isFileWriteEnabled()
public void setFileWriteEnabled(boolean fileWriteEnabled)
fileWriteEnabled
- the fileWriteEnabled to setpublic String getFileURL()
public void setFileURL(String fileURL)
fileURL
- the fileURL to setpublic void trackFileSystem()
public static void bindCrashProtection(boolean consumeError)
consumeError
- true will hide the error from the user, false will leave the builtin logic that defaults to
showing an error dialog to the userpublic static boolean isCrashBound()