1.0.2 • Published 3 years ago

egg-yzziot-log v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

egg-yzziot-log

NPM version build status Test coverage David deps Known Vulnerabilities npm download

Install

$ npm i egg-yzziot-log --save

Usage

// {app_root}/config/plugin.js
exports.yzziotLog = {
  enable: true,
  package: 'egg-yzziot-log',
};

Configuration

simple logs instance

// {app_root}/config/config.default.js
exports.yzziotLog = {
    client: {
        endpoint: '',
        // make aliyun account produce accessKeyId
        accessKeyId: '',
        // make aliyun account produce accessKeySecret
        accessKeySecret: '',
        // logs service region
        region: '',
        // logs service project
        project: '',
        // logs service logStore
        logStore: '',
        // whether allow upload
        uploadFlag: '',
    },
};

Usage:

app.yzziotLog.error(message, source, tenant);  // you can access to simple logs instance by app.yzziotlog

multi logs instance

// {app_root}/config/config.default.js
exports.yzziotLog = {
    clients: {
        // clientId, access the client instance by app.yzziotLog.get('clientId')
        log1: {
            endpoint: '',
            accessKeyId: '',
            accessKeySecret: '',
            region: '',
            project: '',
            logStore: '',
            uploadFlag: '',
        },
        log2: {
            endpoint: '',
            accessKeyId: '',
            accessKeySecret: '',
            region: '',
            project: '',
            logStore: '',
            uploadFlag: '',
        },
        // ...
    },
    // default configuration for all logs service
    default: {},
} 

Usage:

const client1 = app.yzziotLog.get('log1');
client1.error(message, source, tenant); 

const client2 = app.yzziotLog.get('log2');
client2.error(message, source, tenant); 

see config/config.default.js for more detail.

user guide

Info Level Logs

app.yzziotLog.info(message, source, tenant);

Debug Level Logs

app.yzziotLog.debug(message, source, tenant);

Warn Level Logs

app.yzziotLog.warn(message, source, tenant);

Error Level Logs

app.yzziotLog.error(message, source, tenant);

Questions & Suggestions

Please open an issue here.

License

MIT

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago