diff --git a/package.json b/package.json index 08ac75e..6ee7883 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-logger", - "version": "2.1.0", + "version": "2.1.1", "scripts": { "build": "gulp build", "build:watch": "gulp", diff --git a/src/index.ts b/src/index.ts index 321421f..4c093de 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,7 +13,6 @@ import {CustomNGXLoggerService} from './custom-logger.service'; export * from './custom-logger.service'; export * from './custom-logger.service.mock'; - import {NGXLoggerHttpService} from './http.service'; export * from './http.service'; export * from './http.service.mock'; diff --git a/src/logger.service.ts b/src/logger.service.ts index 950a555..e2c94de 100644 --- a/src/logger.service.ts +++ b/src/logger.service.ts @@ -102,7 +102,12 @@ export class NGXLogger { return additional.map((next, idx) => { try { - return typeof next === 'object' ? JSON.stringify(next, null, 2) : next; + // We just want to make sure the JSON can be parsed, we do not want to actually change the type + if (typeof next === 'object') { + JSON.stringify(next) + } + + return next; } catch (e) { return `The additional[${idx}] value could not be parsed using JSON.stringify().` @@ -119,14 +124,15 @@ export class NGXLogger { message = this._prepareMessage(message); - additional = this._prepareAdditionalParameters(additional); + // only use validated parameters for HTTP requests + const validatedAdditionalParameters = this._prepareAdditionalParameters(additional); const timestamp = new Date().toISOString(); const config = this.configService.getConfig(); if (logOnServer && config.serverLoggingUrl && level >= config.serverLogLevel) { // Allow logging on server even if client log level is off - this.httpService.logOnServer(config.serverLoggingUrl, message, additional, timestamp, logLevelString).subscribe((res: any) => { + this.httpService.logOnServer(config.serverLoggingUrl, message, validatedAdditionalParameters, timestamp, logLevelString).subscribe((res: any) => { // I don't think we should do anything on success }, (error: HttpErrorResponse) => { diff --git a/src/package.json b/src/package.json index 7f41494..936a759 100644 --- a/src/package.json +++ b/src/package.json @@ -1,6 +1,6 @@ { "name": "ngx-logger", - "version": "2.1.0", + "version": "2.1.1", "repository": { "type": "git", "url": "https://github.com/dbfannin/ngx-logger"