pig-dam-core
Version:
Library that should be included in every Pig DAM project we build
86 lines • 2.81 kB
TypeScript
/**
* Date: 2019-07-12
* Time: 21:26
* @license MIT (see project's LICENSE file)
*
*/
import { LogMessage, Severity, StackDescription } from "../types";
/**
* This is only a base class implementation. The finer details of how logging is implemented will differ per
* platform. The idea is that this class encapsulates the broad strokes. There will be override points and
* they will clearly be labelled. A few notes:
* - when messages are errors we will attempt to extract useful logging information from them such as
* message, stack and metadata
*/
export declare abstract class LogBase {
readonly applicationId: string;
readonly environmentId: string;
readonly sortMetadata: boolean;
readonly threshold: Severity;
constructor({ applicationId, environmentId, sortMetadata, threshold }: {
applicationId: string;
environmentId: string;
sortMetadata?: boolean;
threshold?: Severity;
});
/********************* Public Interface *********************/
debug(message: LogMessage, { metadata, moduleId, stack, traceId }: {
metadata?: {
[index: string]: any;
};
moduleId: string;
stack?: StackDescription;
traceId?: string;
}): void;
error(message: LogMessage, { metadata, moduleId, stack, traceId }: {
metadata?: {
[index: string]: any;
};
moduleId: string;
stack?: StackDescription;
traceId?: string;
}): void;
fatal(message: LogMessage, { metadata, moduleId, stack, traceId }: {
metadata?: {
[index: string]: any;
};
moduleId: string;
stack?: StackDescription;
traceId?: string;
}): void;
info(message: LogMessage, { metadata, moduleId, stack, traceId }: {
metadata?: {
[index: string]: any;
};
moduleId: string;
stack?: StackDescription;
traceId?: string;
}): void;
warn(message: LogMessage, { metadata, moduleId, stack, traceId }: {
metadata?: {
[index: string]: any;
};
moduleId: string;
stack?: StackDescription;
traceId?: string;
}): void;
/**********************
* Protected Interface
*********************/
/**
* This is where the rubber meets the road. Derived classes should hook this guy up
* to wherever the output needs to go.
*/
protected abstract _logEntry(message: string, severity: Severity, metadata: {
[index: string]: any;
}): void;
/*********************
* Private Interface
********************/
/**
* Processes the message and forwards it to `_logEntry`
* @private
*/
private _processEntry;
}
//# sourceMappingURL=base.d.ts.map