Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

winston-tagged-http-logger

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

winston-tagged-http-logger

Sets up logging to a TaggedLogger for important http.Server events

latest
Source
npmnpm
Version
1.2.1
Version published
Maintainers
2
Created
Source

winston-tagged-http-logger

Pipes events from a node HTTP server (vanilla OR express!) to a tagged-logger for winston.

Install me!

npm install winston-tagged-http-logger

Example

This will create a new winston logger and a new tagged-logger, and use a tagged-console-target to write the output to the console in all the colours of the rainbow.

var server = require('http').createServer();

// create our winston logger
var winston = require('winston');
var winstonLogger = new winston.Logger();

// create a transport so our logs have somewhere to go
var TaggedConsoleTarget = require('tagged-console-target');
winston.add(new TaggedConsoleTarget());

// make a new tagged logger to generate tagged log messages
var TaggedLogger = require('tagged-logger');
var logger = new TaggedLogger(winstonLogger, ['my amazing server']);

// Use this module to pipe the events from an http server to the logger
require('winston-tagged-http-logger')(server, log);

// All done! Events from `server` are now being piped to our `logger`!

What events are logged?

  • When the server starts running, showing the host and port that the server started on.
  • When a request is responded to, the client, path, status code, method and response time are logged.

What is the format of the logs?

Why, take a look! Here's an example of a log:

19:35:53.255 2013-06-26 Wednesday
19:35:53.589 [kvass, http] Listening on 0.0.0.0:9506
19:36:06.359 [kvass, http, 127.0.0.1:50230] GET /user/active 200 12ms

Broken down, these are the parts of a request log:

  • 19:36:06.359 the time on the server at which the request was received
  • [kvass, http, tags that have been assigned to this logger
  • 127.0.0.1:50230] a tag representing the origin of the request
  • GET the request method
  • /user/active the requested path
  • 200 the response status code
  • 12ms the time it took to respond to the request

FAQs

Package last updated on 06 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts