var _computedKey;
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
// This module is browser compatible.
import { getLevelByName, getLevelName } from "./levels.ts";
const DEFAULT_FORMATTER = ({ levelName, msg })=>`${levelName} ${msg}`;
_computedKey = Symbol.dispose;
export class BaseHandler {
  #levelName;
  #level;
  formatter;
  constructor(levelName, options){
    const { formatter = DEFAULT_FORMATTER } = options ?? {};
    this.#levelName = levelName;
    this.#level = getLevelByName(levelName);
    this.formatter = formatter;
  }
  get level() {
    return this.#level;
  }
  set level(level) {
    this.#level = level;
    this.#levelName = getLevelName(level);
  }
  get levelName() {
    return this.#levelName;
  }
  set levelName(levelName) {
    this.#levelName = levelName;
    this.#level = getLevelByName(levelName);
  }
  handle(logRecord) {
    if (this.level > logRecord.level) return;
    const msg = this.format(logRecord);
    this.log(msg);
  }
  format(logRecord) {
    return this.formatter(logRecord);
  }
  setup() {}
  destroy() {}
  [_computedKey]() {
    this.destroy();
  }
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImh0dHBzOi8vanNyLmlvL0BzdGQvbG9nLzAuMjI0LjcvYmFzZV9oYW5kbGVyLnRzIl0sInNvdXJjZXNDb250ZW50IjpbIi8vIENvcHlyaWdodCAyMDE4LTIwMjQgdGhlIERlbm8gYXV0aG9ycy4gQWxsIHJpZ2h0cyByZXNlcnZlZC4gTUlUIGxpY2Vuc2UuXG4vLyBUaGlzIG1vZHVsZSBpcyBicm93c2VyIGNvbXBhdGlibGUuXG5pbXBvcnQge1xuICBnZXRMZXZlbEJ5TmFtZSxcbiAgZ2V0TGV2ZWxOYW1lLFxuICB0eXBlIExldmVsTmFtZSxcbiAgdHlwZSBMb2dMZXZlbCxcbn0gZnJvbSBcIi4vbGV2ZWxzLnRzXCI7XG5pbXBvcnQgdHlwZSB7IExvZ1JlY29yZCB9IGZyb20gXCIuL2xvZ2dlci50c1wiO1xuXG5leHBvcnQgdHlwZSBGb3JtYXR0ZXJGdW5jdGl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