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

Merge development into main #33

Merged
merged 4 commits into from
Aug 21, 2024
Merged
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
19 changes: 10 additions & 9 deletions src/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ export class Logs {
private _maxLevel = -1;
static console: PrettyLogs;

private _log({ level, consoleLog, logMessage, metadata, type }: LogParams): LogReturn | null {
private _log({ level, consoleLog, logMessage, metadata, type }: LogParams): LogReturn {
// filter out more verbose logs according to maxLevel set in config
if (this._getNumericLevel(level) > this._maxLevel) return null;
if (this._getNumericLevel(level) <= this._maxLevel) {
consoleLog(logMessage, metadata);
}

consoleLog(logMessage, metadata);
return new LogReturn(
{
raw: logMessage,
Expand Down Expand Up @@ -45,7 +46,7 @@ export class Logs {
return metadata;
}

public ok(log: string, metadata?: Metadata): LogReturn | null {
public ok(log: string, metadata?: Metadata): LogReturn {
metadata = this._addDiagnosticInformation(metadata);
return this._log({
level: LOG_LEVEL.INFO,
Expand All @@ -56,7 +57,7 @@ export class Logs {
});
}

public info(log: string, metadata?: Metadata): LogReturn | null {
public info(log: string, metadata?: Metadata): LogReturn {
metadata = this._addDiagnosticInformation(metadata);
return this._log({
level: LOG_LEVEL.INFO,
Expand All @@ -67,7 +68,7 @@ export class Logs {
});
}

public error(log: string, metadata?: Metadata): LogReturn | null {
public error(log: string, metadata?: Metadata): LogReturn {
metadata = this._addDiagnosticInformation(metadata);
return this._log({
level: LOG_LEVEL.ERROR,
Expand All @@ -78,7 +79,7 @@ export class Logs {
});
}

public debug(log: string, metadata?: Metadata): LogReturn | null {
public debug(log: string, metadata?: Metadata): LogReturn {
metadata = this._addDiagnosticInformation(metadata);
return this._log({
level: LOG_LEVEL.DEBUG,
Expand All @@ -89,7 +90,7 @@ export class Logs {
});
}

public fatal(log: string, metadata?: Metadata): LogReturn | null {
public fatal(log: string, metadata?: Metadata): LogReturn {
if (!metadata) {
metadata = Logs.convertErrorsIntoObjects(new Error(log)) as Metadata;
const stack = metadata.stack as string[];
Expand All @@ -114,7 +115,7 @@ export class Logs {
});
}

public verbose(log: string, metadata?: Metadata): LogReturn | null {
public verbose(log: string, metadata?: Metadata): LogReturn {
metadata = this._addDiagnosticInformation(metadata);
return this._log({
level: LOG_LEVEL.VERBOSE,
Expand Down
Loading