@iobroker/js-controller-common-db 7.0.8-alpha.8-20251127-036be0224 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/lib/common/logger.js +5 -5
- package/build/cjs/lib/common/logger.js.map +1 -1
- package/build/cjs/lib/common/tools.d.ts +9 -0
- package/build/cjs/lib/common/tools.js +1 -1
- package/build/cjs/lib/common/tools.js.map +2 -2
- package/build/esm/lib/common/logger.js +17 -17
- package/build/esm/lib/common/logger.js.map +1 -1
- package/build/esm/lib/common/tools.d.ts +9 -0
- package/build/esm/lib/common/tools.d.ts.map +1 -1
- package/build/esm/lib/common/tools.js +14 -2
- package/build/esm/lib/common/tools.js.map +1 -1
- package/build/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -316,9 +316,9 @@ function logger(level, files, noStdout, prefix) {
|
|
|
316
316
|
this._fileChecker = setInterval(() => {
|
|
317
317
|
this.transports.forEach((transport) => {
|
|
318
318
|
if (
|
|
319
|
-
|
|
320
|
-
transport.name !== "dailyRotateFile" ||
|
|
321
|
-
!transport.options ||
|
|
319
|
+
// @ts-expect-error we use undocumented stuff here TODO
|
|
320
|
+
transport.name !== "dailyRotateFile" || // @ts-expect-error we use undocumented stuff here TODO
|
|
321
|
+
!transport.options || // @ts-expect-error we use undocumented stuff here TODO
|
|
322
322
|
transport.options.name !== tools.appName
|
|
323
323
|
) {
|
|
324
324
|
return;
|
|
@@ -349,12 +349,12 @@ function logger(level, files, noStdout, prefix) {
|
|
|
349
349
|
this.log({
|
|
350
350
|
level: import_node_os.default.platform().startsWith("win") ? "info" : "error",
|
|
351
351
|
message: `host.${hostname} Cannot delete file "${import_node_path.default.normalize(
|
|
352
|
-
|
|
352
|
+
// @ts-expect-error we use undocumented stuff here TODO
|
|
353
353
|
`${transport.dirname}/${files2[i]}`
|
|
354
354
|
)}": ${e}`
|
|
355
355
|
});
|
|
356
356
|
console.log(`host.${hostname} Cannot delete file "${import_node_path.default.normalize(
|
|
357
|
-
|
|
357
|
+
// @ts-expect-error we use undocumented stuff here TODO
|
|
358
358
|
`${transport.dirname}/${files2[i]}`
|
|
359
359
|
)}": ${e.message}`);
|
|
360
360
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/lib/common/logger.ts", "../../../../../../node_modules/@alcalzone/esm2cjs/shims/import.meta.url/shim.js"],
|
|
4
|
-
"sourcesContent": ["import winston from 'winston';\nimport DailyRotateFile from 'winston-daily-rotate-file';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport os from 'node:os';\nimport * as tools from '@/lib/common/tools.js';\nimport Transport from 'winston-transport';\nimport { LEVEL } from 'triple-beam';\nimport deepClone from 'deep-clone';\nimport type { Syslog } from 'winston-syslog';\nimport type { SeqTransport } from '@datalust/winston-seq';\nimport * as url from 'node:url';\nimport { createRequire } from 'node:module';\n\n// eslint-disable-next-line unicorn/prefer-module\nconst thisDir = url.fileURLToPath(new URL('.', import.meta.url || `file://${__filename}`));\n\n// eslint-disable-next-line unicorn/prefer-module\nconst require = createRequire(import.meta.url || `file://${__filename}`);\n\nconst hostname = tools.getHostName();\n\nlet SysLog: typeof Syslog | undefined;\ntry {\n SysLog = require('winston-syslog').Syslog;\n} catch {\n //console.log('No syslog support');\n}\n\nlet Seq: typeof SeqTransport | undefined;\ntry {\n Seq = require('@datalust/winston-seq').SeqTransport;\n} catch {\n //console.log('No seq support');\n}\n\nexport type LogInfo = Record<string | symbol, any>;\n\n// We must check if SysLog is defined before extending it\nconst IoSysLog =\n SysLog &&\n class extends SysLog {\n constructor(options: any) {\n super(options);\n }\n log(info: LogInfo, callback: () => void): void {\n // we need to map the ioBroker loglevels to the Syslog ones\n const ioInfo = info;\n if (ioInfo[LEVEL] === 'warn') {\n ioInfo[LEVEL] = 'warning';\n }\n if (ioInfo[LEVEL] === 'info') {\n ioInfo[LEVEL] = 'notice';\n }\n if (ioInfo[LEVEL] === 'debug') {\n ioInfo[LEVEL] = 'info';\n }\n if (ioInfo[LEVEL] === 'silly') {\n ioInfo[LEVEL] = 'debug';\n }\n\n // No clue why log could ever be undefined, but hey...\n super.log?.(ioInfo, callback);\n }\n };\n\n// We want to enhance some data for Seq\nconst IoSeq =\n Seq &&\n class extends Seq {\n log(info: LogInfo, callback: () => void): void {\n const ioInfo = deepClone(info);\n ioInfo.props = ioInfo.props || {};\n\n // map our log levels to Seq levels\n const level = (ioInfo.level || '').toLowerCase();\n if (level.includes('error')) {\n ioInfo.level = 'Error';\n } else if (level.includes('warn')) {\n ioInfo.level = 'Warning';\n } else if (level.includes('info')) {\n ioInfo.level = 'Information';\n } else if (level.includes('debug')) {\n ioInfo.level = 'Debug';\n } else if (level.includes('silly')) {\n ioInfo.level = 'Verbose';\n } else {\n ioInfo.level = 'Information';\n }\n\n // we add own properties\n ioInfo.props.Hostname = tools.getHostName();\n if (ioInfo.message) {\n // handle as single line with s flag, to if message ends with CR, etc\n const msgParts = ioInfo.message.match(/^([^.]+\\.[0-9]+) \\(([^)]+)\\) (.*)$/s);\n if (msgParts) {\n ioInfo.props.Source = msgParts[1];\n ioInfo.props.Pid = msgParts[2];\n } else {\n ioInfo.props.Source = 'js-controller';\n }\n }\n super.log(ioInfo, callback);\n }\n };\n\n// Class used to inform adapter about new log entry\nclass NotifierTransport extends Transport {\n private name: string;\n constructor(opts: any) {\n super(opts);\n this.name = 'NT'; // NotifierTransport\n }\n\n log(info: LogInfo, callback: () => void): void {\n const msg = {\n severity: info[LEVEL],\n ts: new Date(info.timestamp).getTime(),\n message: info.message,\n };\n setImmediate(() => this.emit('logged', msg));\n callback();\n }\n}\n\nexport interface UserOptions {\n level: string;\n maxDays: number;\n noStdout: boolean;\n localTime?: string;\n colorize?: boolean;\n json?: boolean;\n prefix?: string;\n transport: Record<string, any>;\n}\n\ninterface Options {\n format?: winston.Logform.Format;\n transports: Transport[];\n}\n\nexport function logger(\n level: string | UserOptions,\n files?: string[] | string,\n noStdout?: boolean,\n prefix?: string,\n): winston.Logger {\n const options: Options = {\n transports: [],\n };\n\n //var defaultMaxSize;// = 10 * 1024 * 1024;\n\n if (typeof files === 'string') {\n files = [files];\n }\n\n const formatter = (info: LogInfo): string => `${timestamp(info.timestamp)} - ${info.level}: ${info.message}`;\n\n files = files || [];\n\n // indicator which is used to determine the log dir for developing, where it should be inside the repository\n const isNpm = !thisDir\n .replace(/\\\\/g, '/')\n .toLowerCase()\n .includes(`${tools.appName.toLowerCase()}.js-controller/packages/`);\n\n if (tools.isObject(level)) {\n const userOptions: UserOptions = deepClone(level);\n\n level = userOptions.level;\n prefix = userOptions.prefix || '';\n noStdout = userOptions.noStdout;\n const winstonFormats = [];\n /** @ts-expect-error formatter arg wrongly documented */\n winstonFormats.push(winston.format.timestamp({ format: timestamp }));\n if (userOptions.json === undefined || userOptions.json) {\n winstonFormats.push(winston.format.json());\n }\n if (prefix) {\n winstonFormats.push(winston.format.label({ label: prefix }));\n }\n if (userOptions.colorize === undefined || userOptions.colorize) {\n winstonFormats.push(winston.format.colorize());\n }\n options.format = winston.format.combine.apply(null, winstonFormats);\n\n if (userOptions.prefix !== undefined) {\n delete userOptions.prefix;\n }\n\n if (userOptions.transport) {\n let fName = 0;\n const isWindows = os.platform().startsWith('win');\n for (const transport of Object.values(userOptions.transport)) {\n transport._defaultConfigLoglevel = transport.level; // remember Loglevel if set\n transport.level = transport.level || level;\n\n if (transport.type === 'file' && transport.enabled !== false) {\n transport.filename = transport.filename || `log/${tools.appName}`;\n\n if (!transport.fileext && transport.filename.indexOf('.log') === -1) {\n transport.fileext = '.log';\n }\n\n if (!fName) {\n transport.systemLog = true;\n }\n\n transport.handleExceptions = false;\n transport.name = fName ? `dailyRotateFile${fName}` : tools.appName;\n fName++;\n transport.filename = transport.filename.replace(/\\\\/g, '/');\n if (transport.filename.match(/^\\w:\\/|^\\//)) {\n transport.filename = path.normalize(transport.filename);\n } else {\n transport.filename = path.normalize(\n `${tools.getControllerDir()}${isNpm ? '/../../' : '/'}${transport.filename}`,\n );\n }\n transport.auditFile = `${transport.filename}-audit.json`;\n\n transport.createSymlink =\n transport.createSymlink !== undefined ? transport.createSymlink : !isWindows;\n transport.symlinkName =\n transport.symlinkName !== undefined\n ? transport.symlinkName\n : path.basename(`${transport.filename}.current.log`);\n\n transport.filename += `.%DATE%${transport.fileext || ''}`;\n //transport.label = prefix || ''; //TODO format.label()\n // transport.json = (transport.json !== undefined) ? transport.json : false; // TODO format.json(), new Default!!\n transport.silent = transport.silent !== undefined ? transport.silent : false;\n // transport.colorize = (transport.colorize !== undefined) ? transport.colorize : ((userOptions.colorize === undefined) ? true : userOptions.colorize); //TODO format.colorize()\n transport.localTime =\n transport.localTime !== undefined\n ? transport.localTime\n : userOptions.localTime === undefined\n ? true\n : userOptions.localTime;\n transport.datePattern = 'YYYY-MM-DD';\n transport.format = winston.format.combine(winston.format.printf(formatter));\n /*transport.logException = function (message, info, next, err) {\n console.error(message);\n };*/\n transport.zippedArchive = isWindows\n ? false\n : transport.zippedArchive !== undefined\n ? transport.zippedArchive\n : true;\n\n if (transport.maxFiles === null && userOptions.maxDays) {\n transport.maxFiles = `${userOptions.maxDays}d`;\n }\n\n try {\n const _log = new DailyRotateFile(transport);\n\n _log.on('error', err => {\n console.error(`Error on log file rotation: ${err.message}`);\n });\n\n options.transports.push(_log);\n } catch (e) {\n if (e.code === 'EACCES') {\n // modify error code to make it unique for handling\n e.code = 'EACCES_LOG';\n }\n throw e;\n }\n } else if (transport.type === 'syslog' && transport.enabled !== false) {\n if (!IoSysLog) {\n console.error('Syslog configured, but not installed! Ignore');\n continue;\n }\n // host: The host running syslogd, defaults to localhost.\n // port: The port on the host that syslog is running on, defaults to syslogd's default port.\n // protocol: The network protocol to log over (e.g. tcp4, udp4, unix, unix-connect, etc).\n // path: The path to the syslog dgram socket (i.e. /dev/log or /var/run/syslog for OS X).\n // pid: PID of the process that log messages are coming from (Default process.pid).\n // facility: Syslog facility to use (Default: local0).\n // localhost: Host to indicate that log messages are coming from (Default: localhost).\n // sysLogType: The type of the syslog protocol to use (Default: BSD).\n // app_name: The name of the application (Default: process.title).\n // eol: The end of line character to be added to the end of the message (Default: Message without modifications).\n // replace the used by syslog attribute \"type\" with own \"sysLogType\"\n\n // If no name defined, use hostname as name\n transport.localhost = transport.localhost || hostname;\n transport.format = winston.format.combine(winston.format.printf(formatter));\n if (transport.sysLogType) {\n transport.type = transport.sysLogType;\n delete transport.sysLogType;\n } else {\n delete transport.type;\n }\n try {\n options.transports.push(new IoSysLog(transport));\n } catch (e) {\n console.error(`Cannot activate Syslog: ${e.message}`);\n }\n } else if (transport.type === 'http' && transport.enabled !== false) {\n // host: (Default: localhost) Remote host of the HTTP logging endpoint\n // port: (Default: 80 or 443) Remote port of the HTTP logging endpoint\n // path: (Default: /) Remote URI of the HTTP logging endpoint\n // auth: (Default: None) An object representing the username and password for HTTP Basic Auth\n // ssl: (Default: false) Value indicating if we should use HTTPS\n\n // If no name defined, use hostname as name\n transport.host = transport.host || 'localhost';\n\n try {\n options.transports.push(new winston.transports.Http(transport));\n } catch (e) {\n console.error(`Cannot activate HTTP: ${e.message}`);\n }\n } else if (transport.type === 'stream' && transport.enabled !== false) {\n // stream: any Node.js stream. If an objectMode stream is provided then the entire info object will be written. Otherwise info[MESSAGE] will be written.\n // level: Level of messages that this transport should log (default: level set on parent logger).\n // silent: Boolean flag indicating whether to suppress output (default false).\n // eol: Line-ending character to use. (default: os.EOL).\n\n // If no name defined, use hostname as name\n transport.host = transport.host || 'localhost';\n\n try {\n if (typeof transport.stream === 'string') {\n transport.stream = fs.createWriteStream(transport.stream);\n transport.stream.on('error', (err: Error) => {\n console.error(`Error in Stream: ${err.message}`);\n });\n }\n\n options.transports.push(new winston.transports.Stream(transport));\n } catch (e) {\n console.error(`Cannot activate Stream: ${e.message}`);\n }\n } else if (transport.type === 'seq' && transport.enabled !== false) {\n if (!IoSeq) {\n console.error('Seq configured, but not installed! Ignore');\n continue;\n }\n // serverUrl?: string;\n // apiKey?: string;\n // maxBatchingTime?: number;\n // eventSizeLimit?: number;\n // batchSizeLimit?: number;\n\n // Add only if serverUrl is configured at least\n if (transport.serverUrl) {\n try {\n transport.onError = (e: Error) => {\n console.log(`SEQ error: ${e.message}`);\n };\n const seqLogger = new IoSeq(transport);\n options.transports.push(seqLogger);\n } catch (e) {\n console.error(`Cannot activate SEQ: ${e.message}`);\n }\n } else {\n console.error('Cannot activate SEQ: No serverUrl specified');\n }\n }\n }\n }\n } else {\n for (let i = 0; i < files.length; i++) {\n const opt = {\n name: i ? `dailyRotateFile${i}` : tools.appName,\n filename: path.normalize(\n isNpm ? `${thisDir}/../../../log/${files[i]}` : `${thisDir}/../log/${files[i]}`,\n ),\n extension: '.log',\n datePattern: 'YYYY-MM-DD',\n //json: false, // If true, messages will be logged as JSON (default true). TODO format.json()\n level,\n silent: false,\n localTime: true,\n //colorize: (userOptions.colorize === undefined) ? true : userOptions.colorize, // TODO format.colorize()\n //timestamp: timestamp, // TODO: format.timestamp()\n //label: prefix || '', // TODO format.label()\n handleExceptions: false,\n //maxSize: defaultMaxSize\n };\n\n options.transports.push(new DailyRotateFile(opt));\n }\n }\n\n if (!noStdout) {\n options.transports.push(\n new winston.transports.Console({\n level,\n silent: false,\n format: winston.format.combine(winston.format.printf(formatter)),\n //colorize: (userOptions.colorize === undefined) ? true : userOptions.colorize, // TODO format.colorize()\n //timestamp: timestamp, // TODO: format.timestamp()\n //label: prefix || '' // TODO format.label()\n }),\n );\n }\n\n // Must be registered, for adapter.js notification about new logs\n options.transports.push(\n new NotifierTransport({\n level,\n silent: false,\n }),\n );\n\n const log = winston.createLogger(options);\n\n /** @ts-expect-error why do we override/add method to foreign instance? TODO */\n log.getFileName = function () {\n /** @ts-expect-error we use undocumented stuff here TODO */\n let transport = this.transports.find(t => (t.transport && t.transport.dirname) || t.dirname);\n if (transport) {\n /** @ts-expect-error we use undocumented stuff here TODO */\n transport = transport.transport ? transport.transport : transport;\n /** @ts-expect-error we use undocumented stuff here TODO */\n return `${transport.dirname}/${transport.filename.replace('%DATE%', getDate())}`;\n }\n return '';\n };\n\n log.on('error', error => {\n console.log(`Logger error: ${error.message}`);\n });\n\n // This cannot be deleted, because file rotate works with the size of files and not with the time\n // TODO research and open new issue in winston-daily-rotate-file repo\n /**\n * @param isEnabled\n * @param daysCount\n */\n // @ts-expect-error why do we override/add method to foreign instance? TODO\n log.activateDateChecker = function (isEnabled, daysCount) {\n /** @ts-expect-error we use undocumented stuff here TODO */\n if (!isEnabled && this._fileChecker) {\n /** @ts-expect-error we use undocumented stuff here TODO */\n clearInterval(this._fileChecker);\n /** @ts-expect-error we use undocumented stuff here TODO */\n } else if (isEnabled && !this._fileChecker) {\n if (!daysCount) {\n daysCount = 3;\n }\n\n // Check every hour\n /** @ts-expect-error we use undocumented stuff here TODO */\n this._fileChecker = setInterval(() => {\n this.transports.forEach(transport => {\n if (\n /** @ts-expect-error we use undocumented stuff here TODO */\n transport.name !== 'dailyRotateFile' ||\n /** @ts-expect-error we use undocumented stuff here TODO */\n !transport.options ||\n /** @ts-expect-error we use undocumented stuff here TODO */\n transport.options.name !== tools.appName\n ) {\n return;\n }\n\n /** @ts-expect-error we use undocumented stuff here TODO */\n if (transport && fs.existsSync(transport.dirname)) {\n let files;\n try {\n /** @ts-expect-error we use undocumented stuff here TODO */\n files = fs.readdirSync(transport.dirname);\n } catch (e) {\n console.error(`host.${hostname} Cannot read log directory: ${e.message}`);\n return;\n }\n const forXdays = new Date();\n forXdays.setDate(forXdays.getDate() - daysCount - 1); // normally winston now takes care, for old or on errors make sure fallback works a day later\n\n for (let i = 0; i < files.length; i++) {\n const match = files[i].match(/.+\\.(\\d+-\\d+-\\d+)/);\n if (match) {\n const date = new Date(match[1]);\n if (date < forXdays) {\n // delete file\n try {\n this.log({\n level: 'info',\n message: `host.${hostname} Delete log file ${files[i]}`,\n });\n console.log(`host.${hostname} Delete log file ${files[i]}`);\n /** @ts-expect-error we use undocumented stuff here TODO */\n fs.unlinkSync(`${transport.dirname}/${files[i]}`);\n } catch (e) {\n // there is a bug under windows, that file stays opened and cannot be deleted\n this.log({\n level: os.platform().startsWith('win') ? 'info' : 'error',\n message: `host.${hostname} Cannot delete file \"${path.normalize(\n /** @ts-expect-error we use undocumented stuff here TODO */\n `${transport.dirname}/${files[i]}`,\n )}\": ${e}`,\n });\n console.log(\n `host.${hostname} Cannot delete file \"${path.normalize(\n /** @ts-expect-error we use undocumented stuff here TODO */\n `${transport.dirname}/${files[i]}`,\n )}\": ${e.message}`,\n );\n }\n }\n }\n }\n }\n });\n }, 3_600_000); // every hour\n }\n };\n\n return log;\n}\n\nfunction getDate(): string {\n const ts = new Date();\n return `${ts.getFullYear()}-${(ts.getMonth() + 1).toString().padStart(2, '0')}-${ts\n .getDate()\n .toString()\n .padStart(2, '0')}`;\n}\n\nfunction timestamp(date: string): string {\n const ts = date ? new Date(date) : new Date();\n return `${ts.getFullYear()}-${(ts.getMonth() + 1).toString().padStart(2, '0')}-${ts\n .getDate()\n .toString()\n .padStart(2, '0')} ${ts.getHours().toString().padStart(2, '0')}:${ts\n .getMinutes()\n .toString()\n .padStart(2, '0')}:${ts.getSeconds().toString().padStart(2, '0')}.${ts\n .getMilliseconds()\n .toString()\n .padStart(3, '0')} `;\n}\n", "export const __import_meta_url =\n typeof document === 'undefined' ? new (require('url'.replace('', '')).URL)('file:' + __filename).href :\n (document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href)\n"],
|
|
4
|
+
"sourcesContent": ["import winston from 'winston';\nimport DailyRotateFile from 'winston-daily-rotate-file';\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport os from 'node:os';\nimport * as tools from '@/lib/common/tools.js';\nimport Transport from 'winston-transport';\nimport { LEVEL } from 'triple-beam';\nimport deepClone from 'deep-clone';\nimport type { Syslog } from 'winston-syslog';\nimport type { SeqTransport } from '@datalust/winston-seq';\nimport * as url from 'node:url';\nimport { createRequire } from 'node:module';\n\n// eslint-disable-next-line unicorn/prefer-module\nconst thisDir = url.fileURLToPath(new URL('.', import.meta.url || `file://${__filename}`));\n\n// eslint-disable-next-line unicorn/prefer-module\nconst require = createRequire(import.meta.url || `file://${__filename}`);\n\nconst hostname = tools.getHostName();\n\nlet SysLog: typeof Syslog | undefined;\ntry {\n SysLog = require('winston-syslog').Syslog;\n} catch {\n //console.log('No syslog support');\n}\n\nlet Seq: typeof SeqTransport | undefined;\ntry {\n Seq = require('@datalust/winston-seq').SeqTransport;\n} catch {\n //console.log('No seq support');\n}\n\nexport type LogInfo = Record<string | symbol, any>;\n\n// We must check if SysLog is defined before extending it\nconst IoSysLog =\n SysLog &&\n class extends SysLog {\n constructor(options: any) {\n super(options);\n }\n log(info: LogInfo, callback: () => void): void {\n // we need to map the ioBroker loglevels to the Syslog ones\n const ioInfo = info;\n if (ioInfo[LEVEL] === 'warn') {\n ioInfo[LEVEL] = 'warning';\n }\n if (ioInfo[LEVEL] === 'info') {\n ioInfo[LEVEL] = 'notice';\n }\n if (ioInfo[LEVEL] === 'debug') {\n ioInfo[LEVEL] = 'info';\n }\n if (ioInfo[LEVEL] === 'silly') {\n ioInfo[LEVEL] = 'debug';\n }\n\n // No clue why log could ever be undefined, but hey...\n super.log?.(ioInfo, callback);\n }\n };\n\n// We want to enhance some data for Seq\nconst IoSeq =\n Seq &&\n class extends Seq {\n log(info: LogInfo, callback: () => void): void {\n const ioInfo = deepClone(info);\n ioInfo.props = ioInfo.props || {};\n\n // map our log levels to Seq levels\n const level = (ioInfo.level || '').toLowerCase();\n if (level.includes('error')) {\n ioInfo.level = 'Error';\n } else if (level.includes('warn')) {\n ioInfo.level = 'Warning';\n } else if (level.includes('info')) {\n ioInfo.level = 'Information';\n } else if (level.includes('debug')) {\n ioInfo.level = 'Debug';\n } else if (level.includes('silly')) {\n ioInfo.level = 'Verbose';\n } else {\n ioInfo.level = 'Information';\n }\n\n // we add own properties\n ioInfo.props.Hostname = tools.getHostName();\n if (ioInfo.message) {\n // handle as single line with s flag, to if message ends with CR, etc\n const msgParts = ioInfo.message.match(/^([^.]+\\.[0-9]+) \\(([^)]+)\\) (.*)$/s);\n if (msgParts) {\n ioInfo.props.Source = msgParts[1];\n ioInfo.props.Pid = msgParts[2];\n } else {\n ioInfo.props.Source = 'js-controller';\n }\n }\n super.log(ioInfo, callback);\n }\n };\n\n// Class used to inform adapter about new log entry\nclass NotifierTransport extends Transport {\n private name: string;\n constructor(opts: any) {\n super(opts);\n this.name = 'NT'; // NotifierTransport\n }\n\n log(info: LogInfo, callback: () => void): void {\n const msg = {\n severity: info[LEVEL],\n ts: new Date(info.timestamp).getTime(),\n message: info.message,\n };\n setImmediate(() => this.emit('logged', msg));\n callback();\n }\n}\n\nexport interface UserOptions {\n level: string;\n maxDays: number;\n noStdout: boolean;\n localTime?: string;\n colorize?: boolean;\n json?: boolean;\n prefix?: string;\n transport: Record<string, any>;\n}\n\ninterface Options {\n format?: winston.Logform.Format;\n transports: Transport[];\n}\n\nexport function logger(\n level: string | UserOptions,\n files?: string[] | string,\n noStdout?: boolean,\n prefix?: string,\n): winston.Logger {\n const options: Options = {\n transports: [],\n };\n\n //var defaultMaxSize;// = 10 * 1024 * 1024;\n\n if (typeof files === 'string') {\n files = [files];\n }\n\n const formatter = (info: LogInfo): string => `${timestamp(info.timestamp)} - ${info.level}: ${info.message}`;\n\n files = files || [];\n\n // indicator which is used to determine the log dir for developing, where it should be inside the repository\n const isNpm = !thisDir\n .replace(/\\\\/g, '/')\n .toLowerCase()\n .includes(`${tools.appName.toLowerCase()}.js-controller/packages/`);\n\n if (tools.isObject(level)) {\n const userOptions: UserOptions = deepClone(level);\n\n level = userOptions.level;\n prefix = userOptions.prefix || '';\n noStdout = userOptions.noStdout;\n const winstonFormats = [];\n // @ts-expect-error formatter arg wrongly documented\n winstonFormats.push(winston.format.timestamp({ format: timestamp }));\n if (userOptions.json === undefined || userOptions.json) {\n winstonFormats.push(winston.format.json());\n }\n if (prefix) {\n winstonFormats.push(winston.format.label({ label: prefix }));\n }\n if (userOptions.colorize === undefined || userOptions.colorize) {\n winstonFormats.push(winston.format.colorize());\n }\n options.format = winston.format.combine.apply(null, winstonFormats);\n\n if (userOptions.prefix !== undefined) {\n delete userOptions.prefix;\n }\n\n if (userOptions.transport) {\n let fName = 0;\n const isWindows = os.platform().startsWith('win');\n for (const transport of Object.values(userOptions.transport)) {\n transport._defaultConfigLoglevel = transport.level; // remember Loglevel if set\n transport.level = transport.level || level;\n\n if (transport.type === 'file' && transport.enabled !== false) {\n transport.filename = transport.filename || `log/${tools.appName}`;\n\n if (!transport.fileext && transport.filename.indexOf('.log') === -1) {\n transport.fileext = '.log';\n }\n\n if (!fName) {\n transport.systemLog = true;\n }\n\n transport.handleExceptions = false;\n transport.name = fName ? `dailyRotateFile${fName}` : tools.appName;\n fName++;\n transport.filename = transport.filename.replace(/\\\\/g, '/');\n if (transport.filename.match(/^\\w:\\/|^\\//)) {\n transport.filename = path.normalize(transport.filename);\n } else {\n transport.filename = path.normalize(\n `${tools.getControllerDir()}${isNpm ? '/../../' : '/'}${transport.filename}`,\n );\n }\n transport.auditFile = `${transport.filename}-audit.json`;\n\n transport.createSymlink =\n transport.createSymlink !== undefined ? transport.createSymlink : !isWindows;\n transport.symlinkName =\n transport.symlinkName !== undefined\n ? transport.symlinkName\n : path.basename(`${transport.filename}.current.log`);\n\n transport.filename += `.%DATE%${transport.fileext || ''}`;\n //transport.label = prefix || ''; //TODO format.label()\n // transport.json = (transport.json !== undefined) ? transport.json : false; // TODO format.json(), new Default!!\n transport.silent = transport.silent !== undefined ? transport.silent : false;\n // transport.colorize = (transport.colorize !== undefined) ? transport.colorize : ((userOptions.colorize === undefined) ? true : userOptions.colorize); //TODO format.colorize()\n transport.localTime =\n transport.localTime !== undefined\n ? transport.localTime\n : userOptions.localTime === undefined\n ? true\n : userOptions.localTime;\n transport.datePattern = 'YYYY-MM-DD';\n transport.format = winston.format.combine(winston.format.printf(formatter));\n /*transport.logException = function (message, info, next, err) {\n console.error(message);\n };*/\n transport.zippedArchive = isWindows\n ? false\n : transport.zippedArchive !== undefined\n ? transport.zippedArchive\n : true;\n\n if (transport.maxFiles === null && userOptions.maxDays) {\n transport.maxFiles = `${userOptions.maxDays}d`;\n }\n\n try {\n const _log = new DailyRotateFile(transport);\n\n _log.on('error', err => {\n console.error(`Error on log file rotation: ${err.message}`);\n });\n\n options.transports.push(_log);\n } catch (e) {\n if (e.code === 'EACCES') {\n // modify error code to make it unique for handling\n e.code = 'EACCES_LOG';\n }\n throw e;\n }\n } else if (transport.type === 'syslog' && transport.enabled !== false) {\n if (!IoSysLog) {\n console.error('Syslog configured, but not installed! Ignore');\n continue;\n }\n // host: The host running syslogd, defaults to localhost.\n // port: The port on the host that syslog is running on, defaults to syslogd's default port.\n // protocol: The network protocol to log over (e.g. tcp4, udp4, unix, unix-connect, etc).\n // path: The path to the syslog dgram socket (i.e. /dev/log or /var/run/syslog for OS X).\n // pid: PID of the process that log messages are coming from (Default process.pid).\n // facility: Syslog facility to use (Default: local0).\n // localhost: Host to indicate that log messages are coming from (Default: localhost).\n // sysLogType: The type of the syslog protocol to use (Default: BSD).\n // app_name: The name of the application (Default: process.title).\n // eol: The end of line character to be added to the end of the message (Default: Message without modifications).\n // replace the used by syslog attribute \"type\" with own \"sysLogType\"\n\n // If no name defined, use hostname as name\n transport.localhost = transport.localhost || hostname;\n transport.format = winston.format.combine(winston.format.printf(formatter));\n if (transport.sysLogType) {\n transport.type = transport.sysLogType;\n delete transport.sysLogType;\n } else {\n delete transport.type;\n }\n try {\n options.transports.push(new IoSysLog(transport));\n } catch (e) {\n console.error(`Cannot activate Syslog: ${e.message}`);\n }\n } else if (transport.type === 'http' && transport.enabled !== false) {\n // host: (Default: localhost) Remote host of the HTTP logging endpoint\n // port: (Default: 80 or 443) Remote port of the HTTP logging endpoint\n // path: (Default: /) Remote URI of the HTTP logging endpoint\n // auth: (Default: None) An object representing the username and password for HTTP Basic Auth\n // ssl: (Default: false) Value indicating if we should use HTTPS\n\n // If no name defined, use hostname as name\n transport.host = transport.host || 'localhost';\n\n try {\n options.transports.push(new winston.transports.Http(transport));\n } catch (e) {\n console.error(`Cannot activate HTTP: ${e.message}`);\n }\n } else if (transport.type === 'stream' && transport.enabled !== false) {\n // stream: any Node.js stream. If an objectMode stream is provided then the entire info object will be written. Otherwise info[MESSAGE] will be written.\n // level: Level of messages that this transport should log (default: level set on parent logger).\n // silent: Boolean flag indicating whether to suppress output (default false).\n // eol: Line-ending character to use. (default: os.EOL).\n\n // If no name defined, use hostname as name\n transport.host = transport.host || 'localhost';\n\n try {\n if (typeof transport.stream === 'string') {\n transport.stream = fs.createWriteStream(transport.stream);\n transport.stream.on('error', (err: Error) => {\n console.error(`Error in Stream: ${err.message}`);\n });\n }\n\n options.transports.push(new winston.transports.Stream(transport));\n } catch (e) {\n console.error(`Cannot activate Stream: ${e.message}`);\n }\n } else if (transport.type === 'seq' && transport.enabled !== false) {\n if (!IoSeq) {\n console.error('Seq configured, but not installed! Ignore');\n continue;\n }\n // serverUrl?: string;\n // apiKey?: string;\n // maxBatchingTime?: number;\n // eventSizeLimit?: number;\n // batchSizeLimit?: number;\n\n // Add only if serverUrl is configured at least\n if (transport.serverUrl) {\n try {\n transport.onError = (e: Error) => {\n console.log(`SEQ error: ${e.message}`);\n };\n const seqLogger = new IoSeq(transport);\n options.transports.push(seqLogger);\n } catch (e) {\n console.error(`Cannot activate SEQ: ${e.message}`);\n }\n } else {\n console.error('Cannot activate SEQ: No serverUrl specified');\n }\n }\n }\n }\n } else {\n for (let i = 0; i < files.length; i++) {\n const opt = {\n name: i ? `dailyRotateFile${i}` : tools.appName,\n filename: path.normalize(\n isNpm ? `${thisDir}/../../../log/${files[i]}` : `${thisDir}/../log/${files[i]}`,\n ),\n extension: '.log',\n datePattern: 'YYYY-MM-DD',\n //json: false, // If true, messages will be logged as JSON (default true). TODO format.json()\n level,\n silent: false,\n localTime: true,\n //colorize: (userOptions.colorize === undefined) ? true : userOptions.colorize, // TODO format.colorize()\n //timestamp: timestamp, // TODO: format.timestamp()\n //label: prefix || '', // TODO format.label()\n handleExceptions: false,\n //maxSize: defaultMaxSize\n };\n\n options.transports.push(new DailyRotateFile(opt));\n }\n }\n\n if (!noStdout) {\n options.transports.push(\n new winston.transports.Console({\n level,\n silent: false,\n format: winston.format.combine(winston.format.printf(formatter)),\n //colorize: (userOptions.colorize === undefined) ? true : userOptions.colorize, // TODO format.colorize()\n //timestamp: timestamp, // TODO: format.timestamp()\n //label: prefix || '' // TODO format.label()\n }),\n );\n }\n\n // Must be registered, for adapter.js notification about new logs\n options.transports.push(\n new NotifierTransport({\n level,\n silent: false,\n }),\n );\n\n const log = winston.createLogger(options);\n\n // @ts-expect-error why do we override/add method to foreign instance? TODO\n log.getFileName = function () {\n // @ts-expect-error we use undocumented stuff here TODO\n let transport = this.transports.find(t => (t.transport && t.transport.dirname) || t.dirname);\n if (transport) {\n // @ts-expect-error we use undocumented stuff here TODO\n transport = transport.transport ? transport.transport : transport;\n // @ts-expect-error we use undocumented stuff here TODO\n return `${transport.dirname}/${transport.filename.replace('%DATE%', getDate())}`;\n }\n return '';\n };\n\n log.on('error', error => {\n console.log(`Logger error: ${error.message}`);\n });\n\n // This cannot be deleted, because file rotate works with the size of files and not with the time\n // TODO research and open new issue in winston-daily-rotate-file repo\n /**\n * @param isEnabled\n * @param daysCount\n */\n // @ts-expect-error why do we override/add method to foreign instance? TODO\n log.activateDateChecker = function (isEnabled, daysCount) {\n // @ts-expect-error we use undocumented stuff here TODO\n if (!isEnabled && this._fileChecker) {\n // @ts-expect-error we use undocumented stuff here TODO\n clearInterval(this._fileChecker);\n // @ts-expect-error we use undocumented stuff here TODO\n } else if (isEnabled && !this._fileChecker) {\n if (!daysCount) {\n daysCount = 3;\n }\n\n // Check every hour\n // @ts-expect-error we use undocumented stuff here TODO\n this._fileChecker = setInterval(() => {\n this.transports.forEach(transport => {\n if (\n // @ts-expect-error we use undocumented stuff here TODO\n transport.name !== 'dailyRotateFile' ||\n // @ts-expect-error we use undocumented stuff here TODO\n !transport.options ||\n // @ts-expect-error we use undocumented stuff here TODO\n transport.options.name !== tools.appName\n ) {\n return;\n }\n\n // @ts-expect-error we use undocumented stuff here TODO\n if (transport && fs.existsSync(transport.dirname)) {\n let files;\n try {\n // @ts-expect-error we use undocumented stuff here TODO\n files = fs.readdirSync(transport.dirname);\n } catch (e) {\n console.error(`host.${hostname} Cannot read log directory: ${e.message}`);\n return;\n }\n const forXdays = new Date();\n forXdays.setDate(forXdays.getDate() - daysCount - 1); // normally winston now takes care, for old or on errors make sure fallback works a day later\n\n for (let i = 0; i < files.length; i++) {\n const match = files[i].match(/.+\\.(\\d+-\\d+-\\d+)/);\n if (match) {\n const date = new Date(match[1]);\n if (date < forXdays) {\n // delete file\n try {\n this.log({\n level: 'info',\n message: `host.${hostname} Delete log file ${files[i]}`,\n });\n console.log(`host.${hostname} Delete log file ${files[i]}`);\n // @ts-expect-error we use undocumented stuff here TODO\n fs.unlinkSync(`${transport.dirname}/${files[i]}`);\n } catch (e) {\n // there is a bug under windows, that file stays opened and cannot be deleted\n this.log({\n level: os.platform().startsWith('win') ? 'info' : 'error',\n message: `host.${hostname} Cannot delete file \"${path.normalize(\n // @ts-expect-error we use undocumented stuff here TODO\n `${transport.dirname}/${files[i]}`,\n )}\": ${e}`,\n });\n console.log(\n `host.${hostname} Cannot delete file \"${path.normalize(\n // @ts-expect-error we use undocumented stuff here TODO\n `${transport.dirname}/${files[i]}`,\n )}\": ${e.message}`,\n );\n }\n }\n }\n }\n }\n });\n }, 3_600_000); // every hour\n }\n };\n\n return log;\n}\n\nfunction getDate(): string {\n const ts = new Date();\n return `${ts.getFullYear()}-${(ts.getMonth() + 1).toString().padStart(2, '0')}-${ts\n .getDate()\n .toString()\n .padStart(2, '0')}`;\n}\n\nfunction timestamp(date: string): string {\n const ts = date ? new Date(date) : new Date();\n return `${ts.getFullYear()}-${(ts.getMonth() + 1).toString().padStart(2, '0')}-${ts\n .getDate()\n .toString()\n .padStart(2, '0')} ${ts.getHours().toString().padStart(2, '0')}:${ts\n .getMinutes()\n .toString()\n .padStart(2, '0')}:${ts.getSeconds().toString().padStart(2, '0')}.${ts\n .getMilliseconds()\n .toString()\n .padStart(3, '0')} `;\n}\n", "export const __import_meta_url =\n typeof document === 'undefined' ? new (require('url'.replace('', '')).URL)('file:' + __filename).href :\n (document.currentScript && document.currentScript.src || new URL('main.js', document.baseURI).href)\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;ACAO,IAAM,oBACX,OAAO,aAAa,cAAc,KAAK,QAAQ,MAAM,QAAQ,IAAI,EAAE,CAAC,GAAE,IAAK,UAAU,UAAU,EAAE,OAC9F,SAAS,iBAAiB,SAAS,cAAc,OAAO,IAAI,IAAI,WAAW,SAAS,OAAO,EAAE;ADFlG,qBAAoB;AACpB,uCAA4B;AAC5B,qBAAe;AACf,uBAAiB;AACjB,qBAAe;AACf,YAAuB;AACvB,+BAAsB;AACtB,yBAAsB;AACtB,wBAAsB;AAGtB,UAAqB;AACrB,yBAA8B;AAG9B,MAAM,UAAU,IAAI,cAAc,IAAI,IAAI,KAAK,qBAAmB,UAAU,UAAU,EAAE,CAAC;AAGzF,MAAMA,eAAU,kCAAc,qBAAmB,UAAU,UAAU,EAAE;AAEvE,MAAM,WAAW,MAAM,YAAW;AAElC,IAAI;AACJ,IAAI;AACA,WAASA,SAAQ,gBAAgB,EAAE;AACvC,QAAQ;AAER;AAEA,IAAI;AACJ,IAAI;AACA,QAAMA,SAAQ,uBAAuB,EAAE;AAC3C,QAAQ;AAER;AAKA,MAAM,WACF,UACA,cAAc,OAAM;EAChB,YAAY,SAAY;AACpB,UAAM,OAAO;EACjB;EACA,IAAI,MAAe,UAAoB;AAEnC,UAAM,SAAS;AACf,QAAI,OAAO,wBAAK,MAAM,QAAQ;AAC1B,aAAO,wBAAK,IAAI;IACpB;AACA,QAAI,OAAO,wBAAK,MAAM,QAAQ;AAC1B,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Q,EAAG,SAAS,GAAG,GAAG,CAAC,IAAI,GAC5E,QAAO,EACP,SAAQ,EACR,SAAS,GAAG,GAAG,CAAC,IAAI,GAAG,SAAQ,EAAG,SAAQ,EAAG,SAAS,GAAG,GAAG,CAAC,IAAI,GACjE,WAAU,EACV,SAAQ,EACR,SAAS,GAAG,GAAG,CAAC,IAAI,GAAG,WAAU,EAAG,SAAQ,EAAG,SAAS,GAAG,GAAG,CAAC,IAAI,GACnE,gBAAe,EACf,SAAQ,EACR,SAAS,GAAG,GAAG,CAAC;AACzB;",
|
|
6
6
|
"names": ["require", "deepClone", "Transport", "winston", "os", "path", "DailyRotateFile", "fs", "files"]
|
|
7
7
|
}
|
|
@@ -123,6 +123,11 @@ export declare function isDevInstallation(): boolean;
|
|
|
123
123
|
type AppName = 'iobroker' | 'ioBroker';
|
|
124
124
|
export declare const appNameLowerCase = "iobroker";
|
|
125
125
|
export declare const appName: AppName;
|
|
126
|
+
/**
|
|
127
|
+
* Find all own IPs (ipv4 and ipv6)
|
|
128
|
+
*
|
|
129
|
+
* The result is cached for 10 seconds.
|
|
130
|
+
*/
|
|
126
131
|
export declare function findIPs(): string[];
|
|
127
132
|
/**
|
|
128
133
|
* Fetch the image information of the newest available (official) ioBroker Docker image from DockerHub
|
|
@@ -222,9 +227,13 @@ export declare function getInstalledInfo(hostRunningVersion?: string): Record<st
|
|
|
222
227
|
* @param callback function (err, sources, actualHash) { }
|
|
223
228
|
*/
|
|
224
229
|
export declare function getRepositoryFile(urlOrPath: string, additionalInfo: Record<string, any>, callback: (err?: Error | null, sources?: Record<string, any>, actualHash?: string | number) => void): void;
|
|
230
|
+
/** Result of getRepositoryFileAsync */
|
|
225
231
|
export interface RepositoryFile {
|
|
232
|
+
/** The repository JSON content */
|
|
226
233
|
json: ioBroker.RepositoryJson;
|
|
234
|
+
/** Whether the repository has changed compared to the provided hash */
|
|
227
235
|
changed: boolean;
|
|
236
|
+
/** The actual hash of the repository */
|
|
228
237
|
hash: string;
|
|
229
238
|
}
|
|
230
239
|
/**
|
|
@@ -1103,7 +1103,7 @@ async function getRepositoryFileAsync(url2, hash, force, _actualRepo) {
|
|
|
1103
1103
|
return {
|
|
1104
1104
|
json: data,
|
|
1105
1105
|
changed: _hash?.data ? hash !== _hash.data.hash : true,
|
|
1106
|
-
hash: _hash
|
|
1106
|
+
hash: _hash?.data ? _hash.data.hash : ""
|
|
1107
1107
|
};
|
|
1108
1108
|
}
|
|
1109
1109
|
async function sendDiagInfo(obj) {
|