Add transactionId to SqlLogger

This commit is contained in:
Jerko Steiner 2019-08-26 19:08:35 +07:00
parent 02d072a361
commit 76bf7d8d47

View File

@ -2,6 +2,7 @@ import {ILogger} from './ILogger'
import {Logger, QueryRunner} from 'typeorm' import {Logger, QueryRunner} from 'typeorm'
import {Namespace} from 'cls-hooked' import {Namespace} from 'cls-hooked'
import {CORRELATION_ID} from '../middleware/Transaction' import {CORRELATION_ID} from '../middleware/Transaction'
import { TRANSACTION_ID } from '../database'
export class SqlLogger implements Logger { export class SqlLogger implements Logger {
constructor( constructor(
@ -80,8 +81,9 @@ export class SqlLogger implements Logger {
} }
protected getCorrelationId(): string | undefined { protected getCorrelationId(): string | undefined {
const correlationId: string = this.ns.get(CORRELATION_ID) const correlationId: string = this.ns.get(CORRELATION_ID) || '-'
return correlationId || '' const transactionId: string = this.ns.get(TRANSACTION_ID) || '-'
return correlationId + ' ' + transactionId
} }
} }