Ultimate logger system for your an application.
We Appreciate PowerLogs.
import { octoLogger } from 'octologger'; // or import { logger, xlog } from 'octologger';
octoLogger.info('Wow!');
octoLogger.scope('users', (scope) => {
scope.add('Start');
setTimeout(() => {
scope.done('End');
}, 100);
});
For logger from out of box.
- setup(options:
LoggerOptions
):void
- time:
boolean
— Disable time - silent:
boolean
— Disable output - output:
Output
- time:
- scope(name:
string
):ScopeEntry
- scope(name:
string
, detail:any
):ScopeEntry
- scope(name:
string
, executer:() => void
):ScopeEntry
- scope(name:
string
, detail:any
, executer:() => void
):ScopeEntry
- print():
void
- clear():
void
- entries():
Entry[]
- entry():
Entry
- add(...args:
any[]
):Entry
— similarlog
- log(...args:
any[]
):void
- info(...args:
any[]
):void
- done(...args:
any[]
):void
- verbose(...args:
any[]
):void
- error(...args:
any[]
):void
To make the logger show the correct position (file and line) of the output in console
, follow the instructions:
- Open
Dev Tools
->Settings
- Choice a
Ignore List
- Click
Add Pattern
- Enter "Pattern":
octologger|@mail-core/logger
- Profit 💁🏻♂️
import { createLogger, universalOutput } from 'octologger';
// Create
const xlog = createLogger(
// Options
{
output: [universalOutput()],
},
// Methods
({logger, createEntry}) => ({
ok(msg: string, detail?: any) {
logger.add(createEntry(
'info', // level
'👌', // badge
'OK', // label
msg, // message
detail, // detail
));
},
error(msg: string, detail?: any) {
logger.add(createLogEntry(levels.error, '❌', 'error', msg, detail));
},
}),
);
// Usage
xlog.ok('Wow!');
xlog.error('Ooops...');
To get the position of the logger call in production, you need to use ttsc or transformers.
{
"compilerOptions": {
"plugins": [
{
"type": "checker",
"transform": "octologger/tx"
}
]
}
import {transformer} from 'octologger/tx';
// ts-loader config
getCustomTransformers(program) {
return {
before: [
transformer(program),
],
};
}
npm i
npm test
, code coverage