Skip to content
Will edited this page Mar 30, 2015 · 7 revisions

Logging

Logging from your module

A logger can be retrieved as

var logger = freedom.core.getLoggerSync('my Logger');

or, by using the standard freedom idiom of:

var logger;
freedom.core().getLogger('My Logger').then(function(log) {
  logger = log;
});

Once the logger exists, logging can be performed by calling

logger.log('My message', objects_are_okay_too);

Supported levels include debug,info,log,warn, and error.

The Chat demo provides an example of custom logging.

Filtering logging output

Can be done by specifying a debug level at the point of freedom inclusion. This is done via the debug key in the configuration json object, and looks something like:

<script type='text/javascript' src='freedom.js' data-manifest='manifest.json'>
{
  'debug': 'log'
}
</script>

Valid values are 'debug', 'info', 'log', 'warn', and 'error'.

Custom Logging providers

To change the behavior of logging, for instance to send logs back to your server for storage, to write custom filtering, or to otherwise modify the logging behavior of freedom.js, you will write a custom logging provider.

Loggers implement the core.logger interface, which specifies the debug, info, log, warn, and error methods for handling different severity of log messages. In addition, each of these methods is provided a source argument, specifying where within the application the message originated.

To install a new logger, you can override the built-in core.logger through the privileged freedomcfg operation.

The provided console logger is a reasonable starting point for most logging implementations.