Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
think-logger3
Advanced tools
ThinkJS3.x log module, based on log4js.
npm install think-logger3
const Logger = require('think-logger3');
const logger = new Logger();
logger.debug('Hello World');
There has four log function you can use:
logger.info('info log');
logger.debug('debug log');
logger.warn('warn log');
logger.error('error log');
If you want to log file, you can use file adapter like this:
const Logger = require('think-logger3');
const logger = new Logger({
handle: Logger.File,
filename: __dirname + '/test.log'
});
logger.debug('Hello World');
This adapter will log to a file, and supports split log file by a constant file size. For example:
const Logger = require('think-logger3');
const logger = new Logger({
handle: Logger.File,
filename: __dirname + '/debug.log',
maxLogSize: 50 * 1024, //50M
backups: 10 //max chunk number
})
Then initial log would create a file called debug.log
. After this file reached maxLogSize
, a new file named debug.log.1
will be created. After log file number reached backups
, old log chunk file will be removed.
filename
: log filenamemaxLogSize
: The maximum size (in bytes) for a log file, if not provided then logs won't be rotated.backups
: The number of log files to keep after logSize has been reached (default 5)absolute
: If filename
is a absolute path, the absolute
value should be true
.layout
: Layout defines the way how a log record is rendered. More layouts can see here.This adapter will log to a file, moving old log messages to timestamped files according to a specified pattern. For example:
const Logger = require('think-logger3');
const logger = new Logger({
handle: Logger.DateFile,
filename: __dirname + '/debug.log',
pattern: '-yyyy-MM-dd',
alwaysIncludePattern: false
});
Then initial log would create a file called debug.log
. At midnight, the current debug.log
file would be rename to debug.log-2017-03-12
(for example), and a new debug.log
file created.
level
: log levelfilename
: log base filenamepattern
: date filename would append to filename. A new file is started whenever the pattern for the current log entry differs from that of the previous log entry. The following strings are recognised in the pattern:
alwaysIncludePattern
: If alwaysIncludePattern
is true, then the initial file will be filename.2017-03-12
and no renaming will occur at midnight, but a new file will be written to with the name filename.2017-03-13
.absolute
: If filename
is a absolute path, the absolute
value should be true
.layout
: Layout defines the way how a log record is rendered. More layouts can see here.If those adapter configuration can't satisfy your need, you can use this adapter and set config like log4js. For example:
const Logger = require('think-logger3');
const logger = new Logger({
handle: Logger.Basic,
appenders: {
everything: { type: 'file', filename: 'all-the-logs.log' },
emergencies: { type: 'file', filename: 'oh-no-not-again.log' },
'just-errors': { type: 'logLevelFilter', appender: 'emergencies', level: 'error' }
},
categories: {
default: { appenders: ['just-errors', 'everything'], level: 'debug' }
}
});
All properties are as same as log4js except handle
property. You can see more configure properties on log4js documentation.
Contributions welcome!
FAQs
logger for ThinkJS 3.x
The npm package think-logger3 receives a total of 547 weekly downloads. As such, think-logger3 popularity was classified as not popular.
We found that think-logger3 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 8 open source maintainers 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.