mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
fix(log): make setup and destroy sync (#2532)
Co-authored-by: Yoshiya Hinosawa <stibium121@gmail.com>
This commit is contained in:
parent
e4badb0aa8
commit
ebeecacd61
@ -50,8 +50,8 @@ export class BaseHandler {
|
||||
}
|
||||
|
||||
log(_msg: string) {}
|
||||
async setup() {}
|
||||
async destroy() {}
|
||||
setup() {}
|
||||
destroy() {}
|
||||
}
|
||||
|
||||
export class ConsoleHandler extends BaseHandler {
|
||||
@ -120,8 +120,8 @@ export class FileHandler extends WriterHandler {
|
||||
};
|
||||
}
|
||||
|
||||
override async setup() {
|
||||
this._file = await Deno.open(this._filename, this._openOptions);
|
||||
override setup() {
|
||||
this._file = Deno.openSync(this._filename, this._openOptions);
|
||||
this._writer = this._file;
|
||||
this._buf = new BufWriterSync(this._file);
|
||||
|
||||
@ -155,7 +155,6 @@ export class FileHandler extends WriterHandler {
|
||||
this._file?.close();
|
||||
this._file = undefined;
|
||||
removeEventListener("unload", this.#unloadCallback);
|
||||
return Promise.resolve();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ export function critical<T>(
|
||||
}
|
||||
|
||||
/** Setup logger config. */
|
||||
export async function setup(config: LogConfig) {
|
||||
export function setup(config: LogConfig) {
|
||||
state.config = {
|
||||
handlers: { ...DEFAULT_CONFIG.handlers, ...config.handlers },
|
||||
loggers: { ...DEFAULT_CONFIG.loggers, ...config.loggers },
|
||||
@ -189,7 +189,7 @@ export async function setup(config: LogConfig) {
|
||||
|
||||
for (const handlerName in handlers) {
|
||||
const handler = handlers[handlerName];
|
||||
await handler.setup();
|
||||
handler.setup();
|
||||
state.handlers.set(handlerName, handler);
|
||||
}
|
||||
|
||||
@ -216,4 +216,4 @@ export async function setup(config: LogConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
await setup(DEFAULT_CONFIG);
|
||||
setup(DEFAULT_CONFIG);
|
||||
|
Loading…
Reference in New Issue
Block a user