Logging: Print Client's logs to Server's console, messages colorized for better readability

javascript, console, meteor, meteor-package, logger, logging, logs, logging-library, meteorjs
meteor add ostrio:loggerconsole@=1.2.1


Logging: To Console

Print Client's log messages to Server's console package. All messages is enhanced with colors and extra styles for better readability.

This package is not limited to transferring Client's log messages to Server. It can be used on client only, or for printing colorized messages on both Client and Server.

Server example:

server example

Client example:

client example


meteor add ostrio:logger # If not yet installed
meteor add ostrio:loggerconsole

Support this awesome package:


Initialization [Isomorphic]

new LoggerConsole(LoggerInstance, settings)

  • LoggerInstance {Logger} - from new Logger()
  • settings {Object}
  • settings.format {Function} - This function must return String. Arguments:
    • opts {Object}
    • opts.userId {String}
    • opts.time {Date} - Report date
    • opts.level {String} - Message level, one of: ERROR, FATAL, WARN, DEBUG, INFO, TRACE, LOG, *
    • opts.message {String} - Report message
    • opts.data {Object} - Additional info passed as object

Example: [Isomorphic]

// Initialize Logger:
this.log = new Logger();

// Initialize LoggerConsole and enable with default settings:
(new LoggerConsole(log)).enable();

// Initialize LoggerConsole and enable with custom formatting:
(new LoggerConsole(log, {
  format: function (opts) {
    return ((Meteor.isServer) ? '[SERVER]' : "[CLIENT]") + ' [' + opts.level + '] - ' + opts.message;
Activate with custom adapter settings: [Isomorphic]
this.log = new Logger();
(new LoggerConsole(log)).enable({
  enable: true,
  filter: ['ERROR', 'FATAL', 'WARN'], /* Filters: 'ERROR', 'FATAL', 'WARN', 'DEBUG', 'INFO', 'TRACE', '*' */
  client: true, /* Output logs on both Server's and Client's console */
  server: true  /* Calls from Client and Server will be executed on Server */
Log message: [Isomorphic]
this.log = new Logger();
(new LoggerConsole(log)).enable();

  message {String} - Any text message
  data    {Object} - [optional] Any additional info as object
  userId  {String} - [optional] Current user id
log.info(message, data, userId);
log.debug(message, data, userId);
log.error(message, data, userId);
log.fatal(message, data, userId);
log.warn(message, data, userId);
log.trace(message, data, userId);
log._(message, data, userId); //--> Plain log without level

/* Use with throw */
throw log.error(message, data, usmerId);
Catch-all Client's errors example: [Client]
/* Store original window.onerror */
var _WoE = window.onerror;

window.onerror = function(msg, url, line) {
  log.error(msg, {file: url, onLine: line});
  if (_WoE) {
    _WoE.apply(this, arguments);
Use multiple logger(s) with different settings: [Isomorphic]
this.log1 = new Logger();
this.log2 = new Logger();

(new LoggerConsole(log1)).enable({
  filter: ['*'],
  client: true,
  server: true

(new LoggerConsole(log2)).enable({
  filter: ['ERROR', 'FATAL'],
  client: true,
  server: true