1.6.0 • Published 2 months ago

express-log-url v1.6.0

Weekly downloads
550
License
MIT
Repository
github
Last release
2 months ago

express-log-url

Simple, nice-looking, logging for Express.

Screenshot

Installation

Install package

npm --save install express-log-url

Install within Express

// Somewhere within your server setup

app.use(require('express-log-url'));

Surpressing log entries

To surpress logging set res.logIgnore = true.

Socket logging

The module also contains an extremely simple socket logging function:

var io = require('socket.io').listen(server);
io.on('connect', socket => {
	socket.on('something', require('express-log-url').socket);
	socket.on('something', ()=> ...Actually do work...);
})

Manual logging

The module supports an object containing optional fields which will be output as if it were a fresh server request

var logger = require('express-log-url');

// Simulate a GET request
logger.log({method: 'GET', code: 200, path: '/', responseTime: 10});

// Simulate a POST request with additional fields
logger.log({method: 'POST', code: 400, path: '/some/post', responseTime: 20, info: 'Lack of widgets'});

Supported fields:

FieldDescription
indentIndentation to use. Is commonly a number of spaces
methodShort (ideally no more than 5 characters) method to show
codeThe status code returned by the server
responseTimeThe time (in milliseconds) the server took to respond
infoAdditional information to log against the request

Options

Set the following options via app.set('OPTION', 'VALUE');

SettingTypeDefaultDescription
log.indentStringnullPrefix for any log entry
log.usernameFunctionreq => req.user ? req.user.username || req.user.email : falseHow to determine the current username
1.6.0

2 months ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.0

5 years ago

1.3.6

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.5

7 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

9 years ago

1.0.0

9 years ago