From 22de4f46597f9ef2ff072cc045562d75329510f5 Mon Sep 17 00:00:00 2001 From: Sander Bouwhuis Date: Wed, 15 Jan 2020 21:41:09 +0100 Subject: [PATCH] Add missing time functions from http://getpino.io/#/docs/api?id=pinostdtimefunctions-object (#41618) --- types/pino/index.d.ts | 26 +++++++++++++++++--------- types/pino/pino-tests.ts | 4 ++++ 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/types/pino/index.d.ts b/types/pino/index.d.ts index 82109ac986..678c1fd0c3 100644 --- a/types/pino/index.d.ts +++ b/types/pino/index.d.ts @@ -126,10 +126,18 @@ declare namespace P { * The default time function for Pino. Returns a string like `,"time":1493426328206`. */ epochTime: TimeFn; + /* + * Returns the seconds since Unix epoch + */ + unixTime: TimeFn; /** * Returns an empty string. This function is used when the `timestamp` option is set to `false`. */ nullTime: TimeFn; + /* + * Returns ISO 8601-formatted time in UTC + */ + isoTime: TimeFn; }; /** @@ -319,13 +327,13 @@ declare namespace P { write?: | WriteFn | ({ - fatal?: WriteFn; - error?: WriteFn; - warn?: WriteFn; - info?: WriteFn; - debug?: WriteFn; - trace?: WriteFn; - } & { [logLevel: string]: WriteFn }); + fatal?: WriteFn; + error?: WriteFn; + warn?: WriteFn; + info?: WriteFn; + debug?: WriteFn; + trace?: WriteFn; + } & { [logLevel: string]: WriteFn }); /** * The serializers provided to `pino` are ignored by default in the browser, including the standard @@ -414,14 +422,14 @@ declare namespace P { * the `send` function will be called based on the main logging `level` (set via `options.level`, * defaulting to `info`). */ - level?: Level|string; + level?: Level | string; /** * Remotely record log messages. * * @description Called after writing the log message. */ send: (level: Level, logEvent: LogEvent) => void; - } + }; }; /** * key-value object added as child logger to each log line. If set to null the base child logger is not added diff --git a/types/pino/pino-tests.ts b/types/pino/pino-tests.ts index f6e5ddb5c8..1508a3ffca 100644 --- a/types/pino/pino-tests.ts +++ b/types/pino/pino-tests.ts @@ -173,6 +173,10 @@ const pretty = pino({ } }); +const withTimeFn = pino({ + timestamp: pino.stdTimeFunctions.isoTime, +}); + // Properties/types imported from pino-std-serializers const wrappedErrSerializer = pino.stdSerializers.wrapErrorSerializer((err: pino.SerializedError) => { return {...err, newProp: 'foo'};