Skip to content

Commit

Permalink
fix: Debug function with context and namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jlenon7 committed Nov 3, 2021
1 parent ef88389 commit 0ea1bac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@secjs/logger",
"version": "1.1.8",
"version": "1.1.9",
"description": "",
"scripts": {
"build": "tsc",
Expand Down
15 changes: 11 additions & 4 deletions src/utils/global.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ import { DebugTransporter } from '../Transporters/DebugTransporter'
export {}

declare global {
function Debug(message: any, namespace?: string, context?: string): void
function Log(message: any, formatterOpts?: any, transporterOpts?: any): void
function Debug(message: any, formatterOpts?: any, transporterOpts?: any): void
}

const _global = global as any

_global.Log = Log
_global.Debug = new Logger().debug.bind({
const debug = new Logger().debug.bind({
context: 'Debugger',
mapper: new LogMapper([new DebugFormatter()], [new DebugTransporter()]),
})

_global.Log = Log
_global.Debug = (
message: any,
namespace = 'api:main',
context = 'Debug',
): void => {
debug(message, { context }, { namespace })
}

0 comments on commit 0ea1bac

Please sign in to comment.