Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

proteus-logger

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

proteus-logger

proteus-logger ==============================

  • 1.2.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
2
Weekly downloads
 
Created
Source

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
meta characterscomments
yyyyYear (4 digits)
MMMonth
ddDate
HHHour (2 digits)
mmMinute (2 digits)
ssSeconds (2 digits)
TJust 'T' to split date and time.
levelLogged level
levelcLogged level (colored)
loggerLogger name
loggercLogger name (colored)
msgLogging message
errorError mesage
stackStack trace of the error without line break.
nstackStack trace of the error with line break before trace.
lineFile name and line number
linecFile name and line number (colored)
nLine break

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.

meta characterscomments
yyyyYear (4 digits)
MMMonth (2 digits)
ddDay (2 digits)
hhHours (2 digits)
mmMinutes (2 digits)

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.

FAQs

Package last updated on 04 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc