UNPKG

nextcloud-node-client

Version:

Nextcloud client API for node.js TypeScript applications

104 lines (103 loc) 3.2 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const environment_1 = __importDefault(require("./environment")); const tslog_1 = require("tslog"); class Logger { constructor() { let minLevel; switch (environment_1.default.getMinLogLevel()) { case "silly": minLevel = "silly"; break; case "trace": minLevel = "trace"; break; case "debug": minLevel = "debug"; break; case "info": minLevel = "info"; break; case "warn": minLevel = "warn"; break; case "error": minLevel = "error"; break; case "fatal": minLevel = "fatal"; break; default: minLevel = "error"; } minLevel = "error"; this.logger = new tslog_1.Logger({ minLevel }); // overload is required to get the real position for logging this.silly = this.logger.silly.bind(this.logger); this.trace = this.logger.trace.bind(this.logger); this.debug = this.logger.debug.bind(this.logger); this.info = this.logger.info.bind(this.logger); this.warn = this.logger.warn.bind(this.logger); this.error = this.logger.error.bind(this.logger); this.fatal = this.logger.fatal.bind(this.logger); } /** * Logs a silly message. * @param args - Multiple log attributes that should be logged out. */ silly(...args) { /* istanbul ignore next */ return this.logger.silly(...args); } /** * Logs a trace message. * @param args - Multiple log attributes that should be logged out. */ trace(...args) { /* istanbul ignore next */ return this.logger.trace(...args); } /** * Logs a debug message. * @param args - Multiple log attributes that should be logged out. */ debug(...args) { return this.logger.debug(...args); } /** * Logs a info message. * @param args - Multiple log attributes that should be logged out. */ info(...args) { /* istanbul ignore next */ return this.logger.info(...args); } /** * Logs a warn message. * @param args - Multiple log attributes that should be logged out. */ warn(...args) { /* istanbul ignore next */ return this.logger.warn(...args); } /** * Logs a error message. * @param args - Multiple log attributes that should be logged out. */ error(...args) { /* istanbul ignore next */ return this.logger.error(...args); } /** * Logs a fatal message. * @param args - Multiple log attributes that should be logged out. */ fatal(...args) { /* istanbul ignore next */ return this.logger.fatal(...args); } } exports.default = Logger;