Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: inject custom logger in options (#10)
* feat: inject custom logger in options * docs: injecting custom logger * Fix old node support (#11) Signed-off-by: Matteo Collina <hello@matteocollina.com> --------- Signed-off-by: Matteo Collina <hello@matteocollina.com> Co-authored-by: Matteo Collina <hello@matteocollina.com>
- Loading branch information
Showing
6 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict' | ||
|
||
const closeWithGrace = require('..') | ||
|
||
const customLogger = { | ||
error (message) { | ||
console.error(`[custom logger] ${message}`) | ||
} | ||
} | ||
|
||
closeWithGrace({ delay: 500, logger: customLogger }, function ({ signal, err }) { | ||
console.log('fn called') | ||
// this promise never resolves, so the delay should kick in | ||
return new Promise(() => {}) | ||
}) | ||
|
||
// to keep the process open | ||
setInterval(() => {}, 1000) | ||
console.error(process.pid) |