From 64821eb149858b7653eddfda624bd6c4b2956caa Mon Sep 17 00:00:00 2001 From: Federico Pinna Date: Tue, 23 May 2017 09:00:29 +0200 Subject: [PATCH] feat(debug): Now using debuggo module for debug traces --- package.json | 1 + src/api.ts | 2 +- src/debug.ts | 31 ------------------------------- src/index.ts | 1 - 4 files changed, 2 insertions(+), 33 deletions(-) delete mode 100644 src/debug.ts diff --git a/package.json b/package.json index ed24266..d452208 100644 --- a/package.json +++ b/package.json @@ -96,6 +96,7 @@ "body-parser": "^1.17.1", "camelcase": "^4.1.0", "debug": "^2.6.6", + "debuggo": "^1.0.0", "decamelize": "^1.2.0", "eredita": "^1.0.1", "express": "^4.15.2", diff --git a/src/api.ts b/src/api.ts index a261201..f9bf1b1 100644 --- a/src/api.ts +++ b/src/api.ts @@ -8,7 +8,7 @@ import { normalizeUri } from 'jsonref'; import { Schema, DynamicSchema } from 'jsonpolice'; import { Router, RouterOptions, RequestHandler, Request, Response, NextFunction } from 'express'; import { Eredita } from 'eredita'; -import { createLogger, Logger } from './debug'; +import { createLogger, Logger } from 'debuggo'; import { RESTError } from './error'; import { SchemaRegistry } from './schema'; import { Swagger } from './swagger'; diff --git a/src/debug.ts b/src/debug.ts deleted file mode 100644 index 784b4c2..0000000 --- a/src/debug.ts +++ /dev/null @@ -1,31 +0,0 @@ -import * as debug from 'debug'; - -export interface Logger { - log: debug.IDebugger; - info: debug.IDebugger; - warn: debug.IDebugger; - error: debug.IDebugger; - debug: debug.IDebugger; - trace: debug.IDebugger; -} - -export function createLogger(label: string, context?: string): Logger { - let d = context ? function(label:string): debug.IDebugger { - let origDebugger:debug.IDebugger = debug(label); - let wrappedDebugger:debug.IDebugger = function(formatter: string, ...args: any[]) { - origDebugger(`${context} ${formatter}`, ...args); - }; - wrappedDebugger.enabled = origDebugger.enabled; - wrappedDebugger.log = origDebugger.log; - wrappedDebugger.namespace = origDebugger.namespace; - return wrappedDebugger; - } : debug; - return { - log: d(label + ':log'), - info: d(label + ':info'), - warn: d(label + ':warn'), - error: d(label + ':error'), - debug: d(label + ':debug'), - trace: d(label + ':trace') - } -} diff --git a/src/index.ts b/src/index.ts index ec59074..95116b8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,4 @@ export * from './error'; -export * from './debug'; export * from './scopes'; export * from './schema'; export * from './api';