Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

infinum/loglevel-filesave

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

loglevel-filesave

Greenkeeper badge

Loglevel plugin for saving logs to the file

Build Status Dependency Status devDependency Status

Installation

npm install loglevel-filesave

Usage

When the module is required it returns a function that accepts two arguments:

  • logger - Loglevel logger instance
  • options - Object with various options
    • file - Path to the file where the log should be written
    • prefix - String or a function (receives methodName and message as arguments) that will be used to format the logged message.
      • Default: methodName + ': ' + message
    • consoleLevel - Level of the messages that should be passed trough to the console (default loglevel behaviour).
      • Default: logger.levels.SILENT
    • fs - Filesystem module that should be used. Default: require('fs')
    • separator - Separator that should be used between entries:
      • Default: require('os').EOL (depends on the system)
    • level - Level of messages that should be written to the file.
      • Default: logger.levels.WARN

Example

var loglevel = require('loglevel');
var fileSave = require('loglevel-filesave');

var logger = loglevel.getLogger('log');
fileSave(logger, {file: 'log.txt'});

Requirements

  • Should work on all versions of Node.js
  • Dev requirement: Node.js 6.3+

TODO

  • Add an option to use bulk saves

License

MIT License