Internal services (data store API calls failed, etc) or external services are failing
A user is now stuck in a broken state which the system cannot naturally repair
Game server debugging information
The app cannot boot or stopped unexpectedly
A user request caused an error. The user should still be able to continue using the services
User command request information
Services state change notification (example: third-party services and databases)
Low-level debug information (I/O details, etc). Reserved to MAGE internals
An unusual situation occurred, which requires analysis
Add contexts to the current logger instance.
Logging contexts should be used to help with the triage and filtering of logs; for instance, you will often want to create one logger context per module.
This adds contexts to the current instance. You will not normally want
to use this on the global logger instance: instead, you will normally
want to use this on a logger instance returned by mage.logger.context
or something similar.
import * as mage from mage;
const logger = mage.logger.context('mymodule')
logger.addContexts('some other context to add')
logger.debug('this will be contextualized to mymodule')
In most cases, simply using mage.logger.context
is sufficient.
Return a contextualized logger instance
Logging contexts should be used to help with the triage and filtering of logs; for instance, you will often want to create one logger context per module.
Contrarily to mage.logger.addContexts
, this method returns
a new logger with the given context, instead of setting the context
on the current logger instance. This can be useful to create a localized logger;
import * as mage from mage;
const logger = mage.logger.context('mymodule')
logger.debug('this will be contextualized to mymodule')
Disable a log channel
This will in effect take all logs sent to this channel, and ignore them; logs sent on this channel will no longer be forwarded to any logger backend.
The name of the channel to disable
Create a channel handler
You should only call this if you want to programatically
enable a channel which is not currently enabled or if you
want to re-enable a channel which was disabled using disableChannel
.
The channel to enable
Logger interface
This is useful when you wish, for instance, to add a logger instance to a class.
class MyClass { private _logger: mage.core.ILogger constructor() { this._logger = mage.logger.context('MyClass') } }
ILogger
{Logger}