Skip to content

Commit

Permalink
Merge remote-tracking branch 'root/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mizumaki committed Jun 23, 2020
2 parents 9354721 + bc6f681 commit f93ebbb
Show file tree
Hide file tree
Showing 13 changed files with 3,318 additions and 2,178 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ script:
- npm test
- ./node_modules/.bin/tsc --version ; ./node_modules/.bin/tsc -p test

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

notifications:
email:
Expand Down
29 changes: 29 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,34 @@
# CHANGELOG

## v3.3.2 / 2020-06-22

- [#1814] Use a fork of `diagnostics` published to NPM to avoid git dependency.

## v3.3.1 / 2020-06-21

- [#1803], [#1807] Fix TypeScript bugs.
- [#1740] Add space between `info.message` and `meta.message`.
- [#1813] Avoid indirect storage-engine dependency.
- [#1810] README updates.

## 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

Expand Down
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -627,8 +627,8 @@ const myCustomLevels = {
}
};

const customLevelLogger = winston.createLogger({
levels: myCustomLevels.levels
const customLevelLogger = winston.createLogger({
levels: myCustomLevels.levels
});

customLevelLogger.foobar('some foobar level-ed message');
Expand Down Expand Up @@ -1098,11 +1098,6 @@ you should handle or suppress if you don't want unhandled exceptions:
// Handle errors
//
logger.on('error', function (err) { /* Do Something */ });

//
// Or just suppress them.
//
logger.emitErrs = false;
```

### Working with multiple Loggers in winston
Expand Down
58 changes: 30 additions & 28 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ declare namespace winston {

interface Profiler {
logger: Logger;
start: Date;
start: Number;
done(info?: any): boolean;
}

Expand All @@ -58,7 +58,7 @@ declare namespace winston {
[optionName: string]: any;
}

interface LogMethod {
interface LogMethod {
(level: string, message: string, callback: LogCallback): Logger;
(level: string, message: string, meta: any, callback: LogCallback): Logger;
(level: string, message: string, ...meta: any[]): Logger;
Expand All @@ -74,8 +74,8 @@ declare namespace winston {
(infoObject: object): Logger;
}

interface LoggerOptions {
levels?: Config.AbstractConfigSetLevels;
interface LoggerOptions<T extends Config.AbstractConfigSetLevels = Config.AbstractConfigSetLevels> {
levels?: T;
silent?: boolean;
format?: logform.Format;
level?: string;
Expand All @@ -86,10 +86,32 @@ declare namespace winston {
exceptionHandlers?: any;
}

interface Logger extends NodeJSStream.Transform {
type DefaultLevels = {
// for cli and npm levels
error: number;
warn: number;
help: number;
data: number;
info: number;
debug: number;
prompt: number;
http: number;
verbose: number;
input: number;
silly: number;

// for syslog levels only
emerg: number;
alert: number;
crit: number;
warning: number;
notice: number;
}

type Logger<T extends Config.AbstractConfigSetLevels = DefaultLevels> = NodeJSStream.Transform & {
silent: boolean;
format: logform.Format;
levels: Config.AbstractConfigSetLevels;
levels: T;
level: string;
transports: Transport[];
exceptions: ExceptionHandler;
Expand All @@ -103,26 +125,6 @@ declare namespace winston {
clear(): Logger;
close(): Logger;

// for cli and npm levels
error: LeveledLogMethod;
warn: LeveledLogMethod;
help: LeveledLogMethod;
data: LeveledLogMethod;
info: LeveledLogMethod;
debug: LeveledLogMethod;
prompt: LeveledLogMethod;
http: LeveledLogMethod;
verbose: LeveledLogMethod;
input: LeveledLogMethod;
silly: LeveledLogMethod;

// for syslog levels only
emerg: LeveledLogMethod;
alert: LeveledLogMethod;
crit: LeveledLogMethod;
warning: LeveledLogMethod;
notice: LeveledLogMethod;

query(options?: QueryOptions, callback?: (err: Error, results: any) => void): any;
stream(options?: any): NodeJS.ReadableStream;

Expand All @@ -142,7 +144,7 @@ declare namespace winston {
isSillyEnabled(): boolean;

new(options?: LoggerOptions): Logger;
}
} & {[K in keyof T]: LeveledLogMethod;}

interface Container {
loggers: Map<string, Logger>;
Expand All @@ -162,7 +164,7 @@ declare namespace winston {
let loggers: Container;

let addColors: (target: Config.AbstractConfigSetColors) => any;
let createLogger: (options?: LoggerOptions) => Logger;
let createLogger: <T extends Config.AbstractConfigSetLevels = DefaultLevels>(options?: LoggerOptions<T>) => Logger<T>;

// Pass-through npm level methods routed to the default logger.
let error: LeveledLogMethod;
Expand Down
2 changes: 1 addition & 1 deletion lib/winston/create-logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
const { LEVEL } = require('triple-beam');
const config = require('./config');
const Logger = require('./logger');
const debug = require('diagnostics')('winston:create-logger');
const debug = require('@dabh/diagnostics')('winston:create-logger');

function isLevelEnabledFunctionName(level) {
return 'is' + level.charAt(0).toUpperCase() + level.slice(1) + 'Enabled';
Expand Down
2 changes: 1 addition & 1 deletion lib/winston/exception-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

const os = require('os');
const asyncForEach = require('async/forEach');
const debug = require('diagnostics')('winston:exception');
const debug = require('@dabh/diagnostics')('winston:exception');
const once = require('one-time');
const stackTrace = require('stack-trace');
const ExceptionStream = require('./exception-stream');
Expand Down
2 changes: 1 addition & 1 deletion lib/winston/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class Logger extends Transform {
message: msg
});

if (meta.message) info.message += `${meta.message}`;
if (meta.message) info.message = `${info.message} ${meta.message}`;
if (meta.stack) info.stack = meta.stack;

this.write(info);
Expand Down
2 changes: 1 addition & 1 deletion lib/winston/rejection-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

const os = require('os');
const asyncForEach = require('async/forEach');
const debug = require('diagnostics')('winston:rejection');
const debug = require('@dabh/diagnostics')('winston:rejection');
const once = require('one-time');
const stackTrace = require('stack-trace');
const ExceptionStream = require('./exception-stream');
Expand Down
2 changes: 1 addition & 1 deletion lib/winston/transports/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const zlib = require('zlib');
const { MESSAGE } = require('triple-beam');
const { Stream, PassThrough } = require('readable-stream');
const TransportStream = require('winston-transport');
const debug = require('diagnostics')('winston:file');
const debug = require('@dabh/diagnostics')('winston:file');
const os = require('os');
const tailFile = require('../tail-file');

Expand Down
2 changes: 1 addition & 1 deletion lib/winston/transports/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ module.exports = class Http extends TransportStream {
// Prepare options for outgoing HTTP request
const headers = Object.assign({}, this.headers);
if (auth && auth.bearer) {
headers['Authorization'] = `Bearer ${auth.bearer}`;
headers.Authorization = `Bearer ${auth.bearer}`;
}
const req = (this.ssl ? https : http).request({
...this.options,
Expand Down
Loading

0 comments on commit f93ebbb

Please sign in to comment.