Skip to content

Record log info to logfile, info log by date, error log by error.code

License

Notifications You must be signed in to change notification settings

open-node/logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@open-node/logger

Record log info to logfile, info log by date, error log by error.code

Build status codecov

Installation

npm i @open-node/logger --save

Usage

const Logger = require('@open-node/logger');

const logger = Logger({ errorLogPath, infoLogPath }, deps, clientId);

Table of Contents

Logger

Parameters

  • config Object 配置信息,errorLogPath, infoLogPath, 必须包含
    • config.errorLogPath
    • config.infoLogPath

Returns Logger Instance

error

记录错误信息

Parameters

  • e error error对象
  • extra any? 额外要记录的信息

Returns void

info

记录普通信息

Parameters

  • message string 要记录的信息
  • extra any? 额外要记录的信息

Returns void

logger

将普通函数加工成带有日志记录功能的函数

Parameters

  • fn function 要加工的函数
  • name string 名称、归类
  • isAsync boolean 是否是异步函数 (optional, default true)
  • transform function? 返回值记录的tans 函数 (optional, default x=>x)
  • errorHandler function? 错误信息处理函数 (optional, default e=>e.message)
  • argsHandler function? 参数信息处理函数 (optional, default JSON.stringify)

Returns function

About

Record log info to logfile, info log by date, error log by error.code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages