Following are the common logger modules: 1) logger SUMMARY A simple logging library that combines the simple APIs of Ruby's logger.rb and browser-js console.log() USAGE A logger has 5 different levels of logging in a specific order: 'fatal', 'error', 'warn', 'info', 'debug' Each of these log levels has its own method on the logging instance. You can set the maximum log level on a logger at runtime. By default, a logger writes to STDOUT, but given a writeable file path, it will log directly to a file. Instantiation: // node/common.js style var logger = require('./logger').createLogger(); // logs to STDOUT var logger = require('./logger').createLogger('development.log'); // logs to a file 2) simple-node-logger A simple multi-level logger for console, file, and rolling file appenders. Features include: levels: trace, debug, info, warn, error and fatal levels (plus all and off) flexible ap...
fork() spawn() fork() is a particular case of spawn() that generates a new instance of a V8 engine. Spawn() launches a new process with the available set of commands. Multiple workers run on a single node code base for multiple tasks. This method doesn’t generate a new V8 instance and only a single copy of the node module is active on the processor.
Node.js, being an asynchronous platform, doesn’t wait around for things like file I/O to finish — Node.js uses callbacks. A callback is a function called at the completion of a given task; this prevents any blocking, and allows other code to be run in the meantime. Callbacks are the foundation of Node.js. Callbacks give us an interface with which to say, “and when you’re done doing that, do all this.” This allows us to have as many IO operations as our OS can handle happening at the same time. For example, in a web server with hundreds or thousands of pending requests with multiple blocking queries, performing the blocking queries asynchronously gives you the ability to be able to continue working and not just sit still and wait until the blocking operations come back.
Comments
Post a Comment