More explicit type definitions
This commit is contained in:
parent
0d369c1995
commit
d25e5f5bd7
7
index.ts
7
index.ts
@ -12,4 +12,9 @@ const addLogLevel = (name: string, level: number) => {
|
||||
LogLevel[LogLevel[name] = level] = name;
|
||||
};
|
||||
|
||||
export { MasterLogger, LoggerClient, Defaults, LogLevel, addLogLevel };
|
||||
export {
|
||||
MasterLogger,
|
||||
LoggerClient, Defaults, LogLevel, addLogLevel,
|
||||
};
|
||||
|
||||
export { LoggerClientOptions, LoggerMasterOptions } from './src/Defaults.js';
|
@ -1,3 +1,5 @@
|
||||
import { WebhookClientOptions } from "@navy.gif/discord-webhook/build/esm/src/types/Webhook";
|
||||
|
||||
enum LogLevel {
|
||||
debug = 0,
|
||||
info = 1,
|
||||
@ -42,6 +44,14 @@ const customTypes: string[] = [];
|
||||
const guard = '_logger';
|
||||
const webhook: { url?: string, id?: string, token?: string } = {};
|
||||
|
||||
type LogLevelType = {
|
||||
debug: LogLevel,
|
||||
info: LogLevel,
|
||||
status: LogLevel,
|
||||
warn: LogLevel,
|
||||
error: LogLevel
|
||||
}
|
||||
|
||||
const logLevelMapping = {
|
||||
debug: LogLevel.debug,
|
||||
info: LogLevel.info,
|
||||
@ -50,14 +60,31 @@ const logLevelMapping = {
|
||||
error: LogLevel.error
|
||||
};
|
||||
|
||||
const SharedOptions = {
|
||||
type SharedOptionsType = {
|
||||
guard: string,
|
||||
customStreams: string[]
|
||||
logLevel: LogLevel,
|
||||
logLevelMapping: LogLevelType
|
||||
}
|
||||
|
||||
const SharedOptions: SharedOptionsType = {
|
||||
guard,
|
||||
customStreams,
|
||||
logLevel: LogLevel.info,
|
||||
logLevelMapping,
|
||||
};
|
||||
|
||||
const MasterOptions = {
|
||||
export type LoggerMasterOptions = SharedOptionsType & {
|
||||
fileRotationFreq: number,
|
||||
directory: string,
|
||||
customTypes: string[],
|
||||
customTypeMapping: { [key: string]: string },
|
||||
customColours: { [key: string]: number | string },
|
||||
broadcastLevel: number,
|
||||
webhook: WebhookClientOptions,
|
||||
}
|
||||
|
||||
const MasterOptions: LoggerMasterOptions = {
|
||||
...SharedOptions,
|
||||
fileRotationFreq: 1,
|
||||
directory: './logs',
|
||||
@ -68,6 +95,8 @@ const MasterOptions = {
|
||||
webhook,
|
||||
};
|
||||
|
||||
export type LoggerClientOptions = SharedOptionsType;
|
||||
|
||||
const ClientOptions = {
|
||||
...SharedOptions
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user