Caplin Trader 4.8.0

Interface: module:caplin/core/log/Logger

module:caplin/core/log/Logger

This represents an interface, and should not normally be constructed. Interface that must be implemented by a class that wants to be notified when a message has been logged. See module:caplin/core/log/Log.

All methods take a variable number of arguments, containing all the items that should be written to the log.

To register a logger to receive log messages, you can use this utility method:

caplin.core.log.Log.register( new MyLogger(), "caplin.trading.*" )
The optional second parameter allows you to restrict the kinds of log messages your logger will receive (in this example to messages from the trading library).

To publish log messages, you can write the following:

var logger = caplin.core.log.Log.getLogger("myapp.package.MyClass");
logger.info("Liftoff in T-10");
logger.warn("Houston, we have a problem");
If you are publishing log messages, you should avoid using error, as that is intended for use at the top level.

It is common that you will want to control the log level, which you can do by adjusting the behaviour of the relevant methods.

The caplin logging scheme allows the first argument to be a pattern string, which can have values interpolated into it. Loggers that wish to make use of this can use the module:caplin/core/log/Log#interpolate or module:caplin/core/log/Log#asString methods. All values not interpolated into the first string are simply concatenated together.

Methods

debug()

Log a 'debug' message. A variable argument method. See module:caplin/core/log/Log.interpolate for more information.

error()

Log an 'error' message. A variable argument method. See module:caplin/core/log/Log.interpolate for more information.

Avoid using this method, as it is intended only to be used at the top level.

info()

Log an 'info' message. A variable argument method. See module:caplin/core/log/Log.interpolate for more information.

trace()

Log a 'trace' message. A variable argument method. See module:caplin/core/log/Log.interpolate for more information.

warn()

Log a 'warn' message. A variable argument method. See module:caplin/core/log/Log.interpolate for more information.