Skip to content

Commit 25aa143

Browse files
committed
feat(slack): adjust slack logger to receive blocks
1 parent 83ac853 commit 25aa143

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@athenna/logger",
3-
"version": "5.11.0",
3+
"version": "5.12.0",
44
"description": "The Athenna logging solution. Log in stdout, files and buckets.",
55
"license": "MIT",
66
"author": "João Lenon <lenon@athenna.io>",

src/drivers/SlackDriver.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
* file that was distributed with this source code.
88
*/
99

10-
import { Driver } from '#src/drivers/Driver'
11-
import { HttpClient } from '@athenna/common'
1210
import { debug } from '#src/debug'
11+
import { Driver } from '#src/drivers/Driver'
12+
import { HttpClient, Is } from '@athenna/common'
1313

1414
export class SlackDriver extends Driver {
1515
public async transport(level: string, message: any): Promise<any> {
@@ -25,10 +25,14 @@ export class SlackDriver extends Driver {
2525
this.configs.url
2626
)
2727

28+
if (Is.Object(formatted) && formatted.text && formatted.blocks) {
29+
return HttpClient.builder(true).post(this.configs.url, {
30+
body: { text: formatted.text, blocks: formatted.blocks }
31+
})
32+
}
33+
2834
return HttpClient.builder(true).post(this.configs.url, {
29-
body: {
30-
text: formatted
31-
}
35+
body: { text: formatted }
3236
})
3337
}
3438
}

0 commit comments

Comments
 (0)