1.2.4 • Published 10 years ago

proteus-logger v1.2.4

Weekly downloads
45
License
-
Repository
github
Last release
10 years ago

proteus-logger

About

Proteus Logger is a logging framework to support application logging.

This module collaborate with Proteus Cluster to support logging under the clustered environment (under the clustered environment, workers sends log data to the master, and master unify the log management).

Proteus Logger also provides date-time based file rotation in cluster environment.

Usage

Initialize Logger

To initialize logger, call configure() or define logger info using Proteus Configurator by setting configure key as "logger".

Call configure()

var proteusLogger = require('proteus-logger');
proteusLogger.configure({
  appenders: {
    console: { type: 'console' }
  }
  loggers: {
    logger1: {
      level: 'info',
      appenders: ['console']
    }
  }
});

Use Proteus Configurator

{
  "appenders": {
    "console": { "type": "console" }
  },
  "loggers": {
    "category2": {
      "level": "info",
      "appenders": ["console"]
    }
  }
}

Log messages

var logger = require('proteus-logger').get('category1');
logger.info('this is the information log');
logger.warn('this is the warning log');
logger.error('this is the error log', err);

Layout configuration

require('proteus-logger').configure({
  appenders: {
    console: {
      type: 'console',
      layout: {
        pattern: '%yyyy-%MM-%dd %HH:%mm:%ss %loggerc %msg %argsc (%linec)%nstack'
      }
    }
  }
});
defined patterns

date-time based file rotation

proteusLogger.configure({
  appenders: {
    file: {
      type: "dailyRotateFile",
      filename: "rotated.log", // file to be appended
      pattern: "rotated.%yyyy-%MM-%dd.log" // file to be replaced
    }
  },
  "loggers": {
    "category": {
      "level": "info",
      "appenders": ["file"]
    }
  }
});

According to the above settings, file will be created as "rotated.log" and rotated daily. Rotated files will be something like "rotated.2014-03-12.log". You can use the following meta characters in pattern.

Since pattern has hours and minutes, rotation interval can be modified in configuration. You can set interval property in milliseconds.

proteusLogger.configure({
  appenders: {
    file: {
      type: "dailyRotateFile",
      filename: "rotated.log", // file to be appended
      pattern: "rotated.%yyyy-%MM-%dd-%hh.log" // file to be replaced,
      interval: 3600000 // 1 hour interval
    }
  },
  "loggers": {
    "category": {
      "level": "info",
      "appenders": ["file"]
    }
  }
});

License

Copyright 2012 CyberAgent, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

1.2.4

10 years ago

1.2.3

10 years ago

1.2.2

10 years ago

1.2.1

10 years ago

1.2.0

10 years ago

1.1.9

10 years ago

1.1.8

11 years ago

1.1.7

11 years ago

1.1.6

11 years ago

1.1.5

11 years ago

1.1.4

11 years ago