ostrio:loggerfile

v0.0.11Published 9 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

Meteor file adapter for ostrio:logger

Simply store application logs into file within ostrio:logger package

Installation:

meteor add ostrio:loggerfile

Usage

Log [Server & Client]
1/*
2  message {String} - Any text message
3  data    {Object} - [optional] Any additional info as object
4  userId  {String} - [optional] Current user id
5 */
6Meteor.log.info(message, data, userId);
7Meteor.log.debug(message, data, userId);
8Meteor.log.error(message, data, userId);
9Meteor.log.fatal(message, data, userId);
10Meteor.log.warn(message, data, userId);
11Meteor.log.trace(message, data, userId);
12Meteor.log._(message, data, userId); //--> Shortcut for logging without message, e.g.: simple plain log
Activate and set adapter settings [Server & Client]
1Meteor.log.rule('File', 
2{
3  enable: true,
4  filter: ['ERROR', 'FATAL', 'WARN'], /* Filters: 'ERROR', 'FATAL', 'WARN', 'DEBUG', 'INFO', '*' */
5  client: false, /* This allows to call, but not execute on Client */
6  server: true   /* Calls from client will be executed on Server */
7});
Change string format [Server]

Default format:

1"#{time.getDate()}-#{time.getMonth()}-#{time.getFullYear()} #{time.getHours()}:#{time.getMinutes()}:#{time.getSeconds()} | [#{level}] | Message: \"#{message}\" | User: #{userId} | data: #{data}\r\n"

To change format set Meteor.log.file.format function

1if Meteor.isServer
2  Meteor.log.file.format = (time, level, message, data, userId) ->
3    "#{+time} [#{level}]: \"#{message}\" \r\n"
Change file name format [Server]

Default format:

1# New file will be created every day
2"#{time.getDate()}-#{time.getMonth()}-#{time.getFullYear()}.log"

To change format set Meteor.log.file.fileNameFormat function

1if Meteor.isServer
2  Meteor.log.file.fileNameFormat = (time) ->
3    # New file will be created every hour
4    "#{time.getHours()}_#{time.getDate()}-#{time.getMonth()}-#{time.getFullYear()}.log"