Grind provides a global Log
class that should be used instead of console.log
. The Log class has 5 different logging methods/levels available:
static { }static { }static { }static { }static { }
The default logger is ChalkedConsoleLogger
. This logger chalks (colorizes) output before sending it to console.log
to provide clear visual differentiation of log types:
Log.info
— Outputs default text colorLog.comment
— Outputs as blue textLog.warn
— Outputs as yellow textLog.error
— Outputs as white text with a red backgroundLog.success
— Output as green text
You can write your own custom logger by setting Log.logger
to your own class with the same 5 method signatures.
Here’s an example of a logger that posts back to an API collector:
{ this }{ this }{ this }{ this }{ this }{}
To activate this logger, you should create a Logger provider:
{Loglogger =}
From there, you just need to register LoggerProvider
in your app/Bootstrap.js
file and all existing Log
calls will start posting to your collection handler instead of logging to the console.