@sawerjs/logger
v0.0.0
Published
Simple logger used by sawer
Downloads
35
Readme
@sawerjs/logger
Simple logger used by sawer.
This should be preferably used only in development mode for now as it brings picocolors
dependency with it. If that's not a problem for you and you just want a simple logger, feel free to use it.
Usage
A basic example:
import logger from '@sawerjs/logger';
logger.success('Hello, world!');
// "● Hello, world!"
Create a new logger
Create a new instance of the logger with new Logger()
:
import { Logger } from '@sawerjs/logger';
const logger = new Logger();
Enable debug mode
Enable debug mode with Logger.setDebug(true)
:
import logger from '@sawerjs/logger';
logger.setDebug(true);
logger.debug('Debug message');
// "● Debug message"
Alternatively you can enable debug mode when creating a logger:
import { Logger } from '@sawerjs/logger';
const logger = new Logger({ debug: true });
API
log.success(...args)
callsconsole.log
with green dot (●
) prefixlog.info(...args)
callsconsole.log
with blue dot (●
) prefixlog.warn(...args)
callsconsole.log
with yellow dot (●
) prefixlog.error(...args)
callsconsole.log
with red dot (●
) prefixlog.debug(...args)
callsconsole.log
with magenta dot (●
)Note that debug mode must be enabled with
Logger.setDebug(true)
log.log(...args)
simply callsconsole.log(...args)
log.setDebug(debug)
sets debug modelog.enableDebug
variable istrue
when debug mode is enabled
License
This project is licensed under the MIT License ❤️