We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我希望可以再網站後台使用Logger System,記錄每位使用者的Request Method、以及錯誤訊息,有以下需求
我在 Mac 10.10 下使用 npm 安裝 node.js 7.6.0 ,使用sails.js 0.12
我原本使用winston,為了要可以分類輸出log,我參考以下做法
const winston = require('winston'); // let debug = new winston.Logger({ // levels: { // debug: 0 // }, // transports: [ // new (winston.transports.File)({ filename: './logs/debug.log', color: false,level: 'debug'}), // new (winston.transports.Console)({level: 'debug'}) // ] // }); let info = new winston.Logger({ levels: { info: 1 }, transports: [ new (winston.transports.File)({ filename: './logs/info.log', level: 'info'}), new (winston.transports.Console)({level: 'info'}) ] }); let warn = new winston.Logger({ levels: { warn: 2 }, transports: [ new (winston.transports.File)({ filename: './logs/warning.log', level: 'warn'}), new (winston.transports.Console)({level: 'warn'}) ] }); let error = new winston.Logger({ levels: { error: 3 }, transports: [ new (winston.transports.File)({ filename: './logs/error.log', level: 'error'}), new (winston.transports.Console)({level: 'error'}) ] }); module.exports = { info: function(msg){ info.info(msg); }, warn: function(msg){ warn.warn(msg); }, error: function(msg){ error.error(msg); }, log: function(level,msg){ let lvl = exports[level]; lvl(msg); } };
但是發現 他會出現資料掉失的問題,例如說我插入middlewear想要打印全部的HTTP Request
myRequestLogger: function (req, res, next) { console.log(req.method, req.url , req.method, req.body, req.query); logger.info("Requested :: " + ", req-method:" + req.method + ", req-url:" + req.url + req.method==='POST' ? ", req-body"+req.body:"," + req.method==='GET' ? ", req-query" + req.query: ""); return next(); },
發現winston並沒有輸出應有的資訊,我有使用console.log作為比對,console.log顯示為正確資訊
我有照Sails官網的做法sails.config.log會有同樣的資訊不完整或是遺失的問題
The text was updated successfully, but these errors were encountered:
抱歉我剛才發現錯誤了,忘記+的優先順序高於?判斷式,所以會導致輸出錯誤。 麻煩管理員刪除Issue,謝謝
Sorry, something went wrong.
sails 本身就有帶 log module 了,是可以指定輸出的 file path 的
No branches or pull requests
目的
我希望可以再網站後台使用Logger System,記錄每位使用者的Request Method、以及錯誤訊息,有以下需求
使用的工具
我在 Mac 10.10 下使用 npm 安裝 node.js 7.6.0 ,使用sails.js 0.12
遇到的問題
我原本使用winston,為了要可以分類輸出log,我參考以下做法
但是發現 他會出現資料掉失的問題,例如說我插入middlewear想要打印全部的HTTP Request
發現winston並沒有輸出應有的資訊,我有使用console.log作為比對,console.log顯示為正確資訊
嘗試過的解法
我有照Sails官網的做法sails.config.log會有同樣的資訊不完整或是遺失的問題
The text was updated successfully, but these errors were encountered: