brick-winston
v0.2.0
Published
winston for brick engine
Downloads
1
Readme
brick-winston
基于brick-engine的winston工具包.
Install
npm install --save brick-winston
npm install --save winston
Usage
Setup
const {defineApplication} = require('brick-engine');
const {winstonSetup} = require('brick-winston');
const app = {};
winstonSetup(app);
defineApplication(exports, app);
Define Winston Logger Instance
const { defineProviderFactory } = require('brick-engine');
const { defineWinston } = require('brick-winston');
const { WINSTON_ID,WINSTON_TRANSPORT_ID } = require('./constants');
const { transports } = require('winston');
class Module {
}
exports.Module = Module;
defineWinston(Module,{id:WINSTON_ID,level:'info',transports:[WINSTON_TRANSPORT_ID]});
function transportFactory(){
return new transports.File({ filename: 'error.log', level: 'error' });
}
defineProviderFactory(Module,{id:WINSTON_TRANSPORT_ID,transportFactory});
Use Winston Logger Instance
const { WINSTON_ID } = require('./constants');
const { defineProviderFactory } = require('brick-engine');
class Service {
constructor(logger) {
this.logger = logger;
}
async create(entity){
this.logger.info('create method called',entity)
}
}
exports.Service = Service;
defineProviderFactory(Service,{deps:[{id:WINSTON_ID}]});
Documentations
使用jsdoc
生成注释文档
git clone https://github.com/kiba-zhao/brick-winston.git
cd brick-winston
npm install
npm run docs
open docs/index.html