Skip to content

Commit

Permalink
feat: add formatter option to runtimeConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed Mar 29, 2022
1 parent 2eb020b commit 7647ef2
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/logger",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"license": "MIT",
"author": "João Lenon <lenon@athenna.io>",
Expand Down
42 changes: 42 additions & 0 deletions src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ export class Logger {
async log(message: any, options?: any) {
options = Object.assign({}, { context: 'Logger' }, options)

if (this.runtimeConfig && this.runtimeConfig.formatter) {
options = {
...options,
...this.runtimeConfig.formatter,
}
}

await this.driver.transport(message, options)
}

Expand All @@ -58,6 +65,13 @@ export class Logger {
options.color = Color.cyan
options.streamType = 'stdout'

if (this.runtimeConfig && this.runtimeConfig.formatter) {
options = {
...options,
...this.runtimeConfig.formatter,
}
}

await this.driver.transport(message, options)
}

Expand All @@ -68,6 +82,13 @@ export class Logger {
options.color = Color.orange
options.streamType = 'stdout'

if (this.runtimeConfig && this.runtimeConfig.formatter) {
options = {
...options,
...this.runtimeConfig.formatter,
}
}

await this.driver.transport(message, options)
}

Expand All @@ -78,6 +99,13 @@ export class Logger {
options.color = Color.red
options.streamType = 'stderr'

if (this.runtimeConfig && this.runtimeConfig.formatter) {
options = {
...options,
...this.runtimeConfig.formatter,
}
}

await this.driver.transport(message, options)
}

Expand All @@ -88,6 +116,13 @@ export class Logger {
options.color = Color.purple
options.streamType = 'stdout'

if (this.runtimeConfig && this.runtimeConfig.formatter) {
options = {
...options,
...this.runtimeConfig.formatter,
}
}

await this.driver.transport(message, options)
}

Expand All @@ -98,6 +133,13 @@ export class Logger {
options.color = Color.green
options.streamType = 'stdout'

if (this.runtimeConfig && this.runtimeConfig.formatter) {
options = {
...options,
...this.runtimeConfig.formatter,
}
}

await this.driver.transport(message, options)
}
}

0 comments on commit 7647ef2

Please sign in to comment.