Logger

core Logger

This class handles a variety of loggers, e.g. a browser console one (mostly for debugging), a remote one, etc.

Note: we use log4javascript for the console logger, and our own for the server logger.

Constructor

new Logger(psychoJS, threshold)

Source:
Parameters:
Name Type Description
psychoJS module:core.PsychoJS

the PsychoJS instance

threshold *

the logging threshold, e.g. log4javascript.Level.ERROR

Members

(protected, static, readonly) _ServerLevelValue :number

Source:
Properties:
Name Type Description
CRITICAL number
ERROR number
WARNING number
DATA number
EXP number
INFO number
DEBUG number
NOTSET number

Server logging level values.

We use those values to determine whether a log is to be sent to the server or not.

Type:
  • number

(static, readonly) ServerLevel :Symbol

Source:
Properties:
Name Type Description
CRITICAL Symbol
ERROR Symbol
WARNING Symbol
DATA Symbol
EXP Symbol
INFO Symbol
DEBUG Symbol
NOTSET Symbol

Server logging level.

Type:
  • Symbol

Methods

(protected) _customConsoleLayout() → {*}

Source:

Create a custom console layout.

Returns:

the custom layout

Type
*

(protected) _getValue(level) → {number}

Source:

Get the integer value associated with a logging level.

Parameters:
Name Type Description
level module:core.Logger.ServerLevel

the logging level

Returns:
  • the value associated with the logging level, or 30 is the logging level is unknown.
Type
number

(protected) _throttle(time) → {boolean}

Source:

Check whether or not a log messages must be throttled.

Parameters:
Name Type Description
time number

the time of the latest log message

Returns:

whether or not to log the message

Type
boolean

data(msg, timeopt, objopt)

Source:

Log a server message at the DATA level.

Parameters:
Name Type Attributes Description
msg string

the message to be logged.

time number <optional>

the logging time

obj object <optional>

the associated object (e.g. a Trial)

exp(msg, timeopt, objopt)

Source:

Log a server message at the EXP level.

Parameters:
Name Type Attributes Description
msg string

the message to be logged.

time number <optional>

the logging time

obj object <optional>

the associated object (e.g. a Trial)

(async) flush()

Source:

Flush all server logs to the server.

Note: the logs are compressed using Pako's zlib algorithm. See https://github.com/nodeca/pako for details.

log(msg, level, timeopt, objopt)

Source:

Log a server message.

Parameters:
Name Type Attributes Description
msg string

the message to be logged.

level module:core.Logger.ServerLevel

logging level

time number <optional>

the logging time

obj object <optional>

the associated object (e.g. a Trial)

setLevel(serverLevel)

Source:

Change the logging level.

Parameters:
Name Type Description
serverLevel module:core.Logger.ServerLevel

the new logging level