Skip to content

Commit

Permalink
fix(module): add requestId check to printMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
jjsinch authored and jmcdo29 committed Sep 4, 2020
1 parent ee60e6a commit 97bcda7
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/nestjs-module/src/ogma.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export class OgmaService implements LoggerService {
* use Ogma to log at the ERROR level
* @param message What to print to the Ogma instance
* @param context Optional context if you want to change what the original context was
* @param requestId Optional id of an request
*/
public error(message: any, context?: string): void {
this.printMessage(message, 'error', context);
Expand Down Expand Up @@ -118,7 +117,7 @@ export class OgmaService implements LoggerService {
*/
public printError(error: Error, context?: string, requestId?: string): void {
this.printMessage('', 'error', context, requestId);
if (this.requestContext && this.context) {
if (!requestId && this.requestContext && this.context) {
requestId = this.getRequestId(this.requestContext);
}
context = context ?? this.context;
Expand All @@ -132,7 +131,7 @@ export class OgmaService implements LoggerService {
requestId?: string,
): void {
context = context ?? this.context;
if (this.requestContext && this.context) {
if (!requestId && this.requestContext && this.context) {
requestId = this.getRequestId(this.requestContext);
}
this.ogma[levelString](message, context, undefined, requestId);
Expand Down

0 comments on commit 97bcda7

Please sign in to comment.