onelogger
The only ONE logger.
Install
npm i onelogger
Usage
Get logger
import { getLogger, getCoreLogger } from 'onelogger';
const logger = getLogger();
logger.info('hello world');
const loggerWithPrefix = getLogger('my-prefix-name1');
loggerWithPrefix.info('hello world');
const coreLogger = getCoreLogger('my-prefix-name2');
coreLogger.info('hello world on core logger');
const coreLoggerWithPrefix = getCoreLogger('my-prefix-name2');
coreLoggerWithPrefix.info('hello world on core logger');
Set custom logger
The default logger and coreLogger will pipe to global.console
, you can change them to your real logger.
The custom logger must implements ILogger
interface.
import { setLogger, setCoreLogger, setCustomLogger } from 'onelogger';
setLogger(customLogger);
setCoreLogger(customCoreLogger);
setCustomLogger('myBizLogger', myBizLogger);
getCustomLogger('myBizLogger');
License
MIT
Contributors
This project follows the git-contributor spec, auto updated at Sat Jan 20 2024 22:39:14 GMT+0800
.