|
@@ -11,7 +11,7 @@ export function setLogLevel(level: LogLevel) {
|
|
|
curLogLevel = level;
|
|
|
}
|
|
|
|
|
|
-function getLogLevel(...args: unknown[]): number {
|
|
|
+function getLogLevel(args: unknown[]): number {
|
|
|
if(typeof args.at(-1) === "number")
|
|
|
return args.splice(args.length - 1, 1)[0] as number;
|
|
|
return 0;
|
|
@@ -22,28 +22,28 @@ const consPrefix = `[${scriptInfo.name}]`;
|
|
|
|
|
|
/**
|
|
|
* Logs string-compatible values to the console, as long as the log level is sufficient.
|
|
|
- * @param args Last parameter is logLevel: 0 = Debug, 1/undefined = Info
|
|
|
+ * @param args Last parameter is log level (0 = Debug, 1/undefined = Info)
|
|
|
*/
|
|
|
export function log(...args: unknown[]): void {
|
|
|
- if(curLogLevel <= getLogLevel(...args))
|
|
|
+ if(curLogLevel <= getLogLevel(args))
|
|
|
console.log(consPrefix, ...args);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Logs string-compatible values to the console as info, as long as the log level is sufficient.
|
|
|
- * @param args Last parameter is logLevel: 0 = Debug, 1/undefined = Info
|
|
|
+ * @param args Last parameter is log level (0 = Debug, 1/undefined = Info)
|
|
|
*/
|
|
|
export function info(...args: unknown[]): void {
|
|
|
- if(curLogLevel <= getLogLevel(...args))
|
|
|
+ if(curLogLevel <= getLogLevel(args))
|
|
|
console.info(consPrefix, ...args);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Logs string-compatible values to the console as a warning, as long as the log level is sufficient.
|
|
|
- * @param args Last parameter is logLevel: 0 = Debug, 1/undefined = Info
|
|
|
+ * @param args Last parameter is log level (0 = Debug, 1/undefined = Info)
|
|
|
*/
|
|
|
export function warn(...args: unknown[]): void {
|
|
|
- if(curLogLevel <= getLogLevel(...args))
|
|
|
+ if(curLogLevel <= getLogLevel(args))
|
|
|
console.warn(consPrefix, ...args);
|
|
|
}
|
|
|
|
|
@@ -186,7 +186,8 @@ export interface SiteEvents extends EventEmitter {
|
|
|
export const siteEvents = new EventEmitter() as SiteEvents;
|
|
|
|
|
|
/**
|
|
|
- * Returns the data of an event from the @billjs/event-emitter library
|
|
|
+ * Returns the data of an event from the `@billjs/event-emitter` library.
|
|
|
+ * This function is used to assert the type passed in `<T>`
|
|
|
* @param evt Event object from the `.on()` or `.once()` method
|
|
|
* @template T Type of the data passed by `.fire(type: string, data: T)`
|
|
|
*/
|