Photon Lua (Corona) Client API

Module common.Logger

Logger with ability to control logging level.

Prints messages to console by default. Each logging method perfoms toString() calls and default formatting of arguments only after it checks logging level. Therefore disabled level logging method call with plain arguments doesn't involves much overhead. But if one prefer custom formatting or some calculation for logging methods arguments he should check logging level before doing this to avoid unnecessary operations: if(logger:isLevelEnabled(Logger.Level.DEBUG)) { logger:debug("", someCall(x, y), x + "," + y); }

Functions

new (prefix, level) Creates instance of Logger.
instance:format (...) Applies default logger formatting to arguments
instance:fatal (...) Logs message if logging level = TRACE, DEBUG, INFO, WARN, ERROR, FATAL
instance:error (...) Logs message if logging level = TRACE, DEBUG, INFO, WARN, ERROR
instance:warn (...) Logs message if logging level = TRACE, DEBUG, INFO, WARN
instance:info (...) Logs message if logging level = TRACE, DEBUG, INFO
instance:debug (...) Logs message if logging level = TRACE, DEBUG
instance:trace (...) Logs message if logging level = TRACE
instance:setLevel (level) Changes current logging level.
instance:isLevelEnabled (level) Checks if logging level active.
instance:getLevel () Returns current logging level.
instance:setPrefix (prefix) Set log message prefix.
instance:setLogFunction (func) Changes default 'print' log function to user defined.

Tables

Level Logging levels.


Functions

new (prefix, level)
Creates instance of Logger.

Parameters:

  • prefix optional string All log messages will be prefixed with that. Default is empty string.
  • level optional Level Initial logging level. Default is Level.INFO
instance:format (...)
Applies default logger formatting to arguments

Parameters:

  • ... Multiple arguments of any type to build formatted string from.

Returns:

    string Formatted String.
instance:fatal (...)
Logs message if logging level = TRACE, DEBUG, INFO, WARN, ERROR, FATAL

Parameters:

  • ... Multiple arguments of any type to build message from.
instance:error (...)
Logs message if logging level = TRACE, DEBUG, INFO, WARN, ERROR

Parameters:

  • ... Multiple arguments of any type to build message from.
instance:warn (...)
Logs message if logging level = TRACE, DEBUG, INFO, WARN

Parameters:

  • ... Multiple arguments of any type to build message from.
instance:info (...)
Logs message if logging level = TRACE, DEBUG, INFO

Parameters:

  • ... Multiple arguments of any type to build message from.
instance:debug (...)
Logs message if logging level = TRACE, DEBUG

Parameters:

  • ... Multiple arguments of any type to build message from.
instance:trace (...)
Logs message if logging level = TRACE

Parameters:

  • ... Multiple arguments of any type to build message from.
instance:setLevel (level)
Changes current logging level.

Parameters:

  • level Level New logging level.
instance:isLevelEnabled (level)
Checks if logging level active.

Parameters:

  • level Level Level to check.

Returns:

    boolean True if level active.
instance:getLevel ()
Returns current logging level.

Returns:

    Level Current logging level.
instance:setPrefix (prefix)
Set log message prefix.

Parameters:

  • prefix string New log prefix.
instance:setLogFunction (func)
Changes default 'print' log function to user defined.

Parameters:

  • func function New log function.

Tables

Level
Logging levels. Set to restrict log output.

Fields:

  • FATAL Only fatal(...) method enabled.
  • ERROR Only error(...) and fatal(...) methods enabled.
  • WARN warn(...), error(...) and fatal(...) methods enabled.
  • INFO info(...), warn(...), error(...) and fatal(...) methods enabled.
  • DEBUG All but trace(...) methods enabled.
  • TRACE All logging methods enabled.
generated by LDoc 1.3