{"version":3,"sources":["../src/log.ts"],"names":["VERSION","isBrowser","LocalStorage","formatImage","formatTime","leftPad","addColor","autobind","assert","getHiResTimestamp","originalConsole","debug","console","log","info","warn","error","DEFAULT_LOG_CONFIGURATION","enabled","level","noop","cache","ONCE","once","Log","constructor","id","_startTs","_deltaTs","_storage","userData","LOG_THROTTLE_TIMEOUT","timeStamp","Object","seal","newLevel","setLevel","getLevel","isEnabled","config","getTotal","Number","toPrecision","getDelta","priority","newPriority","getPriority","enable","setConfiguration","get","setting","set","value","settings","table","condition","message","_getLogFunction","arguments","deprecated","oldUsage","newUsage","removed","probe","logLevel","time","columns","tag","getTableHeader","image","scale","_shouldLog","logImageInBrowser","logImageInNode","timeEnd","group","opts","collapsed","options","normalizeArguments","method","groupCollapsed","assign","groupEnd","withGroup","func","trace","normalizeLogLevel","args","total","delta","decorateMessage","bind","resolvedLevel","isFinite","Array","from","length","shift","undefined","unshift","messageType","color","background","img","Image","onload","src","element","nodeName","toLowerCase","toDataURL","key","title"],"mappings":"AAGA,SAAQA,OAAR,EAAiBC,SAAjB,QAAiC,eAAjC;SACQC,Y;SACAC,W,EAAaC,U,EAAYC,O;SACzBC,Q;SACAC,Q;OACDC,M;SACCC,iB;AA2BR,MAAMC,eAAe,GAAG;AACtBC,EAAAA,KAAK,EAAEV,SAAS,KAAKW,OAAO,CAACD,KAAR,IAAiBC,OAAO,CAACC,GAA9B,GAAoCD,OAAO,CAACC,GADtC;AAEtBA,EAAAA,GAAG,EAAED,OAAO,CAACC,GAFS;AAGtBC,EAAAA,IAAI,EAAEF,OAAO,CAACE,IAHQ;AAItBC,EAAAA,IAAI,EAAEH,OAAO,CAACG,IAJQ;AAKtBC,EAAAA,KAAK,EAAEJ,OAAO,CAACI;AALO,CAAxB;AAQA,MAAMC,yBAAqD,GAAG;AAC5DC,EAAAA,OAAO,EAAE,IADmD;AAE5DC,EAAAA,KAAK,EAAE;AAFqD,CAA9D;;AAKA,SAASC,IAAT,GAAgB,CAAE;;AAElB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AG,CAACG,GAAJ,GAAUtC,KAAK,CAAC0C,SAAN,EAAV;AACA,WAAO3F,IAAP;AACD;;AACD,SAAOA,IAAP;AACD;;AAED,SAASgD,cAAT,CAAwBd,KAAxB,EAA8C;AAC5C,OAAK,MAAM0D,GAAX,IAAkB1D,KAAlB,EAAyB;AACvB,SAAK,MAAM2D,KAAX,IAAoB3D,KAAK,CAAC0D,GAAD,CAAzB,EAAgC;AAC9B,aAAOC,KAAK,IAAI,UAAhB;AACD;AACF;;AACD,SAAO,OAAP;AACD","sourcesContent":["// probe.gl, MIT license\n\n/* eslint-disable no-console */\nimport {VERSION, isBrowser} from '@probe.gl/env';\nimport {LocalStorage} from './utils/local-storage';\nimport {formatImage, formatTime, leftPad} from './utils/formatters';\nimport {addColor} from './utils/color';\nimport {autobind} from './utils/autobind';\nimport assert from './utils/assert';\nimport {getHiResTimestamp} from './utils/hi-res-timestamp';\n\n/** \"Global\" log configuration settings */\ntype LogConfiguration = {\n enabled?: boolean;\n level?: number;\n [key: string]: unknown;\n};\n\n/** Options when logging a message */\ntype LogOptions = {\n method?: Function;\n time?: boolean;\n total?: number;\n delta?: number;\n tag?: string;\n message?: string;\n once?: boolean;\n nothrottle?: boolean;\n args?: any;\n};\n\ntype LogFunction = () => void;\n\ntype Table = Record;\n\n// Instrumentation in other packages may override console methods, so preserve them here\nconst originalConsole = {\n debug: isBrowser() ? console.debug || console.log : console.log,\n log: console.log,\n info: console.info,\n warn: console.warn,\n error: console.error\n};\n\nconst DEFAULT_LOG_CONFIGURATION: Required = {\n enabled: true,\n level: 0\n};\n\nfunction noop() {} // eslint-disable-line @typescript-eslint/no-empty-function\n\nconst cache = {};\nconst ONCE = {once: true};\n\n/** A console wrapper */\n\nexport class Log {\n static VERSION = VERSION;\n\n id: string;\n VERSION: string = VERSION;\n _startTs: number = getHiResTimestamp();\n _deltaTs: number = getHiResTimestamp();\n _storage: LocalStorage;\n userData = {};\n\n // TODO - fix support from throttling groups\n LOG_THROTTLE_TIMEOUT: number = 0; // Time before throttled messages are logged again\n\n constructor({id} = {id: ''}) {\n this.id = id;\n this.userData = {};\n this._storage = new LocalStorage(\n `__probe-${this.id}__`,\n DEFAULT_LOG_CONFIGURATION\n );\n\n this.timeStamp(`${this.id} started`);\n\n autobind(this);\n Object.seal(this);\n }\n\n set level(newLevel: number) {\n this.setLevel(newLevel);\n }\n\n get level(): number {\n return this.getLevel();\n }\n\n isEnabled(): boolean {\n return this._storage.config.enabled;\n }\n\n getLevel(): number {\n return this._storage.config.level;\n }\n\n /** @return milliseconds, with fractions */\n getTotal(): number {\n return Number((getHiResTimestamp() - this._startTs).toPrecision(10));\n }\n\n /** @return milliseconds, with fractions */\n getDelta(): number {\n return Number((getHiResTimestamp() - this._deltaTs).toPrecision(10));\n }\n\n /** @deprecated use logLevel */\n set priority(newPriority: number) {\n this.level = newPriority;\n }\n\n /** @deprecated use logLevel */\n get priority(): number {\n return this.level;\n }\n\n /** @deprecated use logLevel */\n getPriority(): number {\n return this.level;\n }\n\n // Configure\n\n enable(enabled: boolean = true): this {\n this._storage.setConfiguration({enabled});\n return this;\n }\n\n setLevel(level: number): this {\n this._storage.setConfiguration({level});\n return this;\n }\n\n /** return the current status of the setting */\n get(setting: string): any {\n return this._storage.config[setting];\n }\n\n // update the status of the setting\n set(setting: string, value: any): void {\n this._storage.setConfiguration({[setting]: value});\n }\n\n /** Logs the current settings as a table */\n settings(): void {\n if (console.table) {\n console.table(this._storage.config);\n } else {\n console.log(this._storage.config);\n }\n }\n\n // Unconditional logging\n\n assert(condition: unknown, message?: string): asserts condition {\n assert(condition, message);\n }\n\n /** Warn, but only once, no console flooding */\n warn(message: string, ...args: unknown[]): LogFunction;\n warn(message: string): LogFunction {\n return this._getLogFunction(0, message, originalConsole.warn, arguments, ONCE);\n }\n\n /** Print an error */\n error(message: string, ...args: unknown[]): LogFunction;\n error(message: string): LogFunction {\n return this._getLogFunction(0, message, originalConsole.error, arguments);\n }\n\n /** Print a deprecation warning */\n deprecated(oldUsage: string, newUsage: string): LogFunction {\n return this.warn(`\\`${oldUsage}\\` is deprecated and will be removed \\\nin a later version. Use \\`${newUsage}\\` instead`);\n }\n\n /** Print a removal warning */\n removed(oldUsage: string, newUsage: string): LogFunction {\n return this.error(`\\`${oldUsage}\\` has been removed. Use \\`${newUsage}\\` instead`);\n }\n\n // Conditional logging\n\n /** Log to a group */\n probe(logLevel, message?, ...args: unknown[]): LogFunction;\n probe(logLevel, message?): LogFunction {\n return this._getLogFunction(logLevel, message, originalConsole.log, arguments, {\n time: true,\n once: true\n });\n }\n\n /** Log a debug message */\n log(logLevel, message?, ...args: unknown[]): LogFunction;\n log(logLevel, message?): LogFunction {\n return this._getLogFunction(logLevel, message, originalConsole.debug, arguments);\n }\n\n /** Log a normal message */\n info(logLevel, message?, ...args: unknown[]): LogFunction;\n info(logLevel, message?): LogFunction {\n return this._getLogFunction(logLevel, message, console.info, arguments);\n }\n\n /** Log a normal message, but only once, no console flooding */\n once(logLevel, message?, ...args: unknown[]): LogFunction;\n once(logLevel, message?) {\n return this._getLogFunction(\n logLevel,\n message,\n originalConsole.debug || originalConsole.info,\n arguments,\n ONCE\n );\n }\n\n /** Logs an object as a table */\n table(logLevel, table?, columns?): LogFunction {\n if (table) {\n return this._getLogFunction(\n logLevel,\n table,\n console.table || noop,\n (columns && [columns]) as unknown as IArguments,\n {\n tag: getTableHeader(table)\n }\n );\n }\n return noop;\n }\n\n /** logs an image under Chrome */\n image({\n logLevel,\n priority,\n image,\n message = '',\n scale = 1\n }: {\n logLevel?: number;\n priority?: number;\n image: any;\n message?: string;\n scale?: number;\n }): LogFunction {\n if (!this._shouldLog(logLevel || priority)) {\n return noop;\n }\n return isBrowser()\n ? logImageInBrowser({image, message, scale})\n : logImageInNode({image, message, scale});\n }\n\n time(logLevel, message) {\n return this._getLogFunction(logLevel, message, console.time ? console.time : console.info);\n }\n\n timeEnd(logLevel, message) {\n return this._getLogFunction(\n logLevel,\n message,\n console.timeEnd ? console.timeEnd : console.info\n );\n }\n\n timeStamp(logLevel, message?) {\n return this._getLogFunction(logLevel, message, console.timeStamp || noop);\n }\n\n group(logLevel, message, opts = {collapsed: false}) {\n const options = normalizeArguments({logLevel, message, opts});\n const {collapsed} = opts;\n // @ts-expect-error\n options.method = (collapsed ? console.groupCollapsed : console.group) || console.info;\n\n return this._getLogFunction(options);\n }\n\n groupCollapsed(logLevel, message, opts = {}) {\n return this.group(logLevel, message, Object.assign({}, opts, {collapsed: true}));\n }\n\n groupEnd(logLevel) {\n return this._getLogFunction(logLevel, '', console.groupEnd || noop);\n }\n\n // EXPERIMENTAL\n\n withGroup(logLevel: number, message: string, func: Function): void {\n this.group(logLevel, message)();\n\n try {\n func();\n } finally {\n this.groupEnd(logLevel)();\n }\n }\n\n trace(): void {\n if (console.trace) {\n console.trace();\n }\n }\n\n // PRIVATE METHODS\n\n /** Deduces log level from a variety of arguments */\n _shouldLog(logLevel: unknown): boolean {\n return this.isEnabled() && this.getLevel() >= normalizeLogLevel(logLevel);\n }\n\n _getLogFunction(\n logLevel: unknown,\n message?: unknown,\n method?: Function,\n args?: IArguments,\n opts?: LogOptions\n ): LogFunction {\n if (this._shouldLog(logLevel)) {\n // normalized opts + timings\n opts = normalizeArguments({logLevel, message, args, opts});\n method = method || opts.method;\n assert(method);\n\n opts.total = this.getTotal();\n opts.delta = this.getDelta();\n // reset delta timer\n this._deltaTs = getHiResTimestamp();\n\n const tag = opts.tag || opts.message;\n\n if (opts.once && tag) {\n if (!cache[tag]) {\n cache[tag] = getHiResTimestamp();\n } else {\n return noop;\n }\n }\n\n // TODO - Make throttling work with groups\n // if (opts.nothrottle || !throttle(tag, this.LOG_THROTTLE_TIMEOUT)) {\n // return noop;\n // }\n\n message = decorateMessage(this.id, opts.message, opts);\n\n // Bind console function so that it can be called after being returned\n return method.bind(console, message, ...opts.args);\n }\n return noop;\n }\n}\n\n/**\n * Get logLevel from first argument:\n * - log(logLevel, message, args) => logLevel\n * - log(message, args) => 0\n * - log({logLevel, ...}, message, args) => logLevel\n * - log({logLevel, message, args}) => logLevel\n */\nfunction normalizeLogLevel(logLevel: unknown): number {\n if (!logLevel) {\n return 0;\n }\n let resolvedLevel;\n\n switch (typeof logLevel) {\n case 'number':\n resolvedLevel = logLevel;\n break;\n\n case 'object':\n // Backward compatibility\n // TODO - deprecate `priority`\n // @ts-expect-error\n resolvedLevel = logLevel.logLevel || logLevel.priority || 0;\n break;\n\n default:\n return 0;\n }\n // 'log level must be a number'\n assert(Number.isFinite(resolvedLevel) && resolvedLevel >= 0);\n\n return resolvedLevel;\n}\n\n/**\n * \"Normalizes\" the various argument patterns into an object with known types\n * - log(logLevel, message, args) => {logLevel, message, args}\n * - log(message, args) => {logLevel: 0, message, args}\n * - log({logLevel, ...}, message, args) => {logLevel, message, args}\n * - log({logLevel, message, args}) => {logLevel, message, args}\n */\nexport function normalizeArguments(opts: {\n logLevel;\n message;\n collapsed?: boolean;\n args?: IArguments | undefined;\n opts?;\n}): {\n logLevel: number;\n message: string;\n args: any[];\n} {\n const {logLevel, message} = opts;\n opts.logLevel = normalizeLogLevel(logLevel);\n\n // We use `arguments` instead of rest parameters (...args) because IE\n // does not support the syntax. Rest parameters is transpiled to code with\n // perf impact. Doing it here instead avoids constructing args when logging is\n // disabled.\n // TODO - remove when/if IE support is dropped\n const args: any[] = opts.args ? Array.from(opts.args) : [];\n // args should only contain arguments that appear after `message`\n // eslint-disable-next-line no-empty\n while (args.length && args.shift() !== message) {}\n\n switch (typeof logLevel) {\n case 'string':\n case 'function':\n if (message !== undefined) {\n args.unshift(message);\n }\n opts.message = logLevel;\n break;\n\n case 'object':\n Object.assign(opts, logLevel);\n break;\n\n default:\n }\n\n // Resolve functions into strings by calling them\n if (typeof opts.message === 'function') {\n opts.message = opts.message();\n }\n const messageType = typeof opts.message;\n // 'log message must be a string' or object\n assert(messageType === 'string' || messageType === 'object');\n\n // original opts + normalized opts + opts arg + fixed up message\n return Object.assign(opts, {args}, opts.opts);\n}\n\nfunction decorateMessage(id, message, opts) {\n if (typeof message === 'string') {\n const time = opts.time ? leftPad(formatTime(opts.total)) : '';\n message = opts.time ? `${id}: ${time} ${message}` : `${id}: ${message}`;\n message = addColor(message, opts.color, opts.background);\n }\n return message;\n}\n\n/** @deprecated Function removed */\nfunction logImageInNode({image, message = '', scale = 1}) {\n console.warn('removed');\n return noop;\n}\n\nfunction logImageInBrowser({image, message = '', scale = 1}) {\n if (typeof image === 'string') {\n const img = new Image();\n img.onload = () => {\n const args = formatImage(img, message, scale);\n console.log(...args);\n };\n img.src = image;\n return noop;\n }\n const element = image.nodeName || '';\n if (element.toLowerCase() === 'img') {\n console.log(...formatImage(image, message, scale));\n return noop;\n }\n if (element.toLowerCase() === 'canvas') {\n const img = new Image();\n img.onload = () => console.log(...formatImage(img, message, scale));\n img.src = image.toDataURL();\n return noop;\n }\n return noop;\n}\n\nfunction getTableHeader(table: Table): string {\n for (const key in table) {\n for (const title in table[key]) {\n return title || 'untitled';\n }\n }\n return 'empty';\n}\n"],"file":"log.js"}