cms_applog_models
cms applog v2 model
Last updated 3 months ago by bestwk1993 .
ISC · Original npm · Tarball · package.json
$ cnpm install cms_applog_models 
SYNC missed versions from official npm registry.

#This Beta Test Please Skip

Applog V3 Model

Version 3

Install

npm i cms_applog_models

Version < 3

See this link click

How to use

Normal

applog.js

const { ApplogModel } = require('cms_applog_models');
let logOptions = {
    filename:'applogTest.log',
    maxLogSize:10000, // max size of log file
    backups:3 // num of backup file
}

let ApplogConfig = {
    self_system: 'test',
    self_group: 'test',
    self_type: 'test'
}

let mode = 'normal' 

exports.Log = class extends LogBeats{
    constructor(){
        super(ApplogConfig,logOptions,mode);
    }
}

test.js

const { Log } = require('./applog');
let applog = new Log();
applog.setMessage('Test')
    .setRequest({ code: 200, message: 'success' })
    .setEnvironment('local')
    .setSelfFunction('test')
    .sendIgnoreResponse(1);

Middleware

applog.js

const { createMiddlewareBeats } = require('cms_applog_models');
let logOptions = {
    filename:'applogTest.log',
    maxLogSize:10000, // max size of log file
    backups:3 // num of backup file
}
let ApplogConfig = {
    self_system: 'test',
    self_group: 'test',
    self_type: 'test'
}

let mode = 'loadtest'
exports.logMiddleware = createMiddlewareBeats(ApplogConfig,logOptions,mode);

index.js

const express = require('express');
const app = express();
const { logMiddleware } = require('./applog');

app.get('/test',logMiddleware,(req,res)=>{
    setTimeout(() => {
        res.send({code:200}).saveLog('Hello')    
    }, 3000);
    
});


app.listen(3000,()=>{
   console.log('Listen on port: ' + 3000);
});

Setting

logConfig

  • filename : Log name
  • maxLogSize : Max size of log file
  • backups : Num of Backup file

ApplogConfig

  • self_system : system name
  • self_group : group of system
  • self_type : type of system

Mode

  • normal : default
  • loadtest : not send log in this mode

Change Log

Change LOG

Current Tags

  • 3.0.9                                ...           latest (3 months ago)

32 Versions

  • 3.0.9                                ...           3 months ago
  • 3.0.8                                ...           9 months ago
  • 3.0.7                                ...           a year ago
  • 3.0.6                                ...           a year ago
  • 3.0.5                                ...           a year ago
  • 3.0.4                                ...           a year ago
  • 3.0.3                                ...           a year ago
  • 3.0.2                                ...           a year ago
  • 3.0.1                                ...           a year ago
  • 3.0.0                                ...           a year ago
  • 2.0.3                                ...           a year ago
  • 2.0.2                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 1.1.15                                ...           a year ago
  • 1.1.14                                ...           2 years ago
  • 1.1.13                                ...           2 years ago
  • 1.1.12                                ...           2 years ago
  • 1.1.11                                ...           2 years ago
  • 1.1.10                                ...           2 years ago
  • 1.1.9                                ...           2 years ago
  • 1.1.8                                ...           2 years ago
  • 1.1.7                                ...           2 years ago
  • 1.1.5                                ...           2 years ago
  • 1.1.4                                ...           2 years ago
  • 1.1.3                                ...           2 years ago
  • 1.1.2                                ...           2 years ago
  • 1.1.1                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.9                                ...           2 years ago
  • 1.0.8                                ...           2 years ago
  • 1.0.7                                ...           2 years ago
  • 1.0.5                                ...           2 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 1
Last Month 0
Dependencies (2)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |