Skip to content

Commit 7e169ec

Browse files
committed
feat(bullmq): allow control over log level
1 parent 85f7530 commit 7e169ec

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

packages/third-parties/bullmq/README.md

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ import "@tsed/bullmq"; // import bullmq ts.ed module
8080
special: {
8181
// Specify additional worker options by queue name
8282
}
83-
}
83+
},
84+
// Specify the log level of the module
85+
logLevel: "info"
8486
}
8587
})
8688
export class Server {}
@@ -255,6 +257,30 @@ class MyService {
255257
}
256258
```
257259

260+
## Logs
261+
262+
Be default the module will log every job's start and completion/failure.
263+
264+
Start and completion is logged on the level of `info`, failure is logged on the level of `error`.
265+
To change/disable this behaviour, pass `logLevel` in the configuration
266+
267+
268+
```ts
269+
270+
@Configuration({
271+
bullmq: {
272+
// ...
273+
logLevel: "off"
274+
// ...
275+
}
276+
})
277+
export class Server {}
278+
279+
```
280+
281+
**Note**: The module logs when job controller is missing as `warn`. This cannot be separetely controlled.
282+
283+
258284
## Contributors
259285

260286
<a href="https://github.com/tsedio/tsed/graphs/contributors"><img src="https://opencollective.com/tsed/contributors.svg?width=890" /></a>

packages/third-parties/bullmq/src/BullMQModule.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export class BullMQModule implements OnInit, OnDestroy {
116116

117117
const $ctx = new DIContext({
118118
id: job.id || v4().split("-").join(""),
119+
level: this.config.logLevel ?? "info",
119120
additionalProps: {
120121
logType: "bullmq",
121122
name: job.name,

packages/third-parties/bullmq/src/config/config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,13 @@ export type BullMQConfig = {
4848
* Specify additional worker options by queue name
4949
*/
5050
workerOptions?: Record<string, Partial<WorkerOptions>>;
51+
52+
/**
53+
* Log level for the module
54+
*
55+
* Default: Info
56+
*/
57+
logLevel?: "debug" | "info" | "warn" | "error" | "off" | "all";
5158
};
5259

5360
declare global {

0 commit comments

Comments
 (0)