Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
baiji-logger
Advanced tools
A logger compoment for Baiji
NodeJS version >= 10.14.2
yarn add baiji-logger
# OR
npm install baiji-logger -S
See details from ./test/app/index.js
// require
const baiji = require('baiji');
const path = require('path');
const baijiLogger = require('baiji-logger');
// define
const { accessLogger, error, info, debug } = baijiLogger({
traceKey: 'serviceName',
baseDir: path.join(__dirname, './logs'),
});
const infoLogger = info();
const errorLogger = error();
const debugLogger = debug();
// use case
const app = baiji('serviceName');
app.use(accessLogger()); // Add accessLogger for routes
// app.use(UsersCtrl); // Use controller
// Start app and listen on port 3000
app.listen(3000, () => infoLogger.info('Port : 3000'));
Based on winstonjs/winston
classify | instance | env | transport | rotate |
---|---|---|---|---|
error | errorLogger | * | error.log | File |
*warning | * | warning.log | File | |
info | infoLogger | * | app.log | File |
accessLogger | * | access.log+Console | DailyRotateFile | |
*verbose | dev/test | debug.log+Console | File | |
debug | debugLogger | dev | Console | |
*silly | dev | Console |
Description
option
|.filter
| means option.filter
-filterKeys
| means options.filter.filterKeys
param | type | default | desc |
---|---|---|---|
option | object | - | The option for baijiLogger |
.traceKey | string | - | The unique key for this app , be used for traceId |
.baseDir | string | - | The base direction path for logs |
.filter | * | false | Sensitive information filtering and replace |
-filterKeys | array | ['password', 'token', 'authorization'] | Filter keys array list |
-recursion | boolean | false | Is recursion |
-replaceChat | string/function | '*' | Replace chat or function |
.generateTraceId | function | ${timestamp}-${shortid}-${traceKey} | The function for generate trace id |
.errorLoggerConfig | object | - | The configuration for error logger |
-filepath | string | /${ENV}_${level}.log | Used by path.join(baseDir,filepath) |
-format | function | [${timeFormat}] [${level}] ${label} - ${json} | A string representing the moment.js date format to be used for rotating. |
-level | string | error | Log only if info.level less than or equal to this level |
-maxFiles | number | 5 | Maximum number of logs to keep. |
-maxSize | string | 10m | Maximum size of the file after which it will rotate. |
-transports | array | [ transports.Console , DailyRotateFile ] | Winston Transports |
-zippedArchive | boolean | true | A boolean to define whether or not to gzip archived log files. |
.infoLoggerConfig | object | - | The configuration for info logger |
-datePattern | string | YYYY-MM-DD | ↑ |
-filepath | string | /${level}/${ENV}_${level}_%DATE%.log | ↑ |
-format | function | [${timeFormat}] [${level}] ${label} - ${json} | ↑ |
-level | string | info | ↑ |
-maxFiles | string | 7d | ↑ |
-maxSize | string | 10m | ↑ |
-transports | array | [ transports.Console , DailyRotateFile ] | ↑ |
-zippedArchive | boolean | true | ↑ |
.accessLogger | object | - | The configuration for access logger , when requested to get the corresponding |
-body | string | ctx.req.body | Post method params |
-method | string | ctx.req.method | Http request method name |
-query | string | ctx.req.query | Get method params |
-remoteIP | string | - | Get remote ip even though proxy by nginx , see common >> getIP function |
-statusCode | string | ctx.res.statusCode | Http response statusCode |
-traceId | string | ${timestamp}-${shortid} | Trace id of full process log |
-url | string | ctx.req.originalUrl | Http request url |
-user | string | ctx.req.user | Remote user info |
.debugLoggerConfig | object | - | The configuration for debug logger |
-format | function | [${timeFormat}] [${level}] ${label} - ${json} | ↑ |
-level | string | debug | ↑ |
-transports | array | [ transports.Console ] | ↑ |
option.filter.recursion
not yet developed.
Is recursion. In case {"body":{"password":{"a":1}}}
, if true
will be {"body":{"password":{"a":"*"}}}
; else , will be {"body":{"password":"*"}}
.option.filter.replaceChat
not yet developed.
only support String type.warning/silly/verbose
classifyfilter
functionstringify
option field to use JSON.stringify(message) ; before this , judge params typeofOptions
descriptionKafka
transport configerror email
configtrace-id
of req
, add the key
of this apptrace-id
and the trace-key
fork https://github.com/baijijs/logger.git
git clone <your own repository>
git branches <your own branch>
git checkout <your own branch>
yarn install -D
... something change
git cz
... step by step add commit with message
git push
pull request
Install development environment module .
yarn install -D
All of the logger test cases are written with Jest
. They can be run with npm
or yarn
.
npm test
# OR
yarn test
Benchmark report log out to ./docs/benchmark.report.log
.
Based on bestiejs/benchmark.js
npm run dev-filter
npm run dev-filter-false
npm run benchmark
FAQs
the Logger Module for Baiji
The npm package baiji-logger receives a total of 6 weekly downloads. As such, baiji-logger popularity was classified as not popular.
We found that baiji-logger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.