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 27

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 218

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 92

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 131

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 144

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 160
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 174
Returns:
Formatted string.
Type
string

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

Returns current logging level.

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

getPrefix() → {string}

Gets logger prefix.

Source:
  • Photon-Javascript_SDK.js, line 53
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 105

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 79
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 71

setLevel(level)

Changes current logging level.

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

setPrefix(prefix)

Sets logger prefix.

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

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 118