winston

I want to display the file Name in the log statement

南楼画角 提交于 2020-01-30 19:54:48
问题 For every logger statement with any level, I need to display the file name from where the log statement executed, below is the illustration I given below: Example : Below is the line executed from JobWork.js logger.info("getInCompleteJobs in job works"); Actual : 2012-11-05T06:07:19.158Z - info: getInCompleteJobs in job works Required : 2012-11-05T06:07:19.158Z - info JobWork.js : getInCompleteJobs in job works Without passing the fileName as a parameter from the log statement it should give

get line number and filename for a log output

倖福魔咒の 提交于 2020-01-14 08:24:06
问题 Is it possible to get the line number and file for each log output ? For example: var winston = require('winston'); winston.log('info', 'some message!'); // this is at line 4 of myfile.js should specify in log file that 'some message' came from myFile.js line 4. 回答1: You can pass the file name as label and you can get the file name from callingModule. Create logger.js file and code like var winston = require('winston'); var getLabel = function (callingModule) { var parts = callingModule

get line number and filename for a log output

本秂侑毒 提交于 2020-01-14 08:23:13
问题 Is it possible to get the line number and file for each log output ? For example: var winston = require('winston'); winston.log('info', 'some message!'); // this is at line 4 of myfile.js should specify in log file that 'some message' came from myFile.js line 4. 回答1: You can pass the file name as label and you can get the file name from callingModule. Create logger.js file and code like var winston = require('winston'); var getLabel = function (callingModule) { var parts = callingModule

How to track data in nodejs with microservices

雨燕双飞 提交于 2020-01-07 03:17:09
问题 I'm dealing with an application using multiple microservices. The application receieves data and processes it, and I'd like to have a way to monitor everything the received data is going throughout the microservices. Since the platform is nodejs we're dealing with asynchronous processing, logs wont always be written one after the other, and since the data does not have aמ ID the logs cannot be filtered in any convenient way. Is there any way to track the data from the first moment it enters

Winston/Node.js how add a Transport only for certain environment?

喜你入骨 提交于 2020-01-01 09:16:15
问题 I have the follow configuration: var winston = require('winston'); var Mail = require('winston-mail').Mail; var logger = new (winston.Logger)({ transports: [ new (winston.transports.Console)({ level: 'info', colorize: true }), new (winston.transports.File)({ level: 'info', filename: './logs/logs.log', new (Mail)({ to: 'xxxxxx@xxxxxx.xx', from: 'winston@xxxxx.xx', subject: 'Errors occurred', level: 'error', host: 'smtp.xxxxx.xx', username: 'xxxx@xxxx.xx', password: 'xxxxx', port: xxx }) ],

How do I get Winston to work with Webpack?

 ̄綄美尐妖づ 提交于 2019-12-30 06:18:11
问题 I have an electron application which is using node.js. I would like to use Winston for logging in the application. I've added winston to my package.json file, but when I run the build command for webpack I'm getting some warnings from the colors.js dependency in winston. '...the request of a dependency is an expression...' It then references winston and colors.js. Ignoring the warnings doesn't work, as the electron application gets an exception trying to load some files from winston. I did

How to log every message in new line using winston logger?

这一生的挚爱 提交于 2019-12-25 17:48:12
问题 we are using winston logger to log events to nodejs fs , i want to write every event into new line using winston, is it possible with to achieve that task using winston library or any other approach that works with nodejs. ctrl.js var winston = require('winston'); var consumer = new ConsumerGroup(options, topics); console.log("Consumer topics:", getConsumerTopics(consumer).toString()); logger = new (winston.Logger)({ level: null, transports: [ // new (winston.transports.Console)(), new

How is adding a new class with prototype methods a form of V8 optimization in JS?

半腔热情 提交于 2019-12-24 10:19:40
问题 I'm reading through Winston's code base and there was a comment in their DerivedLogger class line 22 that says: Create a new class derived logger for which the levels can be attached to the prototype of. This is a V8 optimization that is well known to increase performance of prototype functions. From what I gather here, they are saying that adding a new class (DerivedLogger) which adds prototype methods is a well known form of V8 optimization? how is it different from just adding the methods

Suppress console log of successful mocha tests

流过昼夜 提交于 2019-12-24 03:33:20
问题 When running mocha test suite, my console output is polluted with application logs. Is there an easy way to suppress these logs from successful tests? I'm able to suppress all logs for testing environment, however I'd like to see logs from failed tests. I'm using Winston as logging library. 回答1: You could set up a separate Winston transport when running tests that will write logs to a logfile, and show the contents of that file if the test failed: afterEach(function() { if (this.currentTest

Winston logger names

风流意气都作罢 提交于 2019-12-23 09:44:12
问题 Flatiron's logging library Winston is quite useful, but I can not figure how to assign names to loggers. I am expecting an output similar to other logging libraries, for instance: [<date>] [<log level>] <logger name> - <the message> Is it possible to configure Winston in such a way? Thank you. 回答1: When creating a logging transport, you can provide a label parameter which will be added to the log output between the log level and the log message. For example: var logger = new (winston.Logger)(