diff --git a/src/EndlessFileParser.ts b/src/EndlessFileParser.ts index d0c2f22..ceecb69 100644 --- a/src/EndlessFileParser.ts +++ b/src/EndlessFileParser.ts @@ -6,8 +6,7 @@ import {parseEndlessLogLine} from "./utils/index.js"; import path from "path"; import {EndlessLogLine} from "./common/infrastructure/Atomic.js"; import {TypedEventEmitter} from "./utils/TypedEventEmitter.js"; -import {AppLogger} from "./common/logging.js"; -import { childLogger } from "@foxxmd/logging"; +import {childLogger, Logger} from "@foxxmd/logging"; const endlessFileNames = ['current', 'endlessh.INFO']; @@ -19,9 +18,9 @@ type EndlessFileEventTypes = { export class EndlessFileParser extends TypedEventEmitter { tailFile: TailFile; - logger: AppLogger; + logger: Logger; - constructor(file: TailFile, logger: AppLogger) { + constructor(file: TailFile, logger: Logger) { super(); this.tailFile = file; this.logger = childLogger(logger, 'Parser'); //logger.child({labels: ['Parser']}, mergeArr); @@ -72,7 +71,7 @@ export class EndlessFileParser extends TypedEventEmitter } } - public static async fromFile(dir: string, logger: AppLogger) { + public static async fromFile(dir: string, logger: Logger) { const cl = childLogger(logger, 'Parser'); // logger.child({labels: ['Parser']}, mergeArr); for(const name of endlessFileNames) { const filePath = path.resolve(dir, `./${name}`); diff --git a/src/GeoLookup.ts b/src/GeoLookup.ts index ef8f128..2af7460 100644 --- a/src/GeoLookup.ts +++ b/src/GeoLookup.ts @@ -3,14 +3,13 @@ import {IPDataFields} from "./common/infrastructure/Atomic.js"; import {Address4, Address6} from "ip-address"; import {defaultApiApiQuery, getIpGeolocation, IPDataResponse} from "./ipApi.js"; import {ErrorWithCause} from "pony-cause"; -import {AppLogger} from "./common/logging.js"; -import { childLogger } from "@foxxmd/logging"; +import {childLogger, Logger} from "@foxxmd/logging"; export class GeoLookup { cache: LRUCache = new LRUCache({max: 500}) - logger: AppLogger + logger: Logger - constructor(logger: AppLogger) { + constructor(logger: Logger) { this.logger = childLogger(logger, 'Geo Lookup'); // logger.child({labels: ['Geo Lookup']}, mergeArr) } diff --git a/src/GeoQueue.ts b/src/GeoQueue.ts index 8129409..a0d20ae 100644 --- a/src/GeoQueue.ts +++ b/src/GeoQueue.ts @@ -1,16 +1,9 @@ -import { - EndlessGeoLog, - EndlessLog, - EndlessLogLine, - EndlessStatLog, - IPDataFields -} from "./common/infrastructure/Atomic.js"; +import {EndlessLog, EndlessStatLog, IPDataFields} from "./common/infrastructure/Atomic.js"; import {TypedEventEmitter} from "./utils/TypedEventEmitter.js"; import {sleep} from "./utils/index.js"; import {queue, QueueObject} from 'async'; import {GeoLookup} from "./GeoLookup.js"; -import {AppLogger} from "./common/logging.js"; -import { childLogger } from "@foxxmd/logging"; +import {childLogger, Logger} from "@foxxmd/logging"; type GeoHydratedLogLineEvents = { 'log': [log: EndlessLog] @@ -22,11 +15,11 @@ interface GeoTask { export class GeoQueue extends TypedEventEmitter { - logger: AppLogger; + logger: Logger; queue: QueueObject lookup: GeoLookup; - constructor(logger: AppLogger) { + constructor(logger: Logger) { super(); this.logger = childLogger(logger, 'Geo Queue');// logger.child({labels: ['Geo Queue']}, mergeArr); this.lookup = new GeoLookup(this.logger); diff --git a/src/MapImageService.ts b/src/MapImageService.ts index 9cfa6b8..bbac8fd 100644 --- a/src/MapImageService.ts +++ b/src/MapImageService.ts @@ -1,16 +1,15 @@ import {LRUCache} from "lru-cache"; import {ErrorWithCause} from "pony-cause"; import got from 'got'; -import {AppLogger} from "./common/logging.js"; -import { childLogger } from "@foxxmd/logging"; +import {childLogger, Logger} from "@foxxmd/logging"; export class MapImageService { mapquestKey?: string; imageCache: LRUCache = new LRUCache({max: 100}); - logger: AppLogger; + logger: Logger; - constructor(logger: AppLogger, mapquestKey?: string) { + constructor(logger: Logger, mapquestKey?: string) { this.logger = childLogger(logger, 'Map Image'); // logger.child({labels: ['Map Image']}, mergeArr); this.mapquestKey = mapquestKey; if (this.mapquestKey !== undefined) { diff --git a/src/common/logging.ts b/src/common/logging.ts deleted file mode 100644 index e9c0ab5..0000000 --- a/src/common/logging.ts +++ /dev/null @@ -1,3 +0,0 @@ -import {Logger } from "@foxxmd/logging"; - -export type AppLogger = Logger diff --git a/src/notifier/AbstractWebhookNotifier.ts b/src/notifier/AbstractWebhookNotifier.ts index 1e66b3b..2441b71 100644 --- a/src/notifier/AbstractWebhookNotifier.ts +++ b/src/notifier/AbstractWebhookNotifier.ts @@ -11,13 +11,12 @@ import {ErrorWithCause} from "pony-cause"; import TTLCache from '@isaacs/ttlcache'; import dayjs, {Dayjs} from "dayjs"; import {EndlessCloseLogLine} from "../common/infrastructure/Atomic.js"; -import {AppLogger} from "../common/logging.js"; -import { childLogger } from "@foxxmd/logging"; +import {childLogger, Logger} from "@foxxmd/logging"; interface HydratedEventTypeCommon extends Omit { debounceInterval: Duration cache: TTLCache - logger: AppLogger + logger: Logger } type HydratedEventTypeAccept = Omit & HydratedEventTypeCommon @@ -32,7 +31,7 @@ type HydratedEventTypeClose = HydratedEventTypeCommon & Omit; - constructor(logger: AppLogger, mapquestKey?: string) { + constructor(logger: Logger, mapquestKey?: string) { this.logger = childLogger(logger, 'Notifiers'); // logger.child({labels: ['Notifiers']}, mergeArr); this.queue = this.generateQueue(); diff --git a/src/notifier/NtfyWebhookNotifier.ts b/src/notifier/NtfyWebhookNotifier.ts index 027fbe3..fd38885 100644 --- a/src/notifier/NtfyWebhookNotifier.ts +++ b/src/notifier/NtfyWebhookNotifier.ts @@ -1,9 +1,9 @@ -import { AbstractWebhookNotifier } from "./AbstractWebhookNotifier.js"; +import {AbstractWebhookNotifier} from "./AbstractWebhookNotifier.js"; import {Config, publish} from 'ntfy'; import got from 'got'; import {NtfyConfig, PrioritiesConfig, WebhookPayload} from "../common/infrastructure/webhooks.js"; import {durationToHuman} from "../utils/index.js"; -import {AppLogger} from "../common/logging.js"; +import {Logger} from "@foxxmd/logging"; export class NtfyWebhookNotifier extends AbstractWebhookNotifier { @@ -11,7 +11,7 @@ export class NtfyWebhookNotifier extends AbstractWebhookNotifier { priorities: PrioritiesConfig; - constructor(defaultName: string, config: NtfyConfig, logger: AppLogger) { + constructor(defaultName: string, config: NtfyConfig, logger: Logger) { super('Ntfy', defaultName, config, logger); const { info = 3, diff --git a/src/utils/index.ts b/src/utils/index.ts index 1d4c4f8..7a61a22 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,12 +1,5 @@ import dayjs, {Dayjs} from "dayjs"; -import {AppLogger} from "../common/logging.js"; -import { - replaceResultTransformer, - stripIndentTransformer, - TemplateTag, - TemplateTransformer, - trimResultTransformer -} from 'common-tags' +import {replaceResultTransformer, stripIndentTransformer, TemplateTag, trimResultTransformer} from 'common-tags' import { EndlessLog, EndlessLogLine, @@ -19,6 +12,7 @@ import {Duration} from "dayjs/plugin/duration.js"; import {ErrorWithCause, getErrorCause} from "pony-cause"; import InvalidRegexError from "../common/errors/InvalidRegexError.js"; import {Address4, Address6} from "ip-address"; +import {Logger} from "@foxxmd/logging"; export const overwriteMerge = (destinationArray: any[], sourceArray: any[], options: any): any[] => sourceArray; @@ -98,9 +92,9 @@ export class RateLimitFunc { public lastExecute?: Dayjs; public msBetween: number; protected shouldWait: boolean; - protected logger?: AppLogger; + protected logger?: Logger; - constructor(msBetween: number, shouldWait: boolean, logger?: AppLogger) { + constructor(msBetween: number, shouldWait: boolean, logger?: Logger) { this.msBetween = msBetween; this.lastExecute = dayjs().subtract(msBetween + 1, 'ms'); this.logger = logger;