@sapphire/plugin-logger 4.1.0-next.c2464a5 → 4.1.0-next.fb8af18

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.
@@ -6,7 +6,7 @@ var LoggerStyle_cjs = require('./lib/LoggerStyle.cjs');
6
6
  var LoggerTimestamp_cjs = require('./lib/LoggerTimestamp.cjs');
7
7
 
8
8
  // src/index.ts
9
- var version = "4.1.0-next.c2464a5";
9
+ var version = "4.1.0-next.fb8af18";
10
10
 
11
11
  exports.version = version;
12
12
  Object.keys(Logger_cjs).forEach(function (k) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;AAwBO,IAAM,OAAkB,GAAA","file":"index.cjs","sourcesContent":["import type { Collection } from 'discord.js';\nimport type { LoggerOptions } from './lib/Logger';\nimport type { LoggerTransport } from './lib/LoggerTransport';\nimport type { LogLevel } from '@sapphire/framework';\n\nexport * from './lib/Logger';\nexport * from './lib/LoggerLevel';\nexport * from './lib/LoggerStyle';\nexport * from './lib/LoggerTimestamp';\n\ndeclare module '@sapphire/framework' {\n\texport interface ClientLoggerOptions extends LoggerOptions {}\n\texport interface Container {\n\t\ttransporters: Collection<LogLevel, LoggerTransport>;\n\t}\n}\n\n/**\n * The [@sapphire/plugin-logger](https://github.com/sapphiredev/plugins/blob/main/packages/logger) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '4.1.0-next.c2464a5';\n"]}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;AAkBO,IAAM,OAAkB,GAAA","file":"index.cjs","sourcesContent":["import type { LoggerOptions } from './lib/Logger';\n\nexport * from './lib/Logger';\nexport * from './lib/LoggerLevel';\nexport * from './lib/LoggerStyle';\nexport * from './lib/LoggerTimestamp';\n\ndeclare module '@sapphire/framework' {\n\texport interface ClientLoggerOptions extends LoggerOptions {}\n}\n\n/**\n * The [@sapphire/plugin-logger](https://github.com/sapphiredev/plugins/blob/main/packages/logger) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '4.1.0-next.fb8af18';\n"]}
@@ -1,5 +1,4 @@
1
- import { Collection } from 'discord.js';
2
- import { LogLevel, Logger as Logger$1 } from '@sapphire/framework';
1
+ import { Logger as Logger$1, LogLevel } from '@sapphire/framework';
3
2
  import * as Colorette from 'colorette';
4
3
  import { Timestamp } from '@sapphire/timestamp';
5
4
 
@@ -231,17 +230,6 @@ interface LoggerLevelOptions {
231
230
  message?: LoggerStyleResolvable | null;
232
231
  }
233
232
 
234
- declare class LoggerTransport {
235
- fileName: string;
236
- loglevel: LogLevel;
237
- constructor(options: TransporterOption);
238
- transport(message: string): Promise<void>;
239
- }
240
- interface TransporterOption {
241
- file: string;
242
- loglevel: LogLevel;
243
- }
244
-
245
233
  /**
246
234
  * The logger class.
247
235
  * @since 1.0.0
@@ -337,11 +325,6 @@ interface LoggerOptions {
337
325
  * @default 0
338
326
  */
339
327
  depth?: number;
340
- /**
341
- * The transporter options
342
- * @since 4.1.0
343
- */
344
- transports?: TransporterOption[];
345
328
  }
