UNPKG

ovm

Version:

OVM is a CLI application for managing Obsidian vaults.

43 lines 1.98 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.enableDebugLogLevel = exports.enableLoggingTimestamp = exports.silentCheck = exports.customCommandLogger = exports.logger = exports.getFormat = exports.CUSTOM_COMMAND_LOGGER_FILE = void 0; const os_1 = require("os"); const path_1 = require("path"); const winston_1 = require("winston"); exports.CUSTOM_COMMAND_LOGGER_FILE = (0, path_1.join)((0, os_1.tmpdir)(), 'ovm-custom-command.json'); const getFormat = () => { const jsonLogging = process.env.OVM_ENABLE_LOG_JSON === 'true'; const enableTimestamp = process.env.OVM_ENABLE_LOG_TIMESTAMP === 'true'; return winston_1.format.combine(...(enableTimestamp ? [winston_1.format.timestamp()] : []), jsonLogging ? (winston_1.format.json(), winston_1.format.prettyPrint()) : (winston_1.format.splat(), winston_1.format.simple())); }; exports.getFormat = getFormat; exports.logger = (0, winston_1.createLogger)({ format: (0, exports.getFormat)(), level: 'info', transports: [new winston_1.transports.Console()], }); exports.customCommandLogger = (0, winston_1.createLogger)({ level: 'debug', transports: [ new winston_1.transports.File({ filename: exports.CUSTOM_COMMAND_LOGGER_FILE, format: winston_1.format.combine(winston_1.format.timestamp(), winston_1.format.json(), winston_1.format.prettyPrint()), }), ], }); const silentCheck = (flags) => flags && 'silent' in flags && flags.silent; exports.silentCheck = silentCheck; const enableLoggingTimestamp = (timestamp) => { process.env.OVM_ENABLE_LOG_TIMESTAMP = timestamp ? 'true' : 'false'; }; exports.enableLoggingTimestamp = enableLoggingTimestamp; const enableDebugLogLevel = (debug, flags) => { if (debug) { exports.logger.level = 'debug'; exports.logger.debug(`Command called`, { flags }); } }; exports.enableDebugLogLevel = enableDebugLogLevel; //# sourceMappingURL=logger.js.map