# express-log-url

> ExpressJS pretty printer for URLs

Latest version **1.6.0** (published 2024-03-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install express-log-url
pnpm add express-log-url
yarn add express-log-url
bun add express-log-url
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.0 |
| Published | 2024-03-18 |
| First published | 2015-07-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 6.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Matt Carter |
| Maintainers | hash-bang |
| Keywords | express, expressjs, log, logger, url, pretty, print |

## Links

- npm: https://www.npmjs.com/package/express-log-url
- Repository: https://github.com/hash-bang/node-express-log-url
- Homepage: https://github.com/hash-bang/node-express-log-url#readme
- Issues: https://github.com/hash-bang/node-express-log-url/issues
- npm.io page: https://npm.io/package/express-log-url

## Dependencies (1)

- [chalk](https://npm.io/package/chalk.md) ^4.1.2

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.6.0 (latest) — 2024-03-18
- 1.5.1 — 2020-08-31
- 1.5.0 — 2020-08-31
- 1.4.0 — 2019-07-26
- 1.3.6 — 2019-06-25
- 1.3.5 — 2019-06-25
- 1.3.4 — 2019-02-06
- 1.3.3 — 2019-02-06
- 1.3.2 — 2019-02-06
- 1.3.1 — 2018-10-09
- 1.3.0 — 2018-09-26
- 1.2.4 — 2018-09-26
- 1.2.3 — 2018-06-08
- 1.2.2 — 2018-01-01
- 1.2.1 — 2017-11-04
- … 8 more at https://npm.io/package/express-log-url/versions

## README

express-log-url
===============
Simple, nice-looking, logging for Express.

![Screenshot](docs/screenshot.png)


Installation
============

Install package
---------------

```
npm --save install express-log-url
```


Install within Express
----------------------

```javascript
// 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:

```javascript
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

```javascript
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:

| Field          | Description                                              |
|----------------|----------------------------------------------------------|
| `indent`       | Indentation to use. Is commonly a number of spaces       |
| `method`       | Short (ideally no more than 5 characters) method to show |
| `code`         | The status code returned by the server                   |
| `responseTime` | The time (in milliseconds) the server took to respond    |
| `info`         | Additional information to log against the request        |


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

| Setting           | Type       | Default                                      | Description                           |
|-------------------|------------|----------------------------------------------|---------------------------------------|
| `log.indent`      | String     | `null`                                       | Prefix for any log entry              |
| `log.username `   | Function   | `req => req.user ? req.user.username || req.user.email : false` | How to determine the current username |

---
_Source: https://npm.io/package/express-log-url · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
