Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add types for ConsoleLogger #101

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/core/LightLogger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* Many libraries use a logger interface to log information about the processing.
* This logger is expected to be compatible not only with the one from the `pino` library but
* also with the default `console`.
* This means that the library can output logs by default to the console and the user can
* replace it with a custom logger that implements this interface.
*/
export interface LightLogger {
trace(obj: Record<string, unknown>, message: string): void;
trace(message: string): void;
trace(error: Error): void;
trace(value: unknown, message?: string): void;

debug(obj: Record<string, unknown>, message: string): void;
debug(message: string): void;
debug(error: Error): void;
debug(value: unknown, message?: string): void;

info(obj: Record<string, unknown>, message: string): void;
info(message: string): void;
info(error: Error): void;
info(value: unknown, message?: string): void;

warn(obj: Record<string, unknown>, message: string): void;
warn(message: string): void;
warn(error: Error): void;
warn(value: unknown, message?: string): void;

error(obj: Record<string, unknown>, message: string): void;
error(message: string): void;
error(error: Error): void;
error(value: unknown, message?: string): void;
}
32 changes: 4 additions & 28 deletions src/core/Logger.d.ts
Original file line number Diff line number Diff line change
@@ -1,36 +1,12 @@
import { LightLogger } from './LightLogger';

/**
* Many libraries use a logger interface to log information about the processing
* Many libraries use a logger interface to log information about the processing.
* This logger is expected to be compatible with the one from the `pino` library
*/

export interface Logger {
export interface Logger extends LightLogger {
child(bindings?: Record<string, any>): Logger;

Check warning on line 8 in src/core/Logger.d.ts

View workflow job for this annotation

GitHub Actions / nodejs / lint-eslint

Unexpected any. Specify a different type

trace(obj: Record<string, unknown>, message: string): void;
trace(message: string): void;
trace(error: Error): void;
trace(value: unknown, message?: string): void;

debug(obj: Record<string, unknown>, message: string): void;
debug(message: string): void;
debug(error: Error): void;
debug(value: unknown, message?: string): void;

info(obj: Record<string, unknown>, message: string): void;
info(message: string): void;
info(error: Error): void;
info(value: unknown, message?: string): void;

warn(obj: Record<string, unknown>, message: string): void;
warn(message: string): void;
warn(error: Error): void;
warn(value: unknown, message?: string): void;

error(obj: Record<string, unknown>, message: string): void;
error(message: string): void;
error(error: Error): void;
error(value: unknown, message?: string): void;

fatal(obj: Record<string, unknown>, message: string): void;
fatal(message: string): void;
fatal(error: Error): void;
Expand Down
Loading