Skip to content

Instantly share code, notes, and snippets.

@un4ckn0wl3z
Created August 23, 2023 02:57
Show Gist options
  • Save un4ckn0wl3z/e264290f0181b9264b008a541414d654 to your computer and use it in GitHub Desktop.
Save un4ckn0wl3z/e264290f0181b9264b008a541414d654 to your computer and use it in GitHub Desktop.
import { CustomSingletonLoggerService, DataAlreadyExistsError, LogDto, SingletonFlushSummaryLog, SingletonLoggerHelperService } from "@eqxjs/stub"
import { Injectable } from "@nestjs/common"
// export declare class LogDto {
// appName?: string;
// componentVersion?: string;
// componentName?: string;
// broker?: string;
// channel?: string;
// useCase?: string;
// useCaseStep?: string;
// device?: string | Array<string>;
// public?: string;
// user?: string;
// action?: string;
// message?: string;
// timestamp?: string;
// dependency?: string;
// responseTime?: number;
// resultCode?: string;
// resultFlag?: string;
// instance?: string;
// originateServiceName?: string;
// recordName?: string;
// recordType?: string;
// sessionId?: string;
// transactionId?: string;
// appResult?: string;
// appResultCode?: string;
// dateTime?: string;
// serviceTime?: number;
// constructor(param: any);
// }
@Injectable()
export class ExampleServiceX {
constructor(
private singletonLogger: CustomSingletonLoggerService,
private singletonSummaryFlush: SingletonFlushSummaryLog,
private singletoneLogHelper: SingletonLoggerHelperService
) {
// this.singletoneLogHelper.setNow(Date.now()) // เพื่อเอาไว้คำนวณ service time ตรง summary log
this.singletonLogger.init(new LogDto({})) // for init another log dto field pls check above example
this.singletonLogger.debug('ACTION', 'DATA')
// summary log flushing
// this.singletonSummaryFlush.flush()
// this.singletonSummaryFlush.flushError(new DataAlreadyExistsError("Hacked"))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment