Skip to content

logger: refactor with configurable implemention #204

@myfreeer

Description

@myfreeer

Currently we use log4js as the logger, but users may want to use other logging framework or implement logger themselves.

  • Loggers are initialized in the init life cycle of the main thread.
  • Logger should be returned by a function as implemention of interfaces.
  • Messages of the worker threads are sent to the main thread and logged by the worker of main thread.
  • Logger initializer should only be invoked in the main thread.
  • The dependency of log4js should probably removed with adapters, a default console-based implemention should be provided instead.
  • This change should be considered breaking.
export interface Logger {
    trace(type: LogType, ...contents: unknown[]): void;
    debug(type: LogType, ...contents: unknown[]): void;
    info(type: LogType, ...contents: unknown[]): void;
    warn(type: LogType, ...contents: unknown[]): void;
    error(type: LogType, ...contents: unknown[]): void;
}

LogType may include:

  • io
    • http
      • request
      • response
      • notFound
      • retry
    • disk
      • mkdir
  • system
    • skip
    • skipExternal
    • complete
    • adjustConcurrency
  • custom

Metadata

Metadata

Assignees

No one assigned

    Labels

    BREAKINGissues that can cause breaking changesenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions