Skip to content

Commit

Permalink
fix: declare logger
Browse files Browse the repository at this point in the history
  • Loading branch information
izatop committed Aug 29, 2022
1 parent 96e91d2 commit af844b5
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 24 deletions.
4 changes: 2 additions & 2 deletions packages/app/src/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import {
Unit,
unit,
} from "@bunt/unit";
import {assert, isDefined, Logger} from "@bunt/util";
import {assert, isDefined, logger, Logger} from "@bunt/util";
import {ActionResponse, IRequest} from "./interfaces";
import {IRoute, RouteNotFound} from "./Route";

export class Application<C extends Context> {
@logger
protected logger!: Logger;
declare protected readonly logger: Logger;

readonly #unit: Unit<C>;
readonly #routes = new Set<IRoute<ActionAny<C>>>();
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/Action/Command.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {Action, IRunnable, StateType} from "@bunt/unit";
import {Argv, Logger, Program} from "@bunt/util";
import {Argv, logger, Logger, Program} from "@bunt/util";
import {CommandContext} from "../Context/CommandContext";

export abstract class Command<C extends CommandContext,
S extends StateType | null = null> extends Action<C, S, IRunnable | void> {

@logger
protected logger!: Logger;
declare protected readonly logger: Logger;

readonly #queue = new Set<Promise<unknown>>();

Expand Down
4 changes: 2 additions & 2 deletions packages/queue/src/Dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import {
Unit,
unit,
} from "@bunt/unit";
import {Ctor, Defer, Logger} from "@bunt/util";
import {Ctor, Defer, logger, Logger} from "@bunt/util";
import {Handler} from "./Handler";
import {ITransport} from "./interfaces";
import {Incoming, MessageCtor, Queue, QueueAbstract} from "./Queue";

export class Dispatcher<C extends Context> extends Disposer implements IRunnable {
@logger
public logger!: Logger;
declare public readonly logger: Logger;

readonly #unit: Unit<C>;
readonly #queue: QueueAbstract<ITransport>;
Expand Down
4 changes: 2 additions & 2 deletions packages/queue/src/PubSub/SubscriptionManager.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import {IDisposable} from "@bunt/unit";
import {assert, Defer, Logger} from "@bunt/util";
import {assert, Defer, logger, Logger} from "@bunt/util";
import {SubscriptionId, SubscriptionListenerId, SubscriptionManagerListener} from "./interfaces";
import {SubscriptionList} from "./SubscriptionList";

export type SubscriptionManagerConfig = [list: SubscriptionList, state: Defer<void>];

export abstract class SubscriptionManager implements IDisposable {
@logger
readonly logger!: Logger;
declare protected readonly logger: Logger;

readonly #subscriptions = new Map<string, SubscriptionManagerConfig>();

Expand Down
4 changes: 2 additions & 2 deletions packages/unit/src/Dispose/Disposer.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {Logger, safeMap} from "@bunt/util";
import {logger, Logger, safeMap} from "@bunt/util";
import {DisposableType, IDisposable} from "../Runtime";
import {dispose} from "./functions";

export abstract class Disposer implements IDisposable {
@logger
protected readonly logger!: Logger;
declare protected readonly logger: Logger;

readonly #disposables: DisposableType[] = [];

Expand Down
4 changes: 2 additions & 2 deletions packages/unit/src/Runtime/Heartbeat.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Defer, Logger} from "@bunt/util";
import {Defer, logger, Logger} from "@bunt/util";
import {Disposer} from "../Dispose";
import {IRunnable} from "./interfaces";
import {isRunnable} from "./internal";
Expand All @@ -10,7 +10,7 @@ export class Heartbeat extends Disposer {
public readonly name: string;

@logger
protected readonly logger!: Logger;
declare protected readonly logger: Logger;

readonly #running = new Set<HeartbeatRunningQueue>();
readonly #life = new Defer<void>();
Expand Down
4 changes: 2 additions & 2 deletions packages/unit/src/Runtime/Runtime.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Defer, isNull, isUndefined, LogFn, Logger, SingleRef, toError} from "@bunt/util";
import {Defer, isNull, isUndefined, LogFn, logger, Logger, SingleRef, toError} from "@bunt/util";
import {Disposer, dispose} from "../Dispose";
import {Heartbeat} from "./Heartbeat";
import {RuntimeTask} from "./interfaces";
Expand All @@ -11,7 +11,7 @@ const ENV = process.env.NODE_ENV || "production";

export class Runtime extends Disposer {
@logger
public readonly logger!: Logger;
declare protected readonly logger: Logger;

readonly #running: Heartbeat[] = [];
readonly #pending: Promise<unknown>[] = [];
Expand Down
4 changes: 2 additions & 2 deletions packages/unit/src/Unit.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {assert, isFunction, isInstanceOf, Logger, toError} from "@bunt/util";
import {assert, isFunction, isInstanceOf, logger, Logger, toError} from "@bunt/util";
import {ApplyContext, Context} from "./Context";
import {Action} from "./Action";
import {
Expand All @@ -14,7 +14,7 @@ import {

export class Unit<C extends Context> {
@logger
protected readonly logger!: Logger;
declare protected readonly logger: Logger;

readonly #context: ApplyContext<C>;
readonly #handlers: ActionTransactionHandlers<C> = {};
Expand Down
1 change: 1 addition & 0 deletions packages/util/src/Async/AsyncCallback.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {bind} from "../decorator";
import {Promisify, Fn} from "../interfaces";
import {isUndefined} from "../is";

Expand Down
4 changes: 2 additions & 2 deletions packages/util/test/src/logger/src/LoggableObjectTest.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {ILogable, ILogger, LogableType, Logger} from "../../../../src";
import {ILogable, ILogger, LogableType, logger, Logger} from "../../../../src";

export class LoggableObjectTest<T extends LogableType> implements ILogger, ILogable<T> {
@logger
public logger!: Logger;
declare public readonly logger: Logger;

protected value: T;

Expand Down
3 changes: 2 additions & 1 deletion packages/web/src/WebServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ import {
NotFound,
ValidationError,
Defer,
logger,
} from "@bunt/util";
import {IErrorResponseHeaders, IProtocolAcceptor, IResponderOptions, Responder} from "./Transport";

export class WebServer<C extends Context> extends Application<C> implements IDisposable, IRunnable {
@logger
public readonly logger!: Logger;
declare protected readonly logger: Logger;

readonly #server: http.Server;
readonly #state = new Defer<void>();
Expand Down
6 changes: 3 additions & 3 deletions packages/ws/src/Protocol/ProtoHandleAbstract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Action, Context, IShadowState, ShadowState, StateType} from "@bunt/unit";
import {assert, Logger} from "@bunt/util";
import {assert, logger, Logger} from "@bunt/util";
import ws from "ws";

export abstract class ProtoHandleAbstract<C extends Context, S extends StateType = null>
Expand All @@ -14,7 +14,7 @@ export abstract class ProtoHandleAbstract<C extends Context, S extends StateType
protected static protocol: string;

@logger
protected logger!: Logger;
declare protected readonly logger: Logger;

public static isSupported(protocol: string): boolean {
return this.protocol.toLowerCase() === protocol.toLowerCase();
Expand All @@ -23,7 +23,7 @@ export abstract class ProtoHandleAbstract<C extends Context, S extends StateType
public getShadowState(): ws {
const shadowState = ShadowState.get<ws>(this.state);
assert(shadowState, "Shadow state should be defined");

return shadowState;
}
}
4 changes: 2 additions & 2 deletions packages/ws/src/WebSocketServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ import {
unit,
Unit,
} from "@bunt/unit";
import {assert, Defer, isDefined, isString, Logger, noop, resolveOrReject, toError} from "@bunt/util";
import {assert, Defer, isDefined, isString, logger, Logger, noop, resolveOrReject, toError} from "@bunt/util";
import {RequestMessage, WebServer} from "@bunt/web";
import * as ws from "ws";
import {WebSocketCloseReason} from "./const";
import {HandleProtoType, ProtoHandleAbstract} from "./Protocol";

export class WebSocketServer<C extends Context> extends Disposer implements IRunnable {
@logger
public readonly logger!: Logger;
declare protected readonly logger: Logger;

readonly #disposeAcceptor: () => void;
readonly #servers = new Map<IRoute<ActionAny<C>>, ws.Server>();
Expand Down

0 comments on commit af844b5

Please sign in to comment.