new mmir.tools.Logger(theName, theLevel)
Constructor-Method of Class Logger
Name | Type | Description |
---|---|---|
theName |
String | the name / ID for the logger |
theLevel |
String | Number | optional OPTIONAL the log-level. If omitted, the logger will use the default log-level |
- See:
-
getAsLevel
getLevel
Members
-
private,constantERROR_STACK_LEVELnumber
-
if stacktrace is enabled: number of stack-levels that should be omitted when printing an error via
printe
(to hide logger-internal function-call-stack) NOTE: if isErrInvoked is TRUE: this function was invoked via additional printe()-call => need to take 1 more step down the stack -
privateIS_TRACEboolean
-
quasi constant: is updated once, if stacktrace is enabled -- otherwise readonly!
-
privateisFullStackDepthBoolean
-
setting for trace-depth (i.e. stack-depth)
-
privatepnOriginalfunction
-
proxy object for storing the original implementation of
mmir.tools.Logger#print
function. (only used, if tracing is enabled!) -
privatepnTraceOptionsObject
-
options object for tracing
-
private,constantSTACK_LEVELnumber
-
if stacktrace is enabled: number of stack-levels that should be omitted (to hide logger-internal function-call-stack)
-
privatetmpTraceConfigObject
-
configuration value for enabling/disabling tracing in log-output
Methods
-
privateapplyReverseCallStackWith(args, offset){number}
-
HELPER for modifying the reverseCallStack argument in arguments
Name Type Description args
Arguments the function's original arguments object offset
number the offset for the call-stack, value 0 would mean no change to the callstack (i.e. "go further back by [offset]") Returns:
Name Type Description the
number stack-level/-line from which on the trace should be printed the
Array converted arguments object with applied (or modified) reverseCallStack argument -
c(className, funcName, msg, error, reverseCallStack)
-
Alias for
critical
.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message error
Error optional OPTIONAL an error object: if available, its message and error-stack will be print to the output reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself. -
privatecreateErr(){string}
-
Creates error message (with stack trace, if possible).
Returns:
Type Description string the error message -
privatecreateMsg(){string}
-
creates the message text.
Returns:
Type Description string the message text -
critical(className, funcName, msg, error, reverseCallStack)
-
Print a critical (exception) log message, if at least
critical
(5) log-level is set.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message error
Error optional OPTIONAL an error object: if available, its message and error-stack will be print to the output reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself. -
d(className, funcName, msg, reverseCallStack)
-
Alias for
debug
.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself. -
debug(className, funcName, msg, reverseCallStack)
-
Print a debug log message, if at least
debug
(1) log-level is set.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself. -
e(className, funcName, msg, error, reverseCallStack)
-
Alias for
error
.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message error
Error optional OPTIONAL an error object: if available, its message and error-stack will be print to the output reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself. -
error(className, funcName, msg, error, reverseCallStack)
-
Print an error log message, if at least
error
(4) log-level is set.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message error
Error optional OPTIONAL an error object: if available, its message and error-stack will be print to the output reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself. -
privategetAsLevel(strLogLevel){Number}
-
Get the log-level as number.
Name Type Description strLogLevel
String the string representation for the log-level - See:
Returns:
Type Description Number the log-level as number -
getLevel(){Number}
-
Get the current log-level: if a specific log-level for this Logger instance is set, this value is returned. Otherwise, the default log-level as returned by
mmir.Logging#getDefaultLogLevel
is used. Log-levels:- 0: verbose
- 1: debug
- 2: info
- 3: warn
- 4: error
- 5: critical
- 6: disabled
- See:
Returns:
Type Description Number the logging level -
privategetStackLevel(){number}
-
HELPER for getting the stack-level/-line from which on the trace should be printed in order to suppress showing internal function calls when generating the log output
Returns:
Type Description number the stack-level/-line from which on the trace should be printed -
i(className, funcName, msg, reverseCallStack)
-
Alias for
info
.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself. -
info(className, funcName, msg, reverseCallStack)
-
Print an information log message, if at least
info
(2) log-level is set.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself. -
isc(){Boolean}
-
Alias for
isCritical
.- See:
Returns:
Type Description Boolean true
if at least log-levelcritical
(5) -
isCritical(){Boolean}
-
Check if the current log-level is at least
critical
.- See:
Returns:
Type Description Boolean true
if at least log-levelcritical
(5) -
isd(){Boolean}
-
Alias for
isDebug
.- See:
Returns:
Type Description Boolean true
if at least log-leveldebug
(1) -
isDebug(){Boolean}
-
Check if the current log-level is at least
debug
.- See:
Returns:
Type Description Boolean true
if at least log-leveldebug
(1) -
isDisabled(){Boolean}
-
Check if the current log-level is at least
disabled
.- See:
Returns:
Type Description Boolean true
if at least log-leveldisable
(6) -
ise(){Boolean}
-
Alias for
isError
.- See:
Returns:
Type Description Boolean true
if at least log-levelerror
(4) -
privateisErr(){Boolean}
-
HELPER: check if errObj is an Error
Returns:
Type Description Boolean -
isError(){Boolean}
-
Check if the current log-level is at least
error
.- See:
Returns:
Type Description Boolean true
if at least log-levelerror
(4) -
isi(){Boolean}
-
Alias for
isInfo
.- See:
Returns:
Type Description Boolean true
if at least log-levelinfo
(2) -
isInfo(){Boolean}
-
Check if the current log-level is at least
info
.- See:
Returns:
Type Description Boolean true
if at least log-levelinfo
(2) -
isv(){Boolean}
-
Alias for
isVerbose
.- See:
Returns:
Type Description Boolean true
if at least log-levelverbose
(0) -
isVerbose(){Boolean}
-
Check if the current log-level is at least
verbose
.- See:
Returns:
Type Description Boolean true
if at least log-levelverbose
(0) -
isw(){Boolean}
-
Alias for
isWarn
.- See:
Returns:
Type Description Boolean true
if at least log-levelwarn
(3) -
isWarn(){Boolean}
-
Check if the current log-level is at least
warn
.- See:
Returns:
Type Description Boolean true
if at least log-levelwarn
(3) -
l(className, funcName, msg, error, reverseCallStack)
-
Alias for
log
.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message error
Error optional OPTIONAL an error object: if available, its message and error-stack will be print to the output reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself. -
log(className, funcName, msg, error, reverseCallStack)
-
Print a log message, if at least
debug
log-level is set.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message error
Error optional OPTIONAL an error object: if available, its message and error-stack will be print to the output reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself. -
privateprint()
-
-
privateprinte()
-
print log message with error information.
-
privateprintFullStack()
-
Extension for
mmir.tools.Logger#print
function with tracing. This extension prints the full stack trace in log-output. (only used, if tracing is enabled!) -
privateprintStack()
-
Extension for
mmir.tools.Logger#print
function with tracing. This extension prints only the first entry of the stack trace in log-output. (only used, if tracing is enabled!) -
setLevel(loggingLevel)
-
Set the logging level.
Name Type Description loggingLevel
String | Number if {Number} the logging level as a number if {String} the logging level as a string (see getLevel
)- See:
-
privatesetLogLevel(loggerId, logLevel)
-
configure default log-level for a logger: in case the logger is created without specifying a log-level, this pre-configured log-level will be used.
Name Type Description loggerId
String the ID for the logger logLevel
Number | String the log-level for the logger -
v(className, funcName, msg, reverseCallStack)
-
Alias for
verbose
.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself. -
verbose(className, funcName, msg, reverseCallStack)
-
Print a verbose log message, if at least
verbose
(0) log-level is set.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself. -
w(className, funcName, msg, reverseCallStack)
-
Alias for
warn
.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself. -
warn(className, funcName, msg, reverseCallStack)
-
Print a warning log message, if at least
warn
(3) log-level is set.Name Type Description className
String optional OPTIONAL the name of the class/object from which the logging is invoked from funcName
String optional OPTIONAL the name of the function (within the class) from which the logging is invoked from msg
String the log message reverseCallStack
number optional OPTIONAL offset when printing the callstack position/information: a positive number will go further back/up the callstack. This can be used in logging-helper functions to select the invoking function's position from the callstack instead of printing the information of the logging-helper function itself.