Class: Logger

Exitgames.Common. Logger

Logger with ability to control logging level. Prints messages to browser console. 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); }

new Logger(prefix, level)

Parameters:
Name Type Argument Default Description
prefix string <optional>
"" All log messages will be prefixed with that.
level Exitgames.Common.Logger.Level <optional>
Level.INFO Initial logging level.
Source:
  • Photon-Javascript_SDK.js, line 33

Members

<static, readonly> Level

Logging levels. Set to restrict log output.

Properties:
Name Type Description
DEBUG number All logging methods enabled.
INFO number info(...), warn(...), error(...) methods enabled.
WARN number warn(...) and error(...) methods enabled.
ERROR number Only error(...) method enabled.
OFF number Logging off.
Source:
  • Photon-Javascript_SDK.js, line 227

Methods

debug(mess, optionalParams)

Logs message if logging level = DEBUG, INFO, WARN, ERROR

Parameters:
Name Type Description
mess string Message to log.
optionalParams any For every additional parameter toString() applies and result added to the end of log message after space character.
Source:
  • Photon-Javascript_SDK.js, line 98

error(mess, optionalParams)

Logs message if logging level = ERROR

Parameters:
Name Type Description
mess string Message to log.
optionalParams any For every additional parameter toString() applies and result added to the end of log message after space character.
Source:
  • Photon-Javascript_SDK.js, line 137

exception(mess, optionalParams)

Throws an Error or executes exception handler if set.

Parameters:
Name Type Description
mess string Message passed to Error or exception handler.
optionalParams any For every additional parameter toString() applies and result added to the end of log message after space character.
Source:
  • Photon-Javascript_SDK.js, line 150

format(mess, optionalParams) → {string}

Applies default logger formatting to arguments

Parameters:
Name Type Description
mess string String to start formatting with.
optionalParams any For every additional parameter toString() applies and result added to the end of formatted string after space character.
Source:
  • Photon-Javascript_SDK.js, line 166
Returns:
Formatted string.
Type
string

format(mess, optionalParams) → {string}

Applies default logger formatting to array of objects.

Parameters:
Name Type Description
mess string String to start formatting with.
optionalParams any[] For every additional parameter toString() applies and result added to the end of formatted string after space character.
Source:
  • Photon-Javascript_SDK.js, line 180
Returns:
Formatted string.
Type
string

getLevel() → {Exitgames.Common.Logger.Level}

Returns current logging level.

Source:
  • Photon-Javascript_SDK.js, line 92
Returns:
Current logging level.
Type
Exitgames.Common.Logger.Level

getPrefix() → {string}

Gets logger prefix.

Source:
  • Photon-Javascript_SDK.js, line 59
Returns:
Prefix.
Type
string

info(mess, optionalParams)

Logs message if logging level = INFO, WARN, ERROR

Parameters:
Name Type Description
mess string Message to log.
optionalParams any For every additional parameter toString() applies and result added to the end of log message after space character.
Source:
  • Photon-Javascript_SDK.js, line 111

isLevelEnabled(level) → {boolean}

Checks if logging level active.

Parameters:
Name Type Description
level Exitgames.Common.Logger.Level Level to check.
Source:
  • Photon-Javascript_SDK.js, line 85
Returns:
True if level active.
Type
boolean

setExceptionHandler(handler)

Sets global method to be called on logger.exception call.

Parameters:
Name Type Description
handler (string) => boolean Exception handler. Return true to cancel throwing.
Source:
  • Photon-Javascript_SDK.js, line 77

setLevel(level)

Changes current logging level.

Parameters:
Name Type Description
level Exitgames.Common.Logger.Level New logging level.
Source:
  • Photon-Javascript_SDK.js, line 67

setPrefix(prefix)

Sets logger prefix.

Parameters:
Name Type Description
prefix stirng New prefix.
Source:
  • Photon-Javascript_SDK.js, line 51

warn(mess, optionalParams)

Logs message if logging level = WARN, ERROR

Parameters:
Name Type Description
mess string Message to log.
optionalParams any For every additional parameter toString() applies and result added to the end of log message after space character.
Source:
  • Photon-Javascript_SDK.js, line 124