UNPKG

unstructured-client

Version:

<h3 align="center"> <img src="https://raw.githubusercontent.com/Unstructured-IO/unstructured/main/img/unstructured_logo.png" height="200" > </h3>

59 lines 1.83 kB
"use strict"; /* * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.createConsoleLogger = exports.consoleLoggerLevels = void 0; exports.consoleLoggerLevels = [ "debug", "warning", "info", "error", ]; function createConsoleLogger(level) { const min = exports.consoleLoggerLevels.indexOf(level); const noop = () => { }; const logger = { debug: noop, warning: noop, info: noop, error: noop, }; return exports.consoleLoggerLevels.reduce((logger, level, i) => { if (i < min) { return logger; } logger[level] = log.bind(null, level); return logger; }, logger); } exports.createConsoleLogger = createConsoleLogger; function log(level, message, data) { let line = ""; const allData = [{ msg: message, l: level }, data]; for (const ctx of allData) { for (const [key, value] of Object.entries(ctx || {})) { if (value == null) { line += ` ${key}=<${value}>`; } else if (typeof value === "function") { line += ` ${key}=<function>`; } else if (typeof value === "symbol") { line += ` ${key}=${value.toString()}`; } else if (typeof value === "string") { const v = value.search(/\s/g) >= 0 ? JSON.stringify(value) : value; line += ` ${key}=${v}`; } else if (typeof value !== "object") { line += ` ${key}=${value}`; } else { line += ` ${key}="${JSON.stringify(value)}"`; } } } console.error(line); } //# sourceMappingURL=console-logger.js.map