swc/bundler/tests/.cache/deno/87c9be5e57ebc3b7a43345f000d440c4864abc6d.ts
강동윤 bbaf619f63
fix(bundler): Fix bugs (#1437)
swc_bundler:
 - [x] Fix wrapped esms. (denoland/deno#9307)
 - [x] Make test secure.
2021-03-02 17:33:03 +09:00

55 lines
1.2 KiB
TypeScript

// Loaded from https://deno.land/x/mysql/src/logger.ts
import { log } from "../deps.ts";
let logger = log.getLogger();
export { logger as log };
let isDebug = false;
/** @ignore */
export function debug(func: Function) {
if (isDebug) {
func();
}
}
export interface LoggerConfig {
/** Enable logging (default: true) */
enable?: boolean;
/** The minimal level to print (default: "INFO") */
level?: log.LevelName;
/** A deno_std/log.Logger instance to be used as logger. When used, `level` is ignored. */
logger?: log.Logger;
}
export async function configLogger(config: LoggerConfig) {
let { enable = true, level = "INFO" } = config;
if (config.logger) level = config.logger.levelName;
isDebug = level == "DEBUG";
if (!enable) {
logger = new log.Logger("fakeLogger", "NOTSET", {});
logger.level = 100;
} else {
if (!config.logger) {
await log.setup({
handlers: {
console: new log.handlers.ConsoleHandler(level),
},
loggers: {
default: {
level: "DEBUG",
handlers: ["console"],
},
},
});
logger = log.getLogger();
} else {
logger = config.logger;
}
}
}