UNPKG

@graphql-hive/logger

Version:
21 lines (18 loc) 634 B
import { getLogger } from '@logtape/logtape'; class LogTapeLogWriter { constructor(options = {}) { this.options = options; this.#logTapeLogger = getLogger(this.options.category ?? ["hive-gateway"]); } #logTapeLogger; write(level, attrs, msg) { const log = this.#logTapeLogger[level].bind(this.#logTapeLogger); const properties = this.options.getProperties ? this.options.getProperties(level, attrs, msg) : attrs ? { // TODO: attrs can be an array too ...attrs } : void 0; if (msg != null) log(msg, properties); else if (properties) log(properties); } } export { LogTapeLogWriter };