A
A
Anton Ulanov2016-02-26 14:37:53
Node.js
Anton Ulanov, 2016-02-26 14:37:53

How to set up Winston for Node.js logging?

Good afternoon, do not kick hard, but I can not master the logger setting. At the moment my config looks like this.

var winston = require('winston');
winston.emitErrs = true;

var logger = new (winston.Logger)({
  transports: [
    new (winston.transports.File)({
      name: 'info-file',
      filename: './logs/filelog-info.log',
      level: 'info'
    }),
    new (winston.transports.File)({
      name: 'error-file',
      filename: './logs/filelog-error.log',
      level: 'error'
    }),
    new (winston.transports.console)({
      level: 'debug',
      handleExceptions: true,
      json: false,
      colorize: true
    })
  ]
});

module.exports = logger;
module.exports.stream = {
    write: function(message, encoding){
        logger.info(message);
    }
};

I want the logger to write errors to the error file, connect to the server to the info file, and print info to the console.
At the moment, the error is in the new (winston.transports.console) line, and I can't figure out how to overcome it. Tell me where I did wrong

Answer the question

In order to leave comments, you need to log in

9 answer(s)
A
Anton Ulanov, 2016-02-26
@antonsr98

I asked myself I answered

new (winston.transports.Console)({ level: 'info' })

S
Sergey Romanov, 2014-11-24
@Bagumices

There's no such thing. Each person will take it in their own way. You just need to try to understand the principles as it suits you.
Learning systems equalize all people, make their logic and way of perception the same. I do not think that you can become an extraordinary thinking person by studying science according to a ready-made popular scheme. If you want to be a genius, just teach at your convenience and develop your own learning system in the process. Although it is very simple. For me personally, it is in 3 words.
Diligence
Consistency
Dedication
I guarantee you that if you study any subject for 6 hours a day for 1 month, dedicated, diligently, attentively, even without any system, you will be an expert. Moreover, at the end you will already have your own system that is ideal for you.

X
xaigo, 2014-11-24
@xaigo

I completely agree with the first commentator: there is no universal scheme, there is your own system, which you make up from the methods and habits that are most effective for you.
But if it is the methodology that interests you and English allows, you can read the blogs Cal Newport and Scott H Young . The first deals with the study of how students (and everyone else) learn as quickly and efficiently as possible and willingly shares his observations. The second is his former student, who tried many of the proposed techniques on himself, "digested" and developed his own. Both often deal with specific cases (which language is best to learn, how to prepare for exams, how to learn material faster, etc.), but also pay a lot of attention to the philosophy of the process itself.

S
Stanislav Boyarintsev, 2014-11-27
@masterL

Ron Fry memory training. Express Course
Chapters on how to read and how to summarize information.
Time management. Full course - several authors of the book, you need the "Mind Management" section, its author is Sergey Bekhterev - a section on how to read books and how to make Mind maps.
To memorize information, the interval repetition method and Anka are well suited:
habrahabr.ru/post/240451
habrahabr.ru/post/196448
In order to get any "skill" you need practice. That is, the theoretical study of any material must be accompanied by mandatory practice.
Try to concentrate on studying something so much higher efficiency.
I will say for myself:
Do not learn anything for the future - remembering such information is laborious, it is better to study what you can use right here and now.
Stratoplane article on this topic

T
throughtheether, 2014-11-23
@throughtheether

Interesting, in my opinion, course on coursera.

E
Eugene Burmakin, 2014-11-23
@Freika

www.supermemo.com/articles/20rules.htm read this and get into the habit of using Anki

D
Denis Krivoschekov, 2014-11-24
@densomart

I agree that there are no ready-made schemes. Perhaps because they depend on the specifics of what you are studying. You need to search for specific thematic forums (for example, how to ride a bike - they know on the cyclists forum), almost everywhere there are similar, already asked questions and bits of answers that help build your system.
For example, I had to study school mathematics again, I tried to read smart books, the result was zero. In the chat, an advanced person simply said the name and author of the problem book to be solved. For the first half of the month, I was stupid on the problem book, but suddenly I began to understand how to solve it. During this time, I found many more sources of knowledge in mathematics and realized to what extent I need it at all, I structured the knowledge.
You need to be able to structure in general for this by studying different things. Try to pump up old Soviet school textbooks, try to study a few chapters from them. Anwser the questions. And catch one of the process options. Well, and of course the puzzles. This is more important, far-fetched - "structuring information."
The most important principle in learning is whether or not you can answer a question on a topic you have learned, or you can do what you have been taught. If not, then go ahead and learn more.
It's not a fast track, but it's a way to another world. When you begin to truly learn, everything around you will begin to change drastically. That's when you finally learned - to learn.

A
Andrey Akimov, 2014-11-25
@Ostan

theory + practice + communication + news
- this is in relation to the field of IT

B
brover88, 2017-12-15
@brover88

There are many rules for effective learning, for example:
- special nutrition that improves brain function (for example, omega-3 amino acids);
- linking new knowledge with previous ones, repeating what has been learned;
- calm environment;
- sports;
- change of type of activity;
- Sufficient supply of oxygen;
- brainstorming, mind-mapping;
- etc.
You can read more here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question