lark-log

    2.6.8 • Public • Published

    lark-log

    This is Lark.js log module.

    NPM version build status Test coverage NPM downloads Node.js dependencies

    Useage

    sample

    const LarkLogger = require('lark-log');
     
    const logger = new LarkLogger({ 'using-default': true });
     
    logger.notice("Hello");

    configure

     
    const LarkLogger = require('lark-log');
     
    const logger = new LarkLogger();
     
    const config = {
        {
        "@description": "This is the default config",
        "level": 1,
        "methods": {
            "debug": {
                "level": 1,
                "output": "console"
            },
            "print": {
                "level": 2,
                "output": "console"
            },
            "trace": {
                "level": 2,
                "output": "system"
            },
            "notice": {
                "level": 3,
                "output": "system"
            },
            "warn": {
                "level": 4,
                "output": "system"
            },
            "error": {
                "level": 5,
                "output": "error"
            },
            "fatal": {
                "level": 5,
                "output": "error"
            }
        },
        "outputs": {
            "default": {
                "line-max-length": 2000,
                "format": "<%= method.toUpperCase() %>:\t<%= date('yyyy-mm-dd HH:MM:ss')%>\t<%= content %>",
                "path-prefix": "logs/",
                "path-suffix": ".log"
            },
            "console": null,
            "system": {
                "path": "system"
            },
            "error": {
                "path": "system",
                "path-suffix": ".log.wf"
            }
        }
    };
     
    logger.configure(config);
     
    logger.debug('debug');// write "debug " to terminal
    logger.notice('notice');// write "NOTICE: {DATETIME} notice" to system.log, {DATETIME} is in "yyyy-mm-dd HH:MM:ss" style
    logger.error('error');//write to system.log.wf

    logrotate

    logger.configure({
        "outputs": {
            "default": {
                "path-suffix": ".log.<%= date('yyyymmddHH') %>"
            }
        }
    });
    
    • If '<%' exists in path (including prefix and suffix), the path will be regarded as a dynamic path. LarkLog calculates the path every when an output came.

    Keywords

    Install

    npm i lark-log

    DownloadsWeekly Downloads

    43

    Version

    2.6.8

    License

    MIT

    Unpacked Size

    24.5 kB

    Total Files

    14

    Last publish

    Collaborators

    • mdemo
    • viringbells
    • zezhou