Skip to content

Commit

Permalink
deprecation(log): string type for BaseHandler.formatter (#4023)
Browse files Browse the repository at this point in the history
Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
  • Loading branch information
timreichen and iuioiua authored Dec 30, 2023
1 parent 27c3c02 commit c3da971
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions log/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ export interface HandlerOptions {
export class BaseHandler {
level: number;
levelName: LevelName;
/**
* @deprecated (will be removed in 0.213.0) Use {@linkcode FormatterFunction} instead of a string.
*/
formatter: string | FormatterFunction;

constructor(levelName: LevelName, options: HandlerOptions = {}) {
Expand Down
6 changes: 3 additions & 3 deletions log/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
* file: new log.handlers.FileHandler("WARNING", {
* filename: "./log.txt",
* // you can change format of output message using any keys in `LogRecord`.
* formatter: "{levelName} {msg}",
* formatter: (record) => `${record.levelName} ${record.msg}`,
* }),
* },
*
Expand Down Expand Up @@ -196,7 +196,7 @@
* log.setup({
* handlers: {
* stringFmt: new log.handlers.ConsoleHandler("DEBUG", {
* formatter: "[{levelName}] {msg}",
* formatter: (record) => `[${record.levelName}] ${record.msg}`,
* }),
*
* functionFmt: new log.handlers.ConsoleHandler("DEBUG", {
Expand All @@ -212,7 +212,7 @@
* }),
*
* anotherFmt: new log.handlers.ConsoleHandler("DEBUG", {
* formatter: "[{loggerName}] - {levelName} {msg}",
* formatter: (record) => `[${record.loggerName}] - ${record.levelName} ${record.msg}`,
* }),
* },
*
Expand Down

0 comments on commit c3da971

Please sign in to comment.