Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: winstonjs/winston
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3.2.1
Choose a base ref
...
head repository: winstonjs/winston
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.3.0
Choose a head ref
Loading
24 changes: 8 additions & 16 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
.nyc_output/
coverage/
docs
examples/
scratch/
test/
.*
*.log
test
test/*
!test/helpers.js
!test/transports/transport.js
node_modules/
node_modules/*
*.md
examples
examples/*
docs
docs/*
.nyc_output/
.nyc_output/*
coverage/
coverage/*
scratch
scratch/*
appveyor.yml
tsconfig.json
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
sudo: false
language: node_js
node_js:
- "6"
- "8"
- "10"
- "11"
- "12"
- "14"

before_install:
- travis_retry npm install
@@ -14,9 +13,9 @@ script:
- npm test
- ./node_modules/.bin/tsc --version ; ./node_modules/.bin/tsc -p test

matrix:
allow_failures:
- node_js: "11"
#matrix:
# allow_failures:
# - node_js: "14"

notifications:
email:
22 changes: 20 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,24 @@
# CHANGELOG

## v3.2.1 / 2018-01-29
## v3.3.0 / 2020-06-21

- [#1779] Fix property name in rejection handler.
- [#1768] Exclude extraneous files from NPM package.
- [#1364], [#1714] Don't remove transport from logger when transport error
occurs.
- [#1603] Expose `child` property on default logger.
- [#1777] Allow HTTP transport to pass options to request.
- [#1662] Add bearer auth capabilities to HTTP transport.
- [#1612] Remove no-op in file transport.
- [#1622], [#1623], [#1625] Typescript fixes.
- (Minor) [#1647], [#1793] Update CI settings.
- (Minor) [#1600], [#1605], [#1593], [#1610], [#1654], [#1656], [#1661],
[#1651], [#1652], [#1677], [#1683], [#1684], [#1700], [#1697], [#1650],
[#1705], [#1723], [#1737], [#1733], [#1743], [#1750], [#1754], [#1780],
[#1778] README, Transports.md, other docs changes.
- [#1672], [#1686], [#1772] Update dependencies.

## v3.2.1 / 2019-01-29
### UNBOUND PROTOTYPE AD INFINITUM EDITION

- #[1579], (@indexzero) Fallback to the "root" instance **always** created by
@@ -11,7 +29,7 @@
- [#1583], (@kibertoad) Add typings for defaultMeta (Fixes [#1582])
- [#1586], (@kibertoad) Update dependencies.

## v3.2.0 / 2018-01-26
## v3.2.0 / 2019-01-26
### SORRY IT TOO SO LONG EDITION

> **NOTE:** this was our first release using Github Projects. See the
127 changes: 109 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ A logger for just about everything.

[![Join the chat at https://gitter.im/winstonjs/winston](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/winstonjs/winston?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## winston@3.2.0
## winston@3

See the [Upgrade Guide](UPGRADE-3.0.md) for more information. Bug reports and
PRs welcome!
@@ -47,27 +47,29 @@ The recommended way to use `winston` is to create your own logger. The
simplest way to do this is using `winston.createLogger`:

``` js
const winston = require('winston');

const logger = winston.createLogger({
level: 'info',
format: winston.format.json(),
defaultMeta: { service: 'user-service' },
transports: [
//
// - Write to all logs with level `info` and below to `combined.log`
// - Write all logs error (and below) to `error.log`.
// - Write all logs with level `error` and below to `error.log`
// - Write all logs with level `info` and below to `combined.log`
//
new winston.transports.File({ filename: 'error.log', level: 'error' }),
new winston.transports.File({ filename: 'combined.log' })
]
new winston.transports.File({ filename: 'combined.log' }),
],
});

//
// If we're not in production then log to the `console` with the format:
// `${info.level}: ${info.message} JSON.stringify({ ...rest }) `
//
//
if (process.env.NODE_ENV !== 'production') {
logger.add(new winston.transports.Console({
format: winston.format.simple()
format: winston.format.simple(),
}));
}
```
@@ -96,9 +98,12 @@ logger to use throughout your application if you so choose.
* [Transports]
* [Multiple transports of the same type](#multiple-transports-of-the-same-type)
* [Adding Custom Transports](#adding-custom-transports)
* [Common Transport options](#common-transport-options)
* [Exceptions](#exceptions)
* [Handling Uncaught Exceptions with winston](#handling-uncaught-exceptions-with-winston)
* [To Exit or Not to Exit](#to-exit-or-not-to-exit)
* [Rejections](#rejections)
* [Handling Uncaught Promise Rejections with winston](#handling-uncaught-promise-rejections-with-winston)
* [Profiling](#profiling)
* [Streaming Logs](#streaming-logs)
* [Querying Logs](#querying-logs)
@@ -117,12 +122,13 @@ from most important to least important._

``` js
const levels = {
error: 0,
warn: 1,
info: 2,
verbose: 3,
debug: 4,
silly: 5
error: 0,
warn: 1,
info: 2,
http: 3,
verbose: 4,
debug: 5,
silly: 6
};
```

@@ -512,17 +518,18 @@ the `syslog` levels are prioritized from 0 to 7 (highest to lowest).
}
```

Similarly, `npm` logging levels are prioritized from 0 to 5 (highest to
Similarly, `npm` logging levels are prioritized from 0 to 6 (highest to
lowest):

``` js
{
error: 0,
warn: 1,
info: 2,
verbose: 3,
debug: 4,
silly: 5
http: 3,
verbose: 4,
debug: 5,
silly: 6
}
```

@@ -740,6 +747,34 @@ module.exports = class YourCustomTransport extends Transport {
};
```

## Common Transport options

As every transport inherits from [winston-transport], it's possible to set
a custom format and a custom log level on each transport separately:

``` js
const logger = winston.createLogger({
transports: [
new winston.transports.File({
filename: 'error.log',
level: 'error',
format: winston.format.json()
}),
new transports.Http({
level: 'warn',
format: winston.format.json()
}),
new transports.Console({
level: 'info',
format: winston.format.combine(
winston.format.colorize(),
winston.format.simple()
)
})
]
});
```

## Exceptions

### Handling Uncaught Exceptions with winston
@@ -855,6 +890,61 @@ const logger = winston.createLogger({ exitOnError: ignoreEpipe });
logger.exitOnError = ignoreEpipe;
```

## Rejections

### Handling Uncaught Promise Rejections with winston

With `winston`, it is possible to catch and log `uncaughtRejection` events
from your process. With your own logger instance you can enable this behavior
when it's created or later on in your applications lifecycle:

``` js
const { createLogger, transports } = require('winston');

// Enable rejection handling when you create your logger.
const logger = createLogger({
transports: [
new transports.File({ filename: 'combined.log' })
],
rejectionHandlers: [
new transports.File({ filename: 'rejections.log' })
]
});

// Or enable it later on by adding a transport or using `.rejections.handle`
const logger = createLogger({
transports: [
new transports.File({ filename: 'combined.log' })
]
});

// Call rejections.handle with a transport to handle rejections
logger.rejections.handle(
new transports.File({ filename: 'rejections.log' })
);
```

If you want to use this feature with the default logger, simply call
`.rejections.handle()` with a transport instance.

``` js
//
// You can add a separate rejection logger by passing it to `.rejections.handle`
//
winston.rejections.handle(
new winston.transports.File({ filename: 'path/to/rejections.log' })
);

//
// Alternatively you can set `handleRejections` to true when adding transports
// to winston.
//
winston.add(new winston.transports.File({
filename: 'path/to/combined.log',
handleRejections: true
}));
```

## Profiling

In addition to logging messages and metadata, `winston` also has a simple
@@ -1077,7 +1167,7 @@ If you prefer to manage the `Container` yourself, you can simply instantiate one
``` js
const winston = require('winston');
const { format } = winston;
const { combine, json } = format;
const { combine, label, json } = format;

const container = new winston.Container();

@@ -1132,6 +1222,7 @@ npm test
[nyc]: https://github.com/istanbuljs/nyc
[assume]: https://github.com/bigpipe/assume
[logform]: https://github.com/winstonjs/logform#readme
[winston-transport]: https://github.com/winstonjs/winston-transport

[Read the `winston@2.x` documentation]: https://github.com/winstonjs/winston/tree/2.x

4 changes: 2 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@ version: "{build}"

environment:
matrix:
- nodejs_version: 6
- nodejs_version: 8
- nodejs_version: 10
- nodejs_version: 12
- nodejs_version: 14

matrix:
fast_finish: true
Loading