From 582864a8f4cdd9bc0620568cad0a5d4114928726 Mon Sep 17 00:00:00 2001 From: Jay McDoniel Date: Sun, 9 May 2021 21:30:35 -0700 Subject: [PATCH] docs(common): add doc strings for common package --- commitlint.config.js | 1 + packages/common/src/stream.interface.ts | 11 +++++++++++ packages/logger/src/logger/ogma.ts | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/commitlint.config.js b/commitlint.config.js index 19c4be061..2a8274128 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -48,6 +48,7 @@ module.exports = { 'benchmarks', 'cli', 'styler', + 'common', ], ], }, diff --git a/packages/common/src/stream.interface.ts b/packages/common/src/stream.interface.ts index b14ca5ea3..5a56085dc 100644 --- a/packages/common/src/stream.interface.ts +++ b/packages/common/src/stream.interface.ts @@ -1,4 +1,15 @@ +/** + * A simple type to allow for easy use of the `ogma` library on front and backend + * abstracted away from the NodeJS `WritableStream`, though inspiration was drawn from it + */ export interface OgmaStream { + /** + * The method for actually writing the log. This is made to be as open ended as possible for great extensibility. + */ write: (message: unknown) => unknown; + /** + * A utility method to determine if color can be used. This should usually return a 1, 4, 8, or 24. + * @see https://nodejs.org/dist/latest-v14.x/docs/api/tty.html#tty_writestream_getcolordepth_env + */ getColorDepth?: () => number; } diff --git a/packages/logger/src/logger/ogma.ts b/packages/logger/src/logger/ogma.ts index 6c98364ad..521fe1ced 100644 --- a/packages/logger/src/logger/ogma.ts +++ b/packages/logger/src/logger/ogma.ts @@ -245,7 +245,7 @@ export class Ogma { public fatal(message: any, meta?: OgmaPrintOptions): void { this.printMessage(message, { level: LogLevel.FATAL, - formattedLevel: style.redBg.white.underline.apply( + formattedLevel: this.style.redBg.white.underline.apply( this.wrapInBrackets(LogLevel[LogLevel.FATAL]), ), ...meta,