Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 413af6e

Browse files
author
Michal Vlasák
committed
🏷 Use pino-multi-stream type
1 parent b7dae6e commit 413af6e

3 files changed

Lines changed: 6 additions & 5 deletions

File tree

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import * as serializers from './serializers';
1313
import { initLoggerStreams } from './streams';
1414

1515
export type PinoLogger = pino.BaseLogger;
16-
export type Level = pino.LevelWithSilent;
16+
export type Level = pinoms.Level;
1717
export type PinoHooks = { logMethod: (inputArgs: any, method: any) => void };
1818

1919
export interface Cosmas extends PinoLogger {

src/interfaces.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
import { Request, Response } from 'express';
22
import * as pino from 'pino';
3+
import * as pinoms from 'pino-multi-stream';
34

45
interface LoggerOptions extends pino.LoggerOptions {
56
streams?: Array<{ stream: NodeJS.WritableStream; level?: pino.Level }>;
67
}
78

89
// this is basically enhanced version of pino-multi-stream.Streams type
910
export interface CosmasStream {
10-
level?: pino.LevelWithSilent;
11+
level?: pinoms.Level;
1112
maxLevel?: number; // this is not processed by pino, so we need the number directly
1213
stream: NodeJS.WritableStream;
1314
}
1415

1516
export interface CosmasOptions {
1617
disableFields?: string[];
1718
enableFields?: string[];
18-
defaultLevel?: pino.LevelWithSilent;
19+
defaultLevel?: pinoms.Level;
1920
disableStackdriverFormat?: boolean;
2021
streams?: CosmasStream[];
2122
formatters?: pino.LoggerOptions['formatters'];

src/streams.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as pino from 'pino';
1+
import * as pinoms from 'pino-multi-stream';
22
import { Transform, TransformCallback } from 'stream';
33
import * as util from 'util';
44
import { CosmasOptions, CosmasStream } from './interfaces';
@@ -37,7 +37,7 @@ const decorateStreams = <T extends Transform>(streams: CosmasStream[], streamCla
3737
};
3838

3939
const initLoggerStreams = (
40-
defaultLevel: pino.LevelWithSilent,
40+
defaultLevel: pinoms.Level,
4141
options: CosmasOptions & { messageKey: string; loggerName?: string }
4242
) => {
4343
let streams: CosmasStream[];

0 commit comments

Comments
 (0)