LoggerModule Class
Item Index
Methods
- areAllGroupsEnabled
- debug
- debug
- deleteErrorFiles
- deleteLogFiles
- disableAllGroups
- disableGroups
- enableAllGroups
- enableGroups
- 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 with a millisecond timestamp 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 with a millisecond timestamp 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
.
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 with a millisecond timestamp 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:
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 synchronous on iOS, but for compatibility with 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 error 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.
Returns:
Each object has a
file
(a Titanium File object), a startTime
(String),
a buffer
(String), and a seqNum
(Number) property.
The buffer property
is present for compatibility with Android; iOS only has one buffer so this
property is always set to "main" on this platform.
info
-
[group]
-
message
Logs a message with a millisecond timestamp 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 with a millisecond timestamp 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 with a millisecond timestamp, 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 with a millisecond timestamp, 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 slighthy 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
-
[group]
-
message
Logs a message with a millisecond timestamp 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
-
-
[group]
String optional -
message
String
Returns:
warning
-
params
Logs a message with a millisecond timestamp 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:
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. Defaults to 3.
maxTotalLogFileCount
Number
The maximum number of log files in total. Defaults to 6.
printMilliseconds
Boolean
Specifies whether the
log function
includes a millisecond timestamp by default. The default value is
false
.
Including an extra millisecond timestamp is an iOS only feature, which can be helpful for performance measurements. On Android, the system timestamps already include milliseconds.
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.