Skip to content

Commit

Permalink
fix: updated get logger function
Browse files Browse the repository at this point in the history
Reviewed-by: @lucacavallaro 
Refs: #34
  • Loading branch information
silvicir authored Nov 6, 2023
1 parent 52ce150 commit 9aaf7af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-jobs-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@pagopa/handler-kit-azure-func": patch
---

Updated getLogger function
12 changes: 3 additions & 9 deletions packages/handler-kit-azure-func/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,9 @@ import * as L from "@pagopa/logger";

// Derive a concrete implementation L.Logger using azure.Context.log
export const getLogger = (ctx: InvocationContext): L.Logger => ({
log: (s, level) => () => {
const logFunc: Record<typeof level, (s: string) => void> = {
debug: ctx.debug,
info: ctx.info,
warn: ctx.warn,
error: ctx.error,
fatal: ctx.error,
};
logFunc[level](s);
log: (s, _level) => () => {
const level = _level === "fatal" ? "error" : _level;
ctx[level](s);
},
format:
process.env.NODE_ENV === "development" ? L.format.simple : L.format.json,
Expand Down

0 comments on commit 9aaf7af

Please sign in to comment.