346
329
  /**
347
330
  * The logger format options.
@@ -388,9 +371,6 @@ interface LoggerFormatOptions {
388
371
  declare module '@sapphire/framework' {
389
372
  interface ClientLoggerOptions extends LoggerOptions {
390
373
  }
391
- interface Container {
392
- transporters: Collection<LogLevel, LoggerTransport>;
393
- }
394
374
  }
395
375
  /**
396
376
  * The [@sapphire/plugin-logger](https://github.com/sapphiredev/plugins/blob/main/packages/logger) version that you are currently using.
@@ -5,7 +5,6 @@ var colorette = require('colorette');
5
5
  var console = require('console');
6
6
  var util = require('util');
7
7
  var LoggerLevel_cjs = require('./LoggerLevel.cjs');
8
- var LoggerTransport_cjs = require('./LoggerTransport.cjs');
9
8
 
10
9
  var __defProp = Object.defineProperty;
11
10
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -38,17 +37,6 @@ var _Logger = class _Logger extends framework.Logger {
38
37
  this.formats = _Logger.createFormatMap(options.format, options.defaultFormat);
39
38
  this.join = options.join ?? " ";
40
39
  this.depth = options.depth ?? 0;
41
- if (options.transports) {
42
- for (const transport of options.transports) {
43
- framework.container.transporters.set(
44
- transport.loglevel,
45
- new LoggerTransport_cjs.LoggerTransport({
46
- file: transport.file,
47
- loglevel: transport.loglevel
48
- })
49
- );
50
- }
51
- }
52
40
  }
53
41
  /**
54
42
  * Writes the log message given a level and the value(s).
@@ -60,10 +48,6 @@ var _Logger = class _Logger extends framework.Logger {
60
48
  const method = this.levels.get(level) ?? "log";
61
49
  const formatter = this.formats.get(level) ?? this.formats.get(framework.LogLevel.None);
62
50
  this.console[method](formatter.run(this.preprocess(values)));
63
- const transporter = framework.container.transporters.get(level);
64
- if (transporter) {
65
- void transporter.transport(formatter.run(this.preprocess(values)));
66
- }
67
51
  }
68
52
  /**
69
53
  * Pre-processes an array of values.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/Logger.ts"],"names":["BuiltinLogger","LogLevel","Console","container","LoggerTransport","isColorSupported","inspect","gray","magenta","cyan","yellow","red","bgRed","white","LoggerLevel"],"mappings":";;;;;;;;;;;;;AAWO,IAAM,OAAA,GAAN,MAAM,OAAA,SAAeA,gBAAc,CAAA;AAAA,EAyBlC,WAAA,CAAY,OAAyB,GAAA,EAAI,EAAA;AAC/C,IAAM,KAAA,CAAA,OAAA,CAAQ,KAAS,IAAAC,kBAAA,CAAS,IAAI,CAAA,CAAA;AArBrC;AAAA;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;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AA,GAAO,EAAE,GAAI,QAAS,CAAA,SAAA,IAAa,EAAC,EAAI,KAAM,EAAA;AAAA,MACvF,KAAA,EAAO,IAAK,CAAA,MAAA,GAAS,CAAG,EAAA,KAAA,CAAM,IAAK,CAAA,MAAA,CAAO,CAAG,EAAA,GAAG,CAAC,CAAC,CAAQ,GAAA,CAAA,GAAA,EAAA;AAAA,KAC1D,CAAA,CAAA;AAAA,GACF;AACD,CAAA,CAAA;AA1G0C,MAAA,CAAA,OAAA,EAAA,QAAA,CAAA,CAAA;AAAnC,IAAM,MAAN,GAAA","file":"Logger.cjs","sourcesContent":["import { Logger as BuiltinLogger, container, LogLevel, type LogMethods } from '@sapphire/framework';\nimport { bgRed, cyan, gray, isColorSupported, magenta, red, white, yellow, type Color } from 'colorette';\nimport { Console } from 'console';\nimport { inspect, type InspectOptions } from 'util';\nimport { LoggerLevel, type LoggerLevelOptions } from './LoggerLevel';\nimport { LoggerTransport, type TransporterOption } from './LoggerTransport';\n\n/**\n * The logger class.\n * @since 1.0.0\n */\nexport class Logger extends BuiltinLogger {\n\t/**\n\t * The console this writes to.\n\t * @since 1.0.0\n\t */\n\tpublic readonly console: Console;\n\n\t/**\n\t * The formats supported by the logger.\n\t * @since 1.0.0\n\t */\n\tpublic readonly formats: Map<LogLevel, LoggerLevel>;\n\n\t/**\n\t * The string `write` will join values by.\n\t * @since 1.0.0\n\t */\n\tpublic readonly join: string;\n\n\t/**\n\t * The inspect depth when logging objects.\n\t * @since 1.0.0\n\t */\n\tpublic readonly depth: number;\n\n\tpublic constructor(options: LoggerOptions = {}) {\n\t\tsuper(options.level ?? LogLevel.Info);\n\n\t\tthis.console = new Console(options.stdout ?? process.stdout, options.stderr ?? process.stderr);\n\t\tthis.formats = Logger.createFormatMap(options.format, options.defaultFormat);\n\t\tthis.join = options.join ?? ' ';\n\t\tthis.depth = options.depth ?? 0;\n\n\t\tif (options.transports) {\n\t\t\tfor (const transport of options.transports) {\n\t\t\t\tcontainer.transporters.set(\n\t\t\t\t\ttransport.loglevel,\n\t\t\t\t\tnew LoggerTransport({\n\t\t\t\t\t\tfile: transport.file,\n\t\t\t\t\t\tloglevel: transport.loglevel\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Writes the log message given a level and the value(s).\n\t * @param level The log level.\n\t * @param values The values to log.\n\t */\n\tpublic override write(level: LogLevel, ...values: readonly unknown[]): void {\n\t\tif (level < this.level) return;\n\n\t\tconst method = this.levels.get(level) ?? 'log';\n\t\tconst formatter = this.formats.get(level) ?? this.formats.get(LogLevel.None)!;\n\n\t\tthis.console[method](formatter.run(this.preprocess(values)));\n\t\tconst transporter = container.transporters.get(level);\n\t\tif (transporter) {\n\t\t\tvoid transporter.transport(formatter.run(this.preprocess(values)));\n\t\t}\n\t}\n\n\t/**\n\t * Pre-processes an array of values.\n\t * @since 1.0.0\n\t * @param values The values to pre-process.\n\t */\n\tprotected preprocess(values: readonly unknown[]) {\n\t\tconst inspectOptions: InspectOptions = { colors: isColorSupported, depth: this.depth };\n\t\treturn values.map((value) => (typeof value === 'string' ? value : inspect(value, inspectOptions))).join(this.join);\n\t}\n\n\tprivate get levels() {\n\t\treturn Reflect.get(BuiltinLogger, 'levels') as Map<LogLevel, LogMethods>;\n\t}\n\n\t/**\n\t * Gets whether or not colorette is enabled.\n\t * @since 1.0.0\n\t */\n\tpublic static get stylize() {\n\t\treturn isColorSupported;\n\t}\n\n\tprivate static createFormatMap(options: LoggerFormatOptions = {}, defaults: LoggerLevelOptions = options.none ?? {}) {\n\t\treturn new Map<LogLevel, LoggerLevel>([\n\t\t\t[LogLevel.Trace, Logger.ensureDefaultLevel(options.trace, defaults, gray, 'TRACE')],\n\t\t\t[LogLevel.Debug, Logger.ensureDefaultLevel(options.debug, defaults, magenta, 'DEBUG')],\n\t\t\t[LogLevel.Info, Logger.ensureDefaultLevel(options.info, defaults, cyan, 'INFO')],\n\t\t\t[LogLevel.Warn, Logger.ensureDefaultLevel(options.warn, defaults, yellow, 'WARN')],\n\t\t\t[LogLevel.Error, Logger.ensureDefaultLevel(options.error, defaults, red, 'ERROR')],\n\t\t\t[LogLevel.Fatal, Logger.ensureDefaultLevel(options.fatal, defaults, bgRed, 'FATAL')],\n\t\t\t[LogLevel.None, Logger.ensureDefaultLevel(options.none, defaults, white, '')]\n\t\t]);\n\t}\n\n\tprivate static ensureDefaultLevel(options: LoggerLevelOptions | undefined, defaults: LoggerLevelOptions, color: Color, name: string) {\n\t\tif (options) return new LoggerLevel(options);\n\t\treturn new LoggerLevel({\n\t\t\t...defaults,\n\t\t\ttimestamp: defaults.timestamp === null ? null : { ...(defaults.timestamp ?? {}), color },\n\t\t\tinfix: name.length ? `${color(name.padEnd(5, ' '))} - ` : ''\n\t\t});\n\t}\n}\n\n/**\n * The logger options.\n * @since 1.0.0\n */\nexport interface LoggerOptions {\n\t/**\n\t * A writable stream for the output logs.\n\t * @since 1.0.0\n\t * @default process.stdout\n\t */\n\tstdout?: NodeJS.WritableStream;\n\n\t/**\n\t * A writable stream for the error logs.\n\t * @since 1.0.0\n\t * @default process.stderr\n\t */\n\tstderr?: NodeJS.WritableStream;\n\n\t/**\n\t * The default options used to fill all the possible values for {@link LoggerOptions.format}.\n\t * @since 1.0.0\n\t * @default options.format.none ?? {}\n\t */\n\tdefaultFormat?: LoggerLevelOptions;\n\n\t/**\n\t * The options for each log level. LogLevel.None serves to set the default for all keys, where only\n\t * {@link LoggerTimestampOptions.timestamp} and {@link LoggerLevelOptions.prefix} would be overridden.\n\t * @since 1.0.0\n\t * @default {}\n\t */\n\tformat?: LoggerFormatOptions;\n\n\t/**\n\t * The minimum log level.\n\t * @since 1.0.0\n\t * @default LogLevel.Info\n\t */\n\tlevel?: LogLevel;\n\n\t/**\n\t * The string that joins different messages.\n\t * @since 1.0.0\n\t * @default ' '\n\t */\n\tjoin?: string;\n\n\t/**\n\t * The inspect depth when logging objects.\n\t * @since 1.0.0\n\t * @default 0\n\t */\n\tdepth?: number;\n\n\t/**\n\t * The transporter options\n\t * @since 4.1.0\n\t */\n\ttransports?: TransporterOption[];\n}\n\n/**\n * The logger format options.\n * @since 1.0.0\n */\nexport interface LoggerFormatOptions {\n\t/**\n\t * The logger options for the lowest log level, used when calling {@link ILogger.trace}.\n\t * @since 1.0.0\n\t */\n\ttrace?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the debug level, used when calling {@link ILogger.debug}.\n\t * @since 1.0.0\n\t */\n\tdebug?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the info level, used when calling {@link ILogger.info}.\n\t * @since 1.0.0\n\t */\n\tinfo?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the warning level, used when calling {@link ILogger.warn}.\n\t * @since 1.0.0\n\t */\n\twarn?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the error level, used when calling {@link ILogger.error}.\n\t * @since 1.0.0\n\t */\n\terror?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the critical level, used when calling {@link ILogger.fatal}.\n\t * @since 1.0.0\n\t */\n\tfatal?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for an unknown or uncategorised level.\n\t * @since 1.0.0\n\t */\n\tnone?: LoggerLevelOptions;\n}\n"]}
1
+ {"version":3,"sources":["../../../src/lib/Logger.ts"],"names":["BuiltinLogger","LogLevel","Console","isColorSupported","inspect","gray","magenta","cyan","yellow","red","bgRed","white","LoggerLevel"],"mappings":";;;;;;;;;;;;AAUO,IAAM,OAAA,GAAN,MAAM,OAAA,SAAeA,gBAAc,CAAA;AAAA,EAyBlC,WAAA,CAAY,OAAyB,GAAA,EAAI,EAAA;AAC/C,IAAM,KAAA,CAAA,OAAA,CAAQ,KAAS,IAAAC,kBAAA,CAAS,IAAI,CAAA,CAAA;AArBrC;AAAA;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;AAMhB;AAAA;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA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aAAK,EAAA,OAAO,CAAC,CAAA;AAAA,MACjF,CAACR,kBAAS,CAAA,KAAA,EAAO,OAAO,CAAA,kBAAA,CAAmB,QAAQ,KAAO,EAAA,QAAA,EAAUS,eAAO,EAAA,OAAO,CAAC,CAAA;AAAA,MACnF,CAACT,kBAAS,CAAA,IAAA,EAAM,OAAO,CAAA,kBAAA,CAAmB,QAAQ,IAAM,EAAA,QAAA,EAAUU,eAAO,EAAA,EAAE,CAAC,CAAA;AAAA,KAC5E,CAAA,CAAA;AAAA,GACF;AAAA,EAEA,OAAe,kBAAA,CAAmB,OAAyC,EAAA,QAAA,EAA8B,OAAc,IAAc,EAAA;AACpI,IAAA,IAAI,OAAS,EAAA,OAAO,IAAIC,2BAAA,CAAY,OAAO,CAAA,CAAA;AAC3C,IAAA,OAAO,IAAIA,2BAAY,CAAA;AAAA,MACtB,GAAG,QAAA;AAAA,MACH,SAAA,EAAW,QAAS,CAAA,SAAA,KAAc,IAAO,GAAA,IAAA,GAAO,EAAE,GAAI,QAAS,CAAA,SAAA,IAAa,EAAC,EAAI,KAAM,EAAA;AAAA,MACvF,KAAA,EAAO,IAAK,CAAA,MAAA,GAAS,CAAG,EAAA,KAAA,CAAM,IAAK,CAAA,MAAA,CAAO,CAAG,EAAA,GAAG,CAAC,CAAC,CAAQ,GAAA,CAAA,GAAA,EAAA;AAAA,KAC1D,CAAA,CAAA;AAAA,GACF;AACD,CAAA,CAAA;AA1F0C,MAAA,CAAA,OAAA,EAAA,QAAA,CAAA,CAAA;AAAnC,IAAM,MAAN,GAAA","file":"Logger.cjs","sourcesContent":["import { Logger as BuiltinLogger, LogLevel, type LogMethods } from '@sapphire/framework';\nimport { bgRed, cyan, gray, isColorSupported, magenta, red, white, yellow, type Color } from 'colorette';\nimport { Console } from 'console';\nimport { inspect, type InspectOptions } from 'util';\nimport { LoggerLevel, type LoggerLevelOptions } from './LoggerLevel';\n\n/**\n * The logger class.\n * @since 1.0.0\n */\nexport class Logger extends BuiltinLogger {\n\t/**\n\t * The console this writes to.\n\t * @since 1.0.0\n\t */\n\tpublic readonly console: Console;\n\n\t/**\n\t * The formats supported by the logger.\n\t * @since 1.0.0\n\t */\n\tpublic readonly formats: Map<LogLevel, LoggerLevel>;\n\n\t/**\n\t * The string `write` will join values by.\n\t * @since 1.0.0\n\t */\n\tpublic readonly join: string;\n\n\t/**\n\t * The inspect depth when logging objects.\n\t * @since 1.0.0\n\t */\n\tpublic readonly depth: number;\n\n\tpublic constructor(options: LoggerOptions = {}) {\n\t\tsuper(options.level ?? LogLevel.Info);\n\n\t\tthis.console = new Console(options.stdout ?? process.stdout, options.stderr ?? process.stderr);\n\t\tthis.formats = Logger.createFormatMap(options.format, options.defaultFormat);\n\t\tthis.join = options.join ?? ' ';\n\t\tthis.depth = options.depth ?? 0;\n\t}\n\n\t/**\n\t * Writes the log message given a level and the value(s).\n\t * @param level The log level.\n\t * @param values The values to log.\n\t */\n\tpublic override write(level: LogLevel, ...values: readonly unknown[]): void {\n\t\tif (level < this.level) return;\n\n\t\tconst method = this.levels.get(level) ?? 'log';\n\t\tconst formatter = this.formats.get(level) ?? this.formats.get(LogLevel.None)!;\n\n\t\tthis.console[method](formatter.run(this.preprocess(values)));\n\t}\n\n\t/**\n\t * Pre-processes an array of values.\n\t * @since 1.0.0\n\t * @param values The values to pre-process.\n\t */\n\tprotected preprocess(values: readonly unknown[]) {\n\t\tconst inspectOptions: InspectOptions = { colors: isColorSupported, depth: this.depth };\n\t\treturn values.map((value) => (typeof value === 'string' ? value : inspect(value, inspectOptions))).join(this.join);\n\t}\n\n\tprivate get levels() {\n\t\treturn Reflect.get(BuiltinLogger, 'levels') as Map<LogLevel, LogMethods>;\n\t}\n\n\t/**\n\t * Gets whether or not colorette is enabled.\n\t * @since 1.0.0\n\t */\n\tpublic static get stylize() {\n\t\treturn isColorSupported;\n\t}\n\n\tprivate static createFormatMap(options: LoggerFormatOptions = {}, defaults: LoggerLevelOptions = options.none ?? {}) {\n\t\treturn new Map<LogLevel, LoggerLevel>([\n\t\t\t[LogLevel.Trace, Logger.ensureDefaultLevel(options.trace, defaults, gray, 'TRACE')],\n\t\t\t[LogLevel.Debug, Logger.ensureDefaultLevel(options.debug, defaults, magenta, 'DEBUG')],\n\t\t\t[LogLevel.Info, Logger.ensureDefaultLevel(options.info, defaults, cyan, 'INFO')],\n\t\t\t[LogLevel.Warn, Logger.ensureDefaultLevel(options.warn, defaults, yellow, 'WARN')],\n\t\t\t[LogLevel.Error, Logger.ensureDefaultLevel(options.error, defaults, red, 'ERROR')],\n\t\t\t[LogLevel.Fatal, Logger.ensureDefaultLevel(options.fatal, defaults, bgRed, 'FATAL')],\n\t\t\t[LogLevel.None, Logger.ensureDefaultLevel(options.none, defaults, white, '')]\n\t\t]);\n\t}\n\n\tprivate static ensureDefaultLevel(options: LoggerLevelOptions | undefined, defaults: LoggerLevelOptions, color: Color, name: string) {\n\t\tif (options) return new LoggerLevel(options);\n\t\treturn new LoggerLevel({\n\t\t\t...defaults,\n\t\t\ttimestamp: defaults.timestamp === null ? null : { ...(defaults.timestamp ?? {}), color },\n\t\t\tinfix: name.length ? `${color(name.padEnd(5, ' '))} - ` : ''\n\t\t});\n\t}\n}\n\n/**\n * The logger options.\n * @since 1.0.0\n */\nexport interface LoggerOptions {\n\t/**\n\t * A writable stream for the output logs.\n\t * @since 1.0.0\n\t * @default process.stdout\n\t */\n\tstdout?: NodeJS.WritableStream;\n\n\t/**\n\t * A writable stream for the error logs.\n\t * @since 1.0.0\n\t * @default process.stderr\n\t */\n\tstderr?: NodeJS.WritableStream;\n\n\t/**\n\t * The default options used to fill all the possible values for {@link LoggerOptions.format}.\n\t * @since 1.0.0\n\t * @default options.format.none ?? {}\n\t */\n\tdefaultFormat?: LoggerLevelOptions;\n\n\t/**\n\t * The options for each log level. LogLevel.None serves to set the default for all keys, where only\n\t * {@link LoggerTimestampOptions.timestamp} and {@link LoggerLevelOptions.prefix} would be overridden.\n\t * @since 1.0.0\n\t * @default {}\n\t */\n\tformat?: LoggerFormatOptions;\n\n\t/**\n\t * The minimum log level.\n\t * @since 1.0.0\n\t * @default LogLevel.Info\n\t */\n\tlevel?: LogLevel;\n\n\t/**\n\t * The string that joins different messages.\n\t * @since 1.0.0\n\t * @default ' '\n\t */\n\tjoin?: string;\n\n\t/**\n\t * The inspect depth when logging objects.\n\t * @since 1.0.0\n\t * @default 0\n\t */\n\tdepth?: number;\n}\n\n/**\n * The logger format options.\n * @since 1.0.0\n */\nexport interface LoggerFormatOptions {\n\t/**\n\t * The logger options for the lowest log level, used when calling {@link ILogger.trace}.\n\t * @since 1.0.0\n\t */\n\ttrace?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the debug level, used when calling {@link ILogger.debug}.\n\t * @since 1.0.0\n\t */\n\tdebug?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the info level, used when calling {@link ILogger.info}.\n\t * @since 1.0.0\n\t */\n\tinfo?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the warning level, used when calling {@link ILogger.warn}.\n\t * @since 1.0.0\n\t */\n\twarn?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the error level, used when calling {@link ILogger.error}.\n\t * @since 1.0.0\n\t */\n\terror?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the critical level, used when calling {@link ILogger.fatal}.\n\t * @since 1.0.0\n\t */\n\tfatal?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for an unknown or uncategorised level.\n\t * @since 1.0.0\n\t */\n\tnone?: LoggerLevelOptions;\n}\n"]}
@@ -1,5 +1,4 @@
1
- import { Collection } from 'discord.js';
2
- import { LogLevel, Logger as Logger$1 } from '@sapphire/framework';
1
+ import { Logger as Logger$1, LogLevel } from '@sapphire/framework';
3
2
  import * as Colorette from 'colorette';
4
3
  import { Timestamp } from '@sapphire/timestamp';
5
4
 
@@ -231,17 +230,6 @@ interface LoggerLevelOptions {
231
230
  message?: LoggerStyleResolvable | null;
232
231
  }
233
232
 
234
- declare class LoggerTransport {
235
- fileName: string;
236
- loglevel: LogLevel;
237
- constructor(options: TransporterOption);
238
- transport(message: string): Promise<void>;
239
- }
240
- interface TransporterOption {
241
- file: string;
242
- loglevel: LogLevel;
243
- }
244
-
245
233
  /**
246
234
  * The logger class.
247
235
  * @since 1.0.0
@@ -337,11 +325,6 @@ interface LoggerOptions {
337
325
  * @default 0
338
326
  */
339
327
  depth?: number;
340
- /**
341
- * The transporter options
342
- * @since 4.1.0
343
- */
344
- transports?: TransporterOption[];
345
328
  }
346
329
  /**
347
330
  * The logger format options.
@@ -388,9 +371,6 @@ interface LoggerFormatOptions {
388
371
  declare module '@sapphire/framework' {
389
372
  interface ClientLoggerOptions extends LoggerOptions {
390
373
  }
391
- interface Container {
392
- transporters: Collection<LogLevel, LoggerTransport>;
393
- }
394
374
  }
395
375
  /**
396
376
  * The [@sapphire/plugin-logger](https://github.com/sapphiredev/plugins/blob/main/packages/logger) version that you are currently using.
@@ -4,7 +4,7 @@ export * from './lib/LoggerLevel.mjs';
4
4
  export * from './lib/LoggerStyle.mjs';
5
5
  export * from './lib/LoggerTimestamp.mjs';
6
6
 
7
- var version = "4.1.0-next.c2464a5";
7
+ var version = "4.1.0-next.fb8af18";
8
8
 
9
9
  export { version };
10
10
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAwBO,IAAM,OAAkB,GAAA","file":"index.mjs","sourcesContent":["import type { Collection } from 'discord.js';\nimport type { LoggerOptions } from './lib/Logger';\nimport type { LoggerTransport } from './lib/LoggerTransport';\nimport type { LogLevel } from '@sapphire/framework';\n\nexport * from './lib/Logger';\nexport * from './lib/LoggerLevel';\nexport * from './lib/LoggerStyle';\nexport * from './lib/LoggerTimestamp';\n\ndeclare module '@sapphire/framework' {\n\texport interface ClientLoggerOptions extends LoggerOptions {}\n\texport interface Container {\n\t\ttransporters: Collection<LogLevel, LoggerTransport>;\n\t}\n}\n\n/**\n * The [@sapphire/plugin-logger](https://github.com/sapphiredev/plugins/blob/main/packages/logger) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '4.1.0-next.c2464a5';\n"]}
1
+ {"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;AAkBO,IAAM,OAAkB,GAAA","file":"index.mjs","sourcesContent":["import type { LoggerOptions } from './lib/Logger';\n\nexport * from './lib/Logger';\nexport * from './lib/LoggerLevel';\nexport * from './lib/LoggerStyle';\nexport * from './lib/LoggerTimestamp';\n\ndeclare module '@sapphire/framework' {\n\texport interface ClientLoggerOptions extends LoggerOptions {}\n}\n\n/**\n * The [@sapphire/plugin-logger](https://github.com/sapphiredev/plugins/blob/main/packages/logger) version that you are currently using.\n * An example use of this is showing it of in a bot information command.\n *\n * Note to Sapphire developers: This needs to explicitly be `string` so it is not typed as the string that gets replaced by esbuild\n */\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '4.1.0-next.fb8af18';\n"]}
@@ -1,10 +1,9 @@
1
1
  import { __name, __publicField } from '../chunk-2JTKI4GS.mjs';
2
- import { Logger as Logger$1, LogLevel, container } from '@sapphire/framework';
2
+ import { Logger as Logger$1, LogLevel } from '@sapphire/framework';
3
3
  import { isColorSupported, gray, magenta, cyan, yellow, red, bgRed, white } from 'colorette';
4
4
  import { Console } from 'console';
5
5
  import { inspect } from 'util';
6
6
  import { LoggerLevel } from './LoggerLevel.mjs';
7
- import { LoggerTransport } from './LoggerTransport.mjs';
8
7
 
9
8
  var _Logger = class _Logger extends Logger$1 {
10
9
  constructor(options = {}) {
@@ -33,17 +32,6 @@ var _Logger = class _Logger extends Logger$1 {
33
32
  this.formats = _Logger.createFormatMap(options.format, options.defaultFormat);
34
33
  this.join = options.join ?? " ";
35
34
  this.depth = options.depth ?? 0;
36
- if (options.transports) {
37
- for (const transport of options.transports) {
38
- container.transporters.set(
39
- transport.loglevel,
40
- new LoggerTransport({
41
- file: transport.file,
42
- loglevel: transport.loglevel
43
- })
44
- );
45
- }
46
- }
47
35
  }
48
36
  /**
49
37
  * Writes the log message given a level and the value(s).
@@ -55,10 +43,6 @@ var _Logger = class _Logger extends Logger$1 {
55
43
  const method = this.levels.get(level) ?? "log";
56
44
  const formatter = this.formats.get(level) ?? this.formats.get(LogLevel.None);
57
45
  this.console[method](formatter.run(this.preprocess(values)));
58
- const transporter = container.transporters.get(level);
59
- if (transporter) {
60
- void transporter.transport(formatter.run(this.preprocess(values)));
61
- }
62
46
  }
63
47
  /**
64
48
  * Pre-processes an array of values.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/lib/Logger.ts"],"names":["BuiltinLogger"],"mappings":";;;;;;;;AAWO,IAAM,OAAA,GAAN,MAAM,OAAA,SAAeA,QAAc,CAAA;AAAA,EAyBlC,WAAA,CAAY,OAAyB,GAAA,EAAI,EAAA;AAC/C,IAAM,KAAA,CAAA,OAAA,CAAQ,KAAS,IAAA,QAAA,CAAS,IAAI,CAAA,CAAA;AArBrC;AAAA;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;AAMhB;AAAA;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;AAMhB;AAAA;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,MAAA,CAAA,CAAA;AAMhB;AAAA;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,OAAA,CAAA,CAAA;AAKf,IAAK,IAAA,CAAA,OAAA,GAAU,IAAI,OAAA,CAAQ,OAAQ,CAAA,MAAA,IAAU,QAAQ,MAAQ,EAAA,OAAA,CAAQ,MAAU,IAAA,OAAA,CAAQ,MAAM,CAAA,CAAA;AAC7F,IAAA,IAAA,CAAK,UAAU,OAAO,CAAA,eAAA,CAAgB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,EAAU,MAAQ,EAAA,MAAM,CAAC,CAAA;AAAA,MACjF,CAAC,QAAS,CAAA,KAAA,EAAO,OAAO,CAAA,kBAAA,CAAmB,QAAQ,KAAO,EAAA,QAAA,EAAU,GAAK,EAAA,OAAO,CAAC,CAAA;AAAA,MACjF,CAAC,QAAS,CAAA,KAAA,EAAO,OAAO,CAAA,kBAAA,CAAmB,QAAQ,KAAO,EAAA,QAAA,EAAU,KAAO,EAAA,OAAO,CAAC,CAAA;AAAA,MACnF,CAAC,QAAS,CAAA,IAAA,EAAM,OAAO,CAAA,kBAAA,CAAmB,QAAQ,IAAM,EAAA,QAAA,EAAU,KAAO,EAAA,EAAE,CAAC,CAAA;AAAA,KAC5E,CAAA,CAAA;AAAA,GACF;AAAA,EAEA,OAAe,kBAAA,CAAmB,OAAyC,EAAA,QAAA,EAA8B,OAAc,IAAc,EAAA;AACpI,IAAA,IAAI,OAAS,EAAA,OAAO,IAAI,WAAA,CAAY,OAAO,CAAA,CAAA;AAC3C,IAAA,OAAO,IAAI,WAAY,CAAA;AAAA,MACtB,GAAG,QAAA;AAAA,MACH,SAAA,EAAW,QAAS,CAAA,SAAA,KAAc,IAAO,GAAA,IAAA,GAAO,EAAE,GAAI,QAAS,CAAA,SAAA,IAAa,EAAC,EAAI,KAAM,EAAA;AAAA,MACvF,KAAA,EAAO,IAAK,CAAA,MAAA,GAAS,CAAG,EAAA,KAAA,CAAM,IAAK,CAAA,MAAA,CAAO,CAAG,EAAA,GAAG,CAAC,CAAC,CAAQ,GAAA,CAAA,GAAA,EAAA;AAAA,KAC1D,CAAA,CAAA;AAAA,GACF;AACD,CAAA,CAAA;AA1G0C,MAAA,CAAA,OAAA,EAAA,QAAA,CAAA,CAAA;AAAnC,IAAM,MAAN,GAAA","file":"Logger.mjs","sourcesContent":["import { Logger as BuiltinLogger, container, LogLevel, type LogMethods } from '@sapphire/framework';\nimport { bgRed, cyan, gray, isColorSupported, magenta, red, white, yellow, type Color } from 'colorette';\nimport { Console } from 'console';\nimport { inspect, type InspectOptions } from 'util';\nimport { LoggerLevel, type LoggerLevelOptions } from './LoggerLevel';\nimport { LoggerTransport, type TransporterOption } from './LoggerTransport';\n\n/**\n * The logger class.\n * @since 1.0.0\n */\nexport class Logger extends BuiltinLogger {\n\t/**\n\t * The console this writes to.\n\t * @since 1.0.0\n\t */\n\tpublic readonly console: Console;\n\n\t/**\n\t * The formats supported by the logger.\n\t * @since 1.0.0\n\t */\n\tpublic readonly formats: Map<LogLevel, LoggerLevel>;\n\n\t/**\n\t * The string `write` will join values by.\n\t * @since 1.0.0\n\t */\n\tpublic readonly join: string;\n\n\t/**\n\t * The inspect depth when logging objects.\n\t * @since 1.0.0\n\t */\n\tpublic readonly depth: number;\n\n\tpublic constructor(options: LoggerOptions = {}) {\n\t\tsuper(options.level ?? LogLevel.Info);\n\n\t\tthis.console = new Console(options.stdout ?? process.stdout, options.stderr ?? process.stderr);\n\t\tthis.formats = Logger.createFormatMap(options.format, options.defaultFormat);\n\t\tthis.join = options.join ?? ' ';\n\t\tthis.depth = options.depth ?? 0;\n\n\t\tif (options.transports) {\n\t\t\tfor (const transport of options.transports) {\n\t\t\t\tcontainer.transporters.set(\n\t\t\t\t\ttransport.loglevel,\n\t\t\t\t\tnew LoggerTransport({\n\t\t\t\t\t\tfile: transport.file,\n\t\t\t\t\t\tloglevel: transport.loglevel\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Writes the log message given a level and the value(s).\n\t * @param level The log level.\n\t * @param values The values to log.\n\t */\n\tpublic override write(level: LogLevel, ...values: readonly unknown[]): void {\n\t\tif (level < this.level) return;\n\n\t\tconst method = this.levels.get(level) ?? 'log';\n\t\tconst formatter = this.formats.get(level) ?? this.formats.get(LogLevel.None)!;\n\n\t\tthis.console[method](formatter.run(this.preprocess(values)));\n\t\tconst transporter = container.transporters.get(level);\n\t\tif (transporter) {\n\t\t\tvoid transporter.transport(formatter.run(this.preprocess(values)));\n\t\t}\n\t}\n\n\t/**\n\t * Pre-processes an array of values.\n\t * @since 1.0.0\n\t * @param values The values to pre-process.\n\t */\n\tprotected preprocess(values: readonly unknown[]) {\n\t\tconst inspectOptions: InspectOptions = { colors: isColorSupported, depth: this.depth };\n\t\treturn values.map((value) => (typeof value === 'string' ? value : inspect(value, inspectOptions))).join(this.join);\n\t}\n\n\tprivate get levels() {\n\t\treturn Reflect.get(BuiltinLogger, 'levels') as Map<LogLevel, LogMethods>;\n\t}\n\n\t/**\n\t * Gets whether or not colorette is enabled.\n\t * @since 1.0.0\n\t */\n\tpublic static get stylize() {\n\t\treturn isColorSupported;\n\t}\n\n\tprivate static createFormatMap(options: LoggerFormatOptions = {}, defaults: LoggerLevelOptions = options.none ?? {}) {\n\t\treturn new Map<LogLevel, LoggerLevel>([\n\t\t\t[LogLevel.Trace, Logger.ensureDefaultLevel(options.trace, defaults, gray, 'TRACE')],\n\t\t\t[LogLevel.Debug, Logger.ensureDefaultLevel(options.debug, defaults, magenta, 'DEBUG')],\n\t\t\t[LogLevel.Info, Logger.ensureDefaultLevel(options.info, defaults, cyan, 'INFO')],\n\t\t\t[LogLevel.Warn, Logger.ensureDefaultLevel(options.warn, defaults, yellow, 'WARN')],\n\t\t\t[LogLevel.Error, Logger.ensureDefaultLevel(options.error, defaults, red, 'ERROR')],\n\t\t\t[LogLevel.Fatal, Logger.ensureDefaultLevel(options.fatal, defaults, bgRed, 'FATAL')],\n\t\t\t[LogLevel.None, Logger.ensureDefaultLevel(options.none, defaults, white, '')]\n\t\t]);\n\t}\n\n\tprivate static ensureDefaultLevel(options: LoggerLevelOptions | undefined, defaults: LoggerLevelOptions, color: Color, name: string) {\n\t\tif (options) return new LoggerLevel(options);\n\t\treturn new LoggerLevel({\n\t\t\t...defaults,\n\t\t\ttimestamp: defaults.timestamp === null ? null : { ...(defaults.timestamp ?? {}), color },\n\t\t\tinfix: name.length ? `${color(name.padEnd(5, ' '))} - ` : ''\n\t\t});\n\t}\n}\n\n/**\n * The logger options.\n * @since 1.0.0\n */\nexport interface LoggerOptions {\n\t/**\n\t * A writable stream for the output logs.\n\t * @since 1.0.0\n\t * @default process.stdout\n\t */\n\tstdout?: NodeJS.WritableStream;\n\n\t/**\n\t * A writable stream for the error logs.\n\t * @since 1.0.0\n\t * @default process.stderr\n\t */\n\tstderr?: NodeJS.WritableStream;\n\n\t/**\n\t * The default options used to fill all the possible values for {@link LoggerOptions.format}.\n\t * @since 1.0.0\n\t * @default options.format.none ?? {}\n\t */\n\tdefaultFormat?: LoggerLevelOptions;\n\n\t/**\n\t * The options for each log level. LogLevel.None serves to set the default for all keys, where only\n\t * {@link LoggerTimestampOptions.timestamp} and {@link LoggerLevelOptions.prefix} would be overridden.\n\t * @since 1.0.0\n\t * @default {}\n\t */\n\tformat?: LoggerFormatOptions;\n\n\t/**\n\t * The minimum log level.\n\t * @since 1.0.0\n\t * @default LogLevel.Info\n\t */\n\tlevel?: LogLevel;\n\n\t/**\n\t * The string that joins different messages.\n\t * @since 1.0.0\n\t * @default ' '\n\t */\n\tjoin?: string;\n\n\t/**\n\t * The inspect depth when logging objects.\n\t * @since 1.0.0\n\t * @default 0\n\t */\n\tdepth?: number;\n\n\t/**\n\t * The transporter options\n\t * @since 4.1.0\n\t */\n\ttransports?: TransporterOption[];\n}\n\n/**\n * The logger format options.\n * @since 1.0.0\n */\nexport interface LoggerFormatOptions {\n\t/**\n\t * The logger options for the lowest log level, used when calling {@link ILogger.trace}.\n\t * @since 1.0.0\n\t */\n\ttrace?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the debug level, used when calling {@link ILogger.debug}.\n\t * @since 1.0.0\n\t */\n\tdebug?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the info level, used when calling {@link ILogger.info}.\n\t * @since 1.0.0\n\t */\n\tinfo?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the warning level, used when calling {@link ILogger.warn}.\n\t * @since 1.0.0\n\t */\n\twarn?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the error level, used when calling {@link ILogger.error}.\n\t * @since 1.0.0\n\t */\n\terror?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the critical level, used when calling {@link ILogger.fatal}.\n\t * @since 1.0.0\n\t */\n\tfatal?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for an unknown or uncategorised level.\n\t * @since 1.0.0\n\t */\n\tnone?: LoggerLevelOptions;\n}\n"]}
1
+ {"version":3,"sources":["../../../src/lib/Logger.ts"],"names":["BuiltinLogger"],"mappings":";;;;;;;AAUO,IAAM,OAAA,GAAN,MAAM,OAAA,SAAeA,QAAc,CAAA;AAAA,EAyBlC,WAAA,CAAY,OAAyB,GAAA,EAAI,EAAA;AAC/C,IAAM,KAAA,CAAA,OAAA,CAAQ,KAAS,IAAA,QAAA,CAAS,IAAI,CAAA,CAAA;AArBrC;AAAA;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;AAMhB;AAAA;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,SAAA,CAAA,CAAA;AAMhB;AAAA;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,MAAA,CAAA,CAAA;AAMhB;AAAA;AAAA;AAAA;AAAA,IAAgB,aAAA,CAAA,IAAA,EAAA,OAAA,CAAA,CAAA;AAKf,IAAK,IAAA,CAAA,OAAA,GAAU,IAAI,OAAA,CAAQ,OAAQ,CAAA,MAAA,IAAU,QAAQ,MAAQ,EAAA,OAAA,CAAQ,MAAU,IAAA,OAAA,CAAQ,MAAM,CAAA,CAAA;AAC7F,IAAA,IAAA,CAAK,UAAU,OAAO,CAAA,eAAA,CAAgB,OAAQ,CAAA,MAAA,EAAQ,QAAQ,aAAa,CAAA,CAAA;AAC3E,IAAK,IAAA,CAAA,IAAA,GAAO,QAAQ,IAAQ,IAAA,GAAA,CAAA;AAC5B,IAAK,IAAA,CAAA,KAAA,GAAQ,QAAQ,KAAS,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A,IAAA,GAAO,EAAE,GAAI,QAAS,CAAA,SAAA,IAAa,EAAC,EAAI,KAAM,EAAA;AAAA,MACvF,KAAA,EAAO,IAAK,CAAA,MAAA,GAAS,CAAG,EAAA,KAAA,CAAM,IAAK,CAAA,MAAA,CAAO,CAAG,EAAA,GAAG,CAAC,CAAC,CAAQ,GAAA,CAAA,GAAA,EAAA;AAAA,KAC1D,CAAA,CAAA;AAAA,GACF;AACD,CAAA,CAAA;AA1F0C,MAAA,CAAA,OAAA,EAAA,QAAA,CAAA,CAAA;AAAnC,IAAM,MAAN,GAAA","file":"Logger.mjs","sourcesContent":["import { Logger as BuiltinLogger, LogLevel, type LogMethods } from '@sapphire/framework';\nimport { bgRed, cyan, gray, isColorSupported, magenta, red, white, yellow, type Color } from 'colorette';\nimport { Console } from 'console';\nimport { inspect, type InspectOptions } from 'util';\nimport { LoggerLevel, type LoggerLevelOptions } from './LoggerLevel';\n\n/**\n * The logger class.\n * @since 1.0.0\n */\nexport class Logger extends BuiltinLogger {\n\t/**\n\t * The console this writes to.\n\t * @since 1.0.0\n\t */\n\tpublic readonly console: Console;\n\n\t/**\n\t * The formats supported by the logger.\n\t * @since 1.0.0\n\t */\n\tpublic readonly formats: Map<LogLevel, LoggerLevel>;\n\n\t/**\n\t * The string `write` will join values by.\n\t * @since 1.0.0\n\t */\n\tpublic readonly join: string;\n\n\t/**\n\t * The inspect depth when logging objects.\n\t * @since 1.0.0\n\t */\n\tpublic readonly depth: number;\n\n\tpublic constructor(options: LoggerOptions = {}) {\n\t\tsuper(options.level ?? LogLevel.Info);\n\n\t\tthis.console = new Console(options.stdout ?? process.stdout, options.stderr ?? process.stderr);\n\t\tthis.formats = Logger.createFormatMap(options.format, options.defaultFormat);\n\t\tthis.join = options.join ?? ' ';\n\t\tthis.depth = options.depth ?? 0;\n\t}\n\n\t/**\n\t * Writes the log message given a level and the value(s).\n\t * @param level The log level.\n\t * @param values The values to log.\n\t */\n\tpublic override write(level: LogLevel, ...values: readonly unknown[]): void {\n\t\tif (level < this.level) return;\n\n\t\tconst method = this.levels.get(level) ?? 'log';\n\t\tconst formatter = this.formats.get(level) ?? this.formats.get(LogLevel.None)!;\n\n\t\tthis.console[method](formatter.run(this.preprocess(values)));\n\t}\n\n\t/**\n\t * Pre-processes an array of values.\n\t * @since 1.0.0\n\t * @param values The values to pre-process.\n\t */\n\tprotected preprocess(values: readonly unknown[]) {\n\t\tconst inspectOptions: InspectOptions = { colors: isColorSupported, depth: this.depth };\n\t\treturn values.map((value) => (typeof value === 'string' ? value : inspect(value, inspectOptions))).join(this.join);\n\t}\n\n\tprivate get levels() {\n\t\treturn Reflect.get(BuiltinLogger, 'levels') as Map<LogLevel, LogMethods>;\n\t}\n\n\t/**\n\t * Gets whether or not colorette is enabled.\n\t * @since 1.0.0\n\t */\n\tpublic static get stylize() {\n\t\treturn isColorSupported;\n\t}\n\n\tprivate static createFormatMap(options: LoggerFormatOptions = {}, defaults: LoggerLevelOptions = options.none ?? {}) {\n\t\treturn new Map<LogLevel, LoggerLevel>([\n\t\t\t[LogLevel.Trace, Logger.ensureDefaultLevel(options.trace, defaults, gray, 'TRACE')],\n\t\t\t[LogLevel.Debug, Logger.ensureDefaultLevel(options.debug, defaults, magenta, 'DEBUG')],\n\t\t\t[LogLevel.Info, Logger.ensureDefaultLevel(options.info, defaults, cyan, 'INFO')],\n\t\t\t[LogLevel.Warn, Logger.ensureDefaultLevel(options.warn, defaults, yellow, 'WARN')],\n\t\t\t[LogLevel.Error, Logger.ensureDefaultLevel(options.error, defaults, red, 'ERROR')],\n\t\t\t[LogLevel.Fatal, Logger.ensureDefaultLevel(options.fatal, defaults, bgRed, 'FATAL')],\n\t\t\t[LogLevel.None, Logger.ensureDefaultLevel(options.none, defaults, white, '')]\n\t\t]);\n\t}\n\n\tprivate static ensureDefaultLevel(options: LoggerLevelOptions | undefined, defaults: LoggerLevelOptions, color: Color, name: string) {\n\t\tif (options) return new LoggerLevel(options);\n\t\treturn new LoggerLevel({\n\t\t\t...defaults,\n\t\t\ttimestamp: defaults.timestamp === null ? null : { ...(defaults.timestamp ?? {}), color },\n\t\t\tinfix: name.length ? `${color(name.padEnd(5, ' '))} - ` : ''\n\t\t});\n\t}\n}\n\n/**\n * The logger options.\n * @since 1.0.0\n */\nexport interface LoggerOptions {\n\t/**\n\t * A writable stream for the output logs.\n\t * @since 1.0.0\n\t * @default process.stdout\n\t */\n\tstdout?: NodeJS.WritableStream;\n\n\t/**\n\t * A writable stream for the error logs.\n\t * @since 1.0.0\n\t * @default process.stderr\n\t */\n\tstderr?: NodeJS.WritableStream;\n\n\t/**\n\t * The default options used to fill all the possible values for {@link LoggerOptions.format}.\n\t * @since 1.0.0\n\t * @default options.format.none ?? {}\n\t */\n\tdefaultFormat?: LoggerLevelOptions;\n\n\t/**\n\t * The options for each log level. LogLevel.None serves to set the default for all keys, where only\n\t * {@link LoggerTimestampOptions.timestamp} and {@link LoggerLevelOptions.prefix} would be overridden.\n\t * @since 1.0.0\n\t * @default {}\n\t */\n\tformat?: LoggerFormatOptions;\n\n\t/**\n\t * The minimum log level.\n\t * @since 1.0.0\n\t * @default LogLevel.Info\n\t */\n\tlevel?: LogLevel;\n\n\t/**\n\t * The string that joins different messages.\n\t * @since 1.0.0\n\t * @default ' '\n\t */\n\tjoin?: string;\n\n\t/**\n\t * The inspect depth when logging objects.\n\t * @since 1.0.0\n\t * @default 0\n\t */\n\tdepth?: number;\n}\n\n/**\n * The logger format options.\n * @since 1.0.0\n */\nexport interface LoggerFormatOptions {\n\t/**\n\t * The logger options for the lowest log level, used when calling {@link ILogger.trace}.\n\t * @since 1.0.0\n\t */\n\ttrace?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the debug level, used when calling {@link ILogger.debug}.\n\t * @since 1.0.0\n\t */\n\tdebug?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the info level, used when calling {@link ILogger.info}.\n\t * @since 1.0.0\n\t */\n\tinfo?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the warning level, used when calling {@link ILogger.warn}.\n\t * @since 1.0.0\n\t */\n\twarn?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the error level, used when calling {@link ILogger.error}.\n\t * @since 1.0.0\n\t */\n\terror?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for the critical level, used when calling {@link ILogger.fatal}.\n\t * @since 1.0.0\n\t */\n\tfatal?: LoggerLevelOptions;\n\n\t/**\n\t * The logger options for an unknown or uncategorised level.\n\t * @since 1.0.0\n\t */\n\tnone?: LoggerLevelOptions;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapphire/plugin-logger",
3
- "version": "4.1.0-next.c2464a5",
3
+ "version": "4.1.0-next.fb8af18",
4
4
  "description": "Plugin for @sapphire/framework to have pretty console output",
5
5
  "author": "@sapphire",
6
6
  "license": "MIT",
@@ -86,7 +86,7 @@
86
86
  "@favware/rollup-type-bundler": "^3.3.0",
87
87
  "concurrently": "^8.2.2",
88
88
  "tsup": "^8.2.4",
89
- "tsx": "^4.18.0",
89
+ "tsx": "^4.19.0",
90
90
  "typedoc": "^0.25.13",
91
91
  "typedoc-json-parser": "^10.0.0",
92
92
  "typescript": "~5.4.5"
@@ -1,29 +0,0 @@
1
- 'use strict';
2
-
3
- var promises = require('fs/promises');
4
- var pieces = require('@sapphire/pieces');
5
- require('@sapphire/framework');
6
-
7
- var __defProp = Object.defineProperty;
8
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
11
- var _LoggerTransport = class _LoggerTransport {
12
- constructor(options) {
13
- __publicField(this, "fileName");
14
- __publicField(this, "loglevel");
15
- this.fileName = options.file;
16
- this.loglevel = options.loglevel;
17
- pieces.container.transporters.set(this.loglevel, this);
18
- }
19
- async transport(message) {
20
- await promises.appendFile(this.fileName, `${message}
21
- `);
22
- }
23
- };
24
- __name(_LoggerTransport, "LoggerTransport");
25
- var LoggerTransport = _LoggerTransport;
26
-
27
- exports.LoggerTransport = LoggerTransport;
28
- //# sourceMappingURL=LoggerTransport.cjs.map
29
- //# sourceMappingURL=LoggerTransport.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/LoggerTransport.ts"],"names":["container","appendFile"],"mappings":";;;;;;;;;;AAIO,IAAM,gBAAA,GAAN,MAAM,gBAAgB,CAAA;AAAA,EAGrB,YAAY,OAA4B,EAAA;AAF/C,IAAO,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA,CAAA;AACP,IAAO,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA,CAAA;AAEN,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,IAAA,CAAA;AACxB,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA,CAAA;AACxB,IAAAA,gBAAA,CAAU,YAAa,CAAA,GAAA,CAAI,IAAK,CAAA,QAAA,EAAU,IAAI,CAAA,CAAA;AAAA,GAC/C;AAAA,EAEA,MAAa,UAAU,OAAiB,EAAA;AACvC,IAAA,MAAMC,mBAAW,CAAA,IAAA,CAAK,QAAU,EAAA,CAAA,EAAG,OAAO,CAAA;AAAA,CAAI,CAAA,CAAA;AAAA,GAC/C;AACD,CAAA,CAAA;AAZ6B,MAAA,CAAA,gBAAA,EAAA,iBAAA,CAAA,CAAA;AAAtB,IAAM,eAAN,GAAA","file":"LoggerTransport.cjs","sourcesContent":["import { appendFile } from 'node:fs/promises';\nimport { container } from '@sapphire/pieces';\nimport { LogLevel } from '@sapphire/framework';\n\nexport class LoggerTransport {\n\tpublic fileName: string;\n\tpublic loglevel: LogLevel;\n\tpublic constructor(options: TransporterOption) {\n\t\tthis.fileName = options.file;\n\t\tthis.loglevel = options.loglevel;\n\t\tcontainer.transporters.set(this.loglevel, this);\n\t}\n\n\tpublic async transport(message: string) {\n\t\tawait appendFile(this.fileName, `${message}\\n`);\n\t}\n}\n\nexport interface TransporterOption {\n\tfile: string;\n\tloglevel: LogLevel;\n}\n"]}
@@ -1,24 +0,0 @@
1
- import { __name, __publicField } from '../chunk-2JTKI4GS.mjs';
2
- import { appendFile } from 'node:fs/promises';
3
- import { container } from '@sapphire/pieces';
4
- import '@sapphire/framework';
5
-
6
- var _LoggerTransport = class _LoggerTransport {
7
- constructor(options) {
8
- __publicField(this, "fileName");
9
- __publicField(this, "loglevel");
10
- this.fileName = options.file;
11
- this.loglevel = options.loglevel;
12
- container.transporters.set(this.loglevel, this);
13
- }
14
- async transport(message) {
15
- await appendFile(this.fileName, `${message}
16
- `);
17
- }
18
- };
19
- __name(_LoggerTransport, "LoggerTransport");
20
- var LoggerTransport = _LoggerTransport;
21
-
22
- export { LoggerTransport };
23
- //# sourceMappingURL=LoggerTransport.mjs.map
24
- //# sourceMappingURL=LoggerTransport.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/lib/LoggerTransport.ts"],"names":[],"mappings":";;;;;AAIO,IAAM,gBAAA,GAAN,MAAM,gBAAgB,CAAA;AAAA,EAGrB,YAAY,OAA4B,EAAA;AAF/C,IAAO,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA,CAAA;AACP,IAAO,aAAA,CAAA,IAAA,EAAA,UAAA,CAAA,CAAA;AAEN,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,IAAA,CAAA;AACxB,IAAA,IAAA,CAAK,WAAW,OAAQ,CAAA,QAAA,CAAA;AACxB,IAAA,SAAA,CAAU,YAAa,CAAA,GAAA,CAAI,IAAK,CAAA,QAAA,EAAU,IAAI,CAAA,CAAA;AAAA,GAC/C;AAAA,EAEA,MAAa,UAAU,OAAiB,EAAA;AACvC,IAAA,MAAM,UAAW,CAAA,IAAA,CAAK,QAAU,EAAA,CAAA,EAAG,OAAO,CAAA;AAAA,CAAI,CAAA,CAAA;AAAA,GAC/C;AACD,CAAA,CAAA;AAZ6B,MAAA,CAAA,gBAAA,EAAA,iBAAA,CAAA,CAAA;AAAtB,IAAM,eAAN,GAAA","file":"LoggerTransport.mjs","sourcesContent":["import { appendFile } from 'node:fs/promises';\nimport { container } from '@sapphire/pieces';\nimport { LogLevel } from '@sapphire/framework';\n\nexport class LoggerTransport {\n\tpublic fileName: string;\n\tpublic loglevel: LogLevel;\n\tpublic constructor(options: TransporterOption) {\n\t\tthis.fileName = options.file;\n\t\tthis.loglevel = options.loglevel;\n\t\tcontainer.transporters.set(this.loglevel, this);\n\t}\n\n\tpublic async transport(message: string) {\n\t\tawait appendFile(this.fileName, `${message}\\n`);\n\t}\n}\n\nexport interface TransporterOption {\n\tfile: string;\n\tloglevel: LogLevel;\n}\n"]}