diff --git a/docs/modules/index.ts.md b/docs/modules/index.ts.md index 58b53ff..5034830 100644 --- a/docs/modules/index.ts.md +++ b/docs/modules/index.ts.md @@ -19,6 +19,7 @@ Added in v0.1.0 - [match](#match) - [instances](#instances) - [EqLogEntry](#eqlogentry) + - [JsonShowLogEntry](#jsonshowlogentry) - [ShowLogEntry](#showlogentry) - [debug](#debug) - [debugP](#debugp) @@ -98,6 +99,16 @@ export declare const EqLogEntry: E.Eq Added in v0.1.2 +## JsonShowLogEntry + +**Signature** + +```ts +export declare const JsonShowLogEntry: S.Show +``` + +Added in v0.2.2 + ## ShowLogEntry **Signature** diff --git a/src/index.ts b/src/index.ts index 573ef56..0516fbb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -135,6 +135,14 @@ export const ShowLogEntry: Show = { }`, } +/** + * @category instances + * @since 0.2.2 + */ +export const JsonShowLogEntry: Show = { + show: safeStringify, +} + /** * Colorizes log entries based on the level. * diff --git a/test/index.test.ts b/test/index.test.ts index 8a13588..ce6a794 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -81,6 +81,19 @@ describe('logger-fp-ts', () => { }) }) + test('JsonShowLogEntry', () => { + fc.assert( + fc.property(fc.logEntry(), logEntry => { + expect(JSON.parse(_.JsonShowLogEntry.show(logEntry))).toStrictEqual({ + date: logEntry.date.toISOString(), + level: logEntry.level, + message: logEntry.message, + payload: logEntry.payload, + }) + }), + ) + }) + describe('getColoredShow', () => { test('with a DEBUG', () => { fc.assert(