Logger Module

API Docs for: 1.0.1
Show:

LoggerModule Class

Module: Readme

Methods

areAllGroupsEnabled

() Boolean

Available since 1.0.0

Returns true if logging for all groups is enabled, false otherwise.

Returns:

Boolean:

debug

(
  • params
)
Void

Available since 1.0.0

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:

Void:

debug

(
  • [group]
  • message
)
Void

Available since 1.0.0

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:

Void:

deleteErrorFiles

() Void

Available since 1.0.0

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:

Void:

deleteLogFiles

() Void

Available since 1.0.0

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:

Void:

disableAllGroups

() Void

Available since 1.0.0

Turns off logging for all groups. See also enableGroups, enableAllGroups, and disableGroups.

Returns:

Void:

disableGroups

(
  • [group*]
)
Void

Available since 1.0.0

Turns off logging for the specified groups. See also enableGroups, enableAllGroups, and disableAllGroups.

Parameters:

  • [group*] String optional

Returns:

Void:

enableAllGroups

() Void

Available since 1.0.0

Turns on logging for all groups. See also enableGroups, disableGroups, and disableAllGroups.

Returns:

Void:

enableGroups

(
  • [group*]
)
Void

Available since 1.0.0

Turns on logging for the specified groups. See also disableGroups, enableAllGroups, and disableAllGroups.

Parameters:

  • [group*] String optional

Returns:

Void:

error

(
  • [group]
  • message
)
Void

Available since 1.0.0

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:

Void:

error

(
  • params
)
Void

Available since 1.0.0

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:

Void:

flushLogs

() Void

Available since 1.0.0

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:

Void:

getEnabledGroups

() Array of Strings

Available since 1.0.0

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:

Array of Strings:

getErrorFileInfo

() Array of Objects

Available since 1.0.0

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:

Array of Objects:

Each object has a file (a Titanium File object) and an errorTime (String) property.

getLogCollectionStatus

() Number final

Available since 1.0.0

Shows the status of log collection. See the LOG_COLLECTION_STOPPED, LOG_COLLECTION_PAUSED, and LOG_COLLECTION_STARTED, constants.

Returns:

Number:

getLogFileInfo

() Array of Objects

Available since 1.0.0

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:

Array of Objects:

Each object has a file (a Titanium File object), a startTime (String), a buffer (String), and a seqNum (Number) property.

info

(
  • [group]
  • message
)
Void

Available since 1.0.0

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:

Void:

info

(
  • params
)
Void

Available since 1.0.0

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:

Void:

isLogCollectionRunning

() Boolean

Available since 1.0.0

Determines whether log collection is currently running.

Returns:

Boolean:

log

(
  • [level]
  • [group]
  • message
)
Void

Available since 1.0.0

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:

Void:

log

(
  • params
)
Void

Available since 1.0.0

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:

Void:

logException

(
  • exception
)
Void

Available since 1.0.0

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:

Void:

pauseLogCollection

() Void

Available since 1.0.0

Pauses log collection. See also resumeLogCollection.

Returns:

Void:

resumeLogCollection

() Void

Available since 1.0.0

Resumes log collection. See also pauseLogCollection.

Returns:

Void:

startErrorMonitoring

() Boolean

Available since 1.0.0

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:

Boolean:

True if error monitoring was started successfully, false otherwise.

startLogCollection

(
  • [interval=10]
)
Void

Available since 1.0.0

Starts log collection into a log file. See also stopLogCollection.

Parameters:

  • [interval=10] Number optional

    Specifies, in seconds, how often the console log is saved into the log file. Defaults to 10. Must be at least 1.

Returns:

Void:

stopLogCollection

() Void

Available since 1.0.0

Stops log collection into a log file. See also startLogCollection.

Returns:

Void:

trace

(
  • params
)
Void

Available since 1.0.0

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:

Void:

trace

(
  • [group]
  • message
)
Void

Available since 1.0.0

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:

Void:

warning

(
  • params
)
Void

Available since 1.0.0

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:

Void:

warning

(
  • [group]
  • message
)
Void

Available since 1.0.0

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:

Void:

Properties

logLevel

Number

Available since 1.0.0

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

Available since 1.0.0

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

Available since 1.0.0

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

Available since 1.0.0

The maximum number of log files total, including all sessions and all buffers. Defaults to 24.

Constants

DEBUG

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

DEBUG1

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

DEBUG2

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

DEBUG3

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

DEBUG4

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

DEBUG5

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

DEBUG6

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

DEBUG7

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

DEBUG8

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

DEBUG9

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

ERROR

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

INFO

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

LOG_COLLECTION_PAUSED

Number

Available since 1.0.0

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

Available since 1.0.0

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

Available since 1.0.0

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

Available since 1.0.0

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.

TRACE

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

WARNING

Number

Available since 1.0.0

Use this constant to set the logLevel property or the level parameter of the log method.

Events

flushCompleted

Available since 1.0.0

This event is fired when the flushLogs operation completes.