LoggerModule Class
Item Index
Methods
- areAllGroupsEnabled
- debug
- debug
- deleteErrorFiles
- deleteLogFiles
- disableAllGroups
- disableGroups
- enableAllGroups
- enableGroups
- error
- error
- flushLogs
- getEnabledGroups
- getErrorFileInfo
- getLogCollectionStatus
- getLogFileInfo
- info
- info
- isLogCollectionRunning
- log
- log
- logException
- pauseLogCollection
- resumeLogCollection
- startErrorMonitoring
- startLogCollection
- stopLogCollection
- trace
- trace
- warning
- warning
Constants
Events
Methods
areAllGroupsEnabled
()
Boolean
Returns true if logging for all groups is enabled, false otherwise.
Returns:
debug
-
params
Logs a message at the DEBUG log level, optionally within a logging group.
Logger.debug({ group: 'group', msg: 'msg' });
is equivalent to
Logger.log({ level: Logger.DEBUG, group: 'group', msg: 'msg' });
Note that this method can take 1 or 2 arguments, and the single argument can be a string (which will be interpreted as the message to be logged) or an object (which can have 1 or 2 properties itself).
Parameters:
-
params
Object-
[group]
String optional -
msg
String
-
Returns:
debug
-
[group]
-
message
Logs a message at the DEBUG log level, optionally within a logging group.
Logger.debug([group, ] msg)
is equivalent to
Logger.log(Logger.DEBUG, [group, ] msg)
Note that this method can take 1 or 2 arguments, and the single argument can be a string (which will be interpreted as the message to be logged) or an object (which can have 1 or 2 properties itself).
Parameters:
-
[group]
String optional -
message
String
Returns:
deleteErrorFiles
()
Void
Deletes all error files.
Use the startErrorMonitoring function to start the collection of error information into files, or the getErrorFileInfo function to retrieve information about the currently available error files.
Returns:
deleteLogFiles
()
Void
Deletes all log files. If log collection is running when this function
is called, log collection will be temporarily stopped while the files
are being deleted and then restarted. This means that a new (set of)
log files will be created immediately after the existing files are
deleted. If this is not desired, stop log collection using the
stopLogCollection
function before calling deleteLogFiles
.
Use getLogFileInfo to get a list of available log files and potentially delete them individually.
Returns:
disableAllGroups
()
Void
Turns off logging for all groups. See also enableGroups, enableAllGroups, and disableGroups.
Returns:
disableGroups
-
[group*]
Turns off logging for the specified groups. See also enableGroups, enableAllGroups, and disableAllGroups.
Parameters:
-
[group*]
String optional
Returns:
enableAllGroups
()
Void
Turns on logging for all groups. See also enableGroups, disableGroups, and disableAllGroups.
Returns:
enableGroups
-
[group*]
Turns on logging for the specified groups. See also disableGroups, enableAllGroups, and disableAllGroups.
Parameters:
-
[group*]
String optional
Returns:
error
-
[group]
-
message
Logs a message at the ERROR log level, optionally within a logging group.
Logger.error([group, ] msg)
is equivalent to
Logger.log(Logger.ERROR, [group, ] msg)
Note that this method can take 1 or 2 arguments, and the single argument can be a string (which will be interpreted as the message to be logged) or an object (which can have 1 or 2 properties itself).
Parameters:
-
[group]
String optional -
message
String
Returns:
error
-
params
Logs a message at the ERROR log level, optionally within a logging group.
Logger.error({ group: 'group', msg: 'msg' });
is equivalent to
Logger.log({ level: Logger.ERROR, group: 'group', msg: 'msg' });
Note that this method can take 1 or 2 arguments, and the single argument can be a string (which will be interpreted as the message to be logged) or an object (which can have 1 or 2 properties itself).
Parameters:
-
params
Object-
[group]
String optional -
msg
String
-
Returns:
flushLogs
()
Void
Writes all the currently available log messages into the log file. This is potentially useful because log collection runs periodically, by default every 10 seconds. Call this function if you don't want to wait for the next regularly scheduled instance of log collection.
This operation is asynchronous on Android; the flushCompleted event is fired when the operation completes.
Does nothing (although flushCompleted
is still fired)
if log collection is not running; see
startLogCollection.
Returns:
getEnabledGroups
()
Array of Strings
Returns the groups that are currently enabled for logging. See also the areAllGroupsEnabled; if logging for all groups is enabled, then all messages will be logged regardless of what groups this function returns.
Returns:
getErrorFileInfo
()
Array of Objects
Returns an array of objects that describe the currently available files that capture crashes and exceptions.
Use the startErrorMonitoring method to start the collection of crash and exception information into files, or the deleteErrorFiles method to delete all the error info files at once.
Returns:
Each object has a file
(a Titanium File object) and an errorTime
(String) property.
getLogCollectionStatus
()
Number
final
Shows the status of log collection. See the LOG_COLLECTION_STOPPED, LOG_COLLECTION_PAUSED, and LOG_COLLECTION_STARTED, constants.
Returns:
getLogFileInfo
()
Array of Objects
Returns an array of objects that describe the currently available log
files. On Android, logs are collected in three different buffers:
main
, system
, events
, and
radio
.
Returns:
Each object has a
file
(a Titanium File object), a startTime
(String),
a buffer
(String), and a seqNum
(Number) property.
info
-
[group]
-
message
Logs a message at the INFO log level, optionally within a logging group.
Logger.info([group, ] msg)
is equivalent to
Logger.log(Logger.INFO, [group, ] msg)
Note that this method can take 1 or 2 arguments, and the single argument can be a string (which will be interpreted as the message to be logged) or an object (which can have 1 or 2 properties itself).
Parameters:
-
[group]
String optional -
message
String
Returns:
info
-
params
Logs a message at the INFO log level, optionally within a logging group.
Logger.info({ group: 'group', msg: 'msg' });
is equivalent to
Logger.log({ level: Logger.INFO, group: 'group', msg: 'msg' });
Note that this method can take 1 or 2 arguments, and the single argument can be a string (which will be interpreted as the message to be logged) or an object (which can have 1 or 2 properties itself).
Parameters:
-
params
Object-
[group]
String optional -
msg
String
-
Returns:
isLogCollectionRunning
()
Boolean
Determines whether log collection is currently running.
Returns:
log
-
[level]
-
[group]
-
message
Logs a message, optionally at the specified log level and/or within a logging group (see enableGroups and disableGroups methods).
Note that this method can take 1, 2, or 3 arguments, and the single argument can be a string (which will be interpreted as the message to be logged) or an object (which can have 1, 2, or 3 properties itself).
Parameters:
-
[level]
Number optional -
[group]
String optional -
message
String
Returns:
log
-
params
Logs a message, optionally at the specified log level and/or within a logging group (see enableGroups and disableGroups methods).
Note that this method can take 1, 2, or 3 arguments, and the single argument can be a string (which will be interpreted as the message to be logged) or an object (which can have 1, 2, or 3 properties itself).
Parameters:
-
params
Object-
[level]
Number optional -
[group]
String optional -
msg
String
-
Returns:
logException
-
exception
Logs a JavaScript exception into an error file. Call this function after you caught an exception in JavaScript, with the caught exception object as the parameter.
Parameters:
-
exception
Exception
Returns:
startErrorMonitoring
()
Boolean
Starts error monitoring and the collection of related information into files.
The type of events handled by this function is slightly different on iOS and Android. On iOS, information about fatal signals, exceptions that trigger a fatal signal, and exceptions caught by Titanium is collected. On Android, information about uncaught exceptions and exceptions caught by the Titanium framework is collected.
Capturing information about exceptions caught in JavaScript happens independently from this function. To capture information related to an exception caught in JavaScript, call logException.
On iOS, The information for fatal signal (hard crash) will be available the next time the app restarts after the crash.
Once error monitoring is started, it can only be turned off by restarting the app (and not calling this method when it does restart). If you want to give control to the user whether error monitoring should be running or not, you can provide a switch on the GUI and ask the user to restart the app when the switch is turned off.
Use the getErrorFileInfo method to retrieve information about the currently available error files, or the deleteErrorFiles method to delete all the error info files at once.
Returns:
True if error monitoring was started successfully, false otherwise.
startLogCollection
-
[interval=10]
Starts log collection into a log file. See also stopLogCollection.
Parameters:
-
[interval=10]
Number optionalSpecifies, in seconds, how often the console log is saved into the log file. Defaults to 10. Must be at least 1.
Returns:
stopLogCollection
()
Void
Stops log collection into a log file. See also startLogCollection.
Returns:
trace
-
params
Logs a message at the TRACE log level, optionally within a logging group.
Logger.trace({ group: 'group', msg: 'msg' });
is equivalent to
Logger.log({ level: Logger.TRACE, group: 'group', msg: 'msg' });
Note that this method can take 1 or 2 arguments, and the single argument can be a string (which will be interpreted as the message to be logged) or an object (which can have 1 or 2 properties itself).
Parameters:
-
params
Object-
[group]
String optional -
msg
String
-
Returns:
trace
-
[group]
-
message
Logs a message at the TRACE log level, optionally within a logging group.
Logger.trace([group, ] msg)
is equivalent to
Logger.log(Logger.TRACE, [group, ] msg)
Note that this method can take 1 or 2 arguments, and the single argument can be a string (which will be interpreted as the message to be logged) or an object (which can have 1 or 2 properties itself).
Parameters:
-
[group]
String optional -
message
String
Returns:
warning
-
params
Logs a message at the WARNING log level, optionally within a logging group.
Logger.warning({ group: 'group', msg: 'msg' });
is equivalent to
Logger.log({ level: Logger.WARNING, group: 'group', msg: 'msg' });
Note that this method can take 1 or 2 arguments, and the single argument can be a string (which will be interpreted as the message to be logged) or an object (which can have 1 or 2 properties itself).
Parameters:
-
params
Object-
[group]
String optional -
msg
String
-
Returns:
warning
-
[group]
-
message
Logs a message at the WARNING log level, optionally within a logging group.
Logger.warning([group, ] msg)
is equivalent to
Logger.log(Logger.WARNING, [group, ] msg)
Note that this method can take 1 or 2 arguments, and the single argument can be a string (which will be interpreted as the message to be logged) or an object (which can have 1 or 2 properties itself).
Parameters:
-
[group]
String optional -
message
String
Returns:
Properties
logLevel
Number
The global log level. Messages that are logged with a log level themselves will only be printed if their log level is lower than or equal than the global log level. Defaults to TRACE.
maxLogFileSize
Number
The maximum size of each log file, in bytes. Defaults to 1,000,000. The smallest accepted value for this property is 10,000.
maxSessionLogFileCount
Number
The maximum number of log files per session and per buffer. It may be counter-intuitive at first that this limit is per buffer; however, this is an easy way to make sure that the less active buffers (system, events and radio) are not crowded out by the more active ones (main).
Defaults to 3.
maxTotalLogFileCount
Number
The maximum number of log files total, including all sessions and all buffers. Defaults to 24.
Constants
LOG_COLLECTION_PAUSED
Number
This is one of the possible values of the LoggerModule/logCollectionStatus:property property. It indicates that log collection has been paused.
LOG_COLLECTION_STARTED
Number
This is one of the possible values of the LoggerModule/logCollectionStatus:property property. It indicates that log collection has been started.
LOG_COLLECTION_STOPPED
Number
This is one of the possible values of the LoggerModule/logCollectionStatus:property property. It indicates that log collection has been stopped (or never started).
NONE
Number
Use this constant to set the logLevel property. This is the alias for a log level so high that none of the messegase that have a log level will be printed.
Events
flushCompleted
This event is fired when the flushLogs operation completes.