Class Log
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intConstant indicating the logging level Debug is the default and the lowest level followed by info, warning and errorstatic final intConstant indicating the logging level Debug is the default and the lowest level followed by info, warning and errorstatic final intConstant indicating the logging level Debug is the default and the lowest level followed by info, warning and errorstatic final intIndicates that log reporting to the cloud should occur regardless of whether an error occurredstatic final intIndicates that log reporting to the cloud should be disabledstatic final intIndicates that log reporting to the cloud should occur only if an error occurredstatic final intConstant indicating the logging level Debug is the default and the lowest level followed by info, warning and error -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidbindCrashProtection(boolean consumeError) Binds pro based crash protection logic that will send out an email in case of an exception thrown on the EDTprotected WriterDefault method for creating the output writer into which we write, this method creates a simple log file using the file connectorstatic voidDeletes the current log filestatic voidThis method is a shorthand form for logThrowableIndicates the URL where the log file is savedstatic LogReturns the singleton instance of the logstatic intgetLevel()Returns the logging level for printing log details, the lower the value the more verbose would the printouts bestatic StringReturns the contents of the log as a single long string to be displayed by the application any way it sees fitstatic intIndicates the level of log reporting, this allows developers to send device logs to the cloud thus tracking crashes or functionality in the device.protected StringReturns a simple string containing a timestamp and thread name.static longReturns a server generated unique device id that is cached locally and is only valid per application.static StringReturns a server generated unique device id that is cached locally and is only valid per application.static voidInstalls a log subclass that can replace the logging destination/behaviorstatic booleanReturns true if the user bound crash protectionbooleanIndicates whether GCF's file writing should be used to generate the log fileprotected voidLogs 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 logstatic voidDefault println method invokes the print instance method, uses DEBUG levelstatic voidDefault println method invokes the print instance method, uses given levelprotected voidDefault log implementation prints to the console and the file connector if applicable.static voidsendLog()Sends the current log to the cloud.static voidSends the current log to the cloud and returns immediatelyvoidsetFileURL(String fileURL) Indicates the URL where the log file is savedvoidsetFileWriteEnabled(boolean fileWriteEnabled) Indicates whether GCF's file writing should be used to generate the log filestatic voidsetLevel(int level) Sets the logging level for printing log details, the lower the value the more verbose would the printouts bestatic voidsetReportingLevel(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 voidshowLog()Places a form with the log as a TextArea on the screen, this method can be attached to appear at a given time or using a fixed global key.voidActivates the filesystem tracking of file open/close operations
-
Field Details
-
DEBUG
public static final int DEBUGConstant indicating the logging level Debug is the default and the lowest level followed by info, warning and error- See Also:
-
INFO
public static final int INFOConstant indicating the logging level Debug is the default and the lowest level followed by info, warning and error- See Also:
-
WARNING
public static final int WARNINGConstant indicating the logging level Debug is the default and the lowest level followed by info, warning and error- See Also:
-
ERROR
public static final int ERRORConstant indicating the logging level Debug is the default and the lowest level followed by info, warning and error- See Also:
-
REPORTING_NONE
public static final int REPORTING_NONEIndicates that log reporting to the cloud should be disabled- See Also:
-
REPORTING_DEBUG
public static final int REPORTING_DEBUGIndicates that log reporting to the cloud should occur regardless of whether an error occurred- See Also:
-
REPORTING_PRODUCTION
public static final int REPORTING_PRODUCTIONIndicates that log reporting to the cloud should occur only if an error occurred- See Also:
-
-
Constructor Details
-
Log
protected Log()Prevent new Log() syntax. Use getInstance()
-
-
Method Details
-
getReportingLevel
public 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.
Returns
one of REPORTING_NONE, REPORTING_DEBUG, REPORTING_PRODUCTION
-
setReportingLevel
public 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.
Parameters
level: one of REPORTING_NONE, REPORTING_DEBUG, REPORTING_PRODUCTION
-
getUniqueDeviceId
public static long getUniqueDeviceId()Returns a server generated unique device id that is cached locally and is only valid per application. Notice that this device id is specific to your application and to a specific install, it is guaranteed to be completely unique or -1 if unavailable (which can be due to a network error). Warning: this method might block while accessing the server!s
Returns
a unique device id
Deprecated
this will no longer work. Use
#getUniqueDeviceKey() -
getUniqueDeviceKey
Returns a server generated unique device id that is cached locally and is only valid per application. Notice that this device id is specific to your application and to a specific install, it is guaranteed to be completely unique or null if unavailable (which can be due to a network error). Warning: this method might block while accessing the server!s
Returns
a unique device id
-
sendLog
public static void sendLog()Sends the current log to the cloud. Notice that this method is synchronous and returns only when the sending completes -
sendLogAsync
public static void sendLogAsync()Sends the current log to the cloud and returns immediately -
install
Installs a log subclass that can replace the logging destination/behavior
Parameters
newInstance: the new instance for the Log object
-
p
Default println method invokes the print instance method, uses DEBUG level
Parameters
text: the text to print
-
p
Default println method invokes the print instance method, uses given level
Parameters
-
text: the text to print -
level: one of DEBUG, INFO, WARNING, ERROR
-
-
e
This method is a shorthand form for logThrowable
Parameters
t: the exception
-
deleteLog
public static void deleteLog()Deletes the current log file -
getLevel
public static int getLevel()Returns the logging level for printing log details, the lower the value the more verbose would the printouts be
Returns
one of DEBUG, INFO, WARNING, ERROR
-
setLevel
public static void setLevel(int level) Sets the logging level for printing log details, the lower the value the more verbose would the printouts be
Parameters
level: one of DEBUG, INFO, WARNING, ERROR
-
getLogContent
Returns the contents of the log as a single long string to be displayed by the application any way it sees fit
Returns
string containing the whole log
Deprecated
this was practical in old J2ME devices but hasn't been maintained in ages, use sendLog() instead
-
showLog
public static void showLog()Places a form with the log as a TextArea on the screen, this method can be attached to appear at a given time or using a fixed global key. Using this method might cause a problem with further log output
Deprecated
this method is an outdated method that's no longer supported
-
getInstance
Returns the singleton instance of the log
Returns
the singleton instance of the log
-
bindCrashProtection
public 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
Parameters
consumeError: @param consumeError true will hide the error from the user, false will leave the builtin logic that defaults to showing an error dialog to the user
-
isCrashBound
public static boolean isCrashBound()Returns true if the user bound crash protection
Returns
true if crash protection is bound
-
logThrowable
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
Parameters
t
-
print
Default log implementation prints to the console and the file connector if applicable. Also prepends the thread information and time before
Parameters
-
text: the text to print -
level: one of DEBUG, INFO, WARNING, ERROR
-
-
createWriter
Default method for creating the output writer into which we write, this method creates a simple log file using the file connector
Returns
writer object
Throws
IOException: when thrown by the connector
- Throws:
IOException
-
getThreadAndTimeStamp
Returns a simple string containing a timestamp and thread name.
Returns
timestamp string for use in the log
-
isFileWriteEnabled
public boolean isFileWriteEnabled()Indicates whether GCF's file writing should be used to generate the log file
Returns
the fileWriteEnabled
-
setFileWriteEnabled
public void setFileWriteEnabled(boolean fileWriteEnabled) Indicates whether GCF's file writing should be used to generate the log file
Parameters
fileWriteEnabled: the fileWriteEnabled to set
-
getFileURL
Indicates the URL where the log file is saved
Returns
the fileURL
-
setFileURL
Indicates the URL where the log file is saved
Parameters
fileURL: the fileURL to set
-
trackFileSystem
public void trackFileSystem()Activates the filesystem tracking of file open/close operations
-