Skip to content

fix: fix log namespace #2008

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
18 changes: 8 additions & 10 deletions packages/ts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,10 @@ function format(fmt: string, args: string[]): string {
return out;
}

// Host interface for logging
export declare namespace log {
// Host export for logging, providing basic logging functionality
export function log(level: Level, msg: string): void;
}
// Host export for logging, providing basic logging functionality
export declare function log(level: log.Level, msg: string): void;

// Host interface for logging
export namespace log {
export enum Level {
CRITICAL = 0,
Expand All @@ -104,7 +102,7 @@ export namespace log {
* @param args Format string arguments.
*/
export function critical(msg: string, args: Array<string>): void {
log.log(Level.CRITICAL, format(msg, args));
log(Level.CRITICAL, format(msg, args));
}

/**
Expand All @@ -114,7 +112,7 @@ export namespace log {
* @param args Format string arguments.
*/
export function error(msg: string, args: Array<string>): void {
log.log(Level.ERROR, format(msg, args));
log(Level.ERROR, format(msg, args));
}

/** Logs a warning message.
Expand All @@ -123,7 +121,7 @@ export namespace log {
* @param args Format string arguments.
*/
export function warning(msg: string, args: Array<string>): void {
log.log(Level.WARNING, format(msg, args));
log(Level.WARNING, format(msg, args));
}

/** Logs an info message.
Expand All @@ -132,7 +130,7 @@ export namespace log {
* @param args Format string arguments.
*/
export function info(msg: string, args: Array<string>): void {
log.log(Level.INFO, format(msg, args));
log(Level.INFO, format(msg, args));
}

/** Logs a debug message.
Expand All @@ -141,7 +139,7 @@ export namespace log {
* @param args Format string arguments.
*/
export function debug(msg: string, args: Array<string>): void {
log.log(Level.DEBUG, format(msg, args));
log(Level.DEBUG, format(msg, args));
}
}

Expand Down