1.0.0 • Published 11 months ago
error-log-node v1.0.0
ErrorLog
安装
npm
npm install error-log-node --save
yarn
yarn add error-log-node
导入
const errorLog = require('error-log-node')
创建一个日志对象
const errLog = new ErrorLog(options)
options
name 可选 日志文件的名字 , 默认为 error
path 日志文件存放的路径
实例方法
ErrorLog.prototype.log(err)
- err 错误信息, 可以是一个Error对象或一个字符串
示例
const path = require('path')
const errLog = new ErrorLog({
path: path.join(__dirName, '/log')
})
errLog.log('这是一条错误信息')
errLog.log(new TypeError('类型错误'))
1.0.0
11 months ago