zhi-log
a simple logger for Node
Features
- 100% compatible with console
- log level support
- custom logger name
- a simple LogFactory
Usage
Default devel is INFO
import LogUtil from "zhi-log"
const logger = LogUtil.defaultLogFactory().getLogger()
logger.debug("This is debug log")
logger.info("This is info log")
logger.error("This is error log")
You can set a custom log level
import LogUtil from "zhi-log"
const logger = LogUtil.customLogFactory(LogLevelEnum.LOG_LEVEL_DEBUG).getLogger("test")
logger.debug("This is debug log")
logger.info("This is info log")
logger.error("This is error log")
You can also set a custom prefix sign
import LogUtil from "zhi-log"
const logger = LogUtil.customLogFactory(LogLevelEnum.LOG_LEVEL_DEBUG, "my-log").getLogger("test")
logger.debug("This is debug log")
logger.info("This is info log")
logger.error("This is error log")
Also, if you config LOG_LEVEL in your project's .env
file, it will work
LOG_LEVEL=DEBUG
DEFAUT_LOGGER=zhi