@rawnodes/logger 2.2.0 → 2.4.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/dist/index.d.mts CHANGED
@@ -33,6 +33,7 @@ interface FileConfig {
33
33
  dirname: string;
34
34
  filename: string;
35
35
  datePattern?: string;
36
+ interval?: string;
36
37
  zippedArchive?: boolean;
37
38
  maxSize?: string;
38
39
  maxFiles?: string;
@@ -98,6 +99,8 @@ interface LoggerConfig {
98
99
  cloudwatch?: CloudWatchConfig | CloudWatchConfig[];
99
100
  /** Enable caller info (file:line) in logs. Pass true for defaults or CallerConfig for options */
100
101
  caller?: boolean | CallerConfig;
102
+ /** Hostname to include in all log entries. Defaults to os.hostname() if not specified */
103
+ hostname?: string;
101
104
  }
102
105
  type LoggerContext = Record<string, unknown>;
103
106
  type LevelOverrideMatch<TContext extends LoggerContext> = Partial<TContext> & {
@@ -305,6 +308,7 @@ declare const LoggerConfigSchema: z.ZodObject<{
305
308
  telegram: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<TelegramConfig, unknown, z.core.$ZodTypeInternals<TelegramConfig, unknown>>, z.ZodArray<z.ZodType<TelegramConfig, unknown, z.core.$ZodTypeInternals<TelegramConfig, unknown>>>]>>;
306
309
  cloudwatch: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<CloudWatchConfig, unknown, z.core.$ZodTypeInternals<CloudWatchConfig, unknown>>, z.ZodArray<z.ZodType<CloudWatchConfig, unknown, z.core.$ZodTypeInternals<CloudWatchConfig, unknown>>>]>>;
307
310
  caller: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodType<CallerConfig, unknown, z.core.$ZodTypeInternals<CallerConfig, unknown>>]>>;
311
+ hostname: z.ZodOptional<z.ZodString>;
308
312
  }, z.core.$strip>;
309
313
  declare function validateConfig(config: unknown): z.infer<typeof LoggerConfigSchema>;
310
314
  declare function safeValidateConfig(config: unknown): z.ZodSafeParseResult<{
@@ -315,6 +319,7 @@ declare function safeValidateConfig(config: unknown): z.ZodSafeParseResult<{
315
319
  telegram?: TelegramConfig | TelegramConfig[] | undefined;
316
320
  cloudwatch?: CloudWatchConfig | CloudWatchConfig[] | undefined;
317
321
  caller?: boolean | CallerConfig | undefined;
322
+ hostname?: string | undefined;
318
323
  }>;
319
324
 
320
325
  export { BaseHttpTransport, type BaseHttpTransportOptions, type BufferOptions, type BufferedMessage, type CallerConfig, CallerConfigSchema, type CallerInfo, type CloudWatchConfig, CloudWatchConfigSchema, CloudWatchTransport, type ConsoleConfig, ConsoleConfigSchema, type DiscordConfig, DiscordConfigSchema, DiscordTransport, type FileConfig, FileConfigSchema, type HttpTransportBaseConfig, HttpTransportBaseConfigSchema, LOG_LEVELS, type LevelConfig, type LevelConfigObject, LevelConfigObjectSchema, LevelConfigSchema, type LevelOverride, type LevelOverrideMatch, type LevelRule, LevelRuleSchema, type LogFormat, LogFormatSchema, type LogLevel, LogLevelSchema, Logger, type LoggerConfig, LoggerConfigSchema, type LoggerContext, LoggerStore, type MaskSecretsOptions, MessageBuffer, type Meta, type RequestIdOptions, type SingletonLogger, type TelegramConfig, TelegramConfigSchema, TelegramTransport, type TimingResult, assertLogLevel, createMasker, createSingletonLogger, extractRequestId, flattenObject, formatCallerInfo, formatLogfmt, formatLogfmtValue, generateRequestId, getCallerInfo, getOrGenerateRequestId, isValidLogLevel, maskSecrets, matchesContext, measureAsync, measureSync, safeValidateConfig, validateConfig };
package/dist/index.d.ts CHANGED
@@ -33,6 +33,7 @@ interface FileConfig {
33
33
  dirname: string;
34
34
  filename: string;
35
35
  datePattern?: string;
36
+ interval?: string;
36
37
  zippedArchive?: boolean;
37
38
  maxSize?: string;
38
39
  maxFiles?: string;
@@ -98,6 +99,8 @@ interface LoggerConfig {
98
99
  cloudwatch?: CloudWatchConfig | CloudWatchConfig[];
99
100
  /** Enable caller info (file:line) in logs. Pass true for defaults or CallerConfig for options */
100
101
  caller?: boolean | CallerConfig;
102
+ /** Hostname to include in all log entries. Defaults to os.hostname() if not specified */
103
+ hostname?: string;
101
104
  }
102
105
  type LoggerContext = Record<string, unknown>;
103
106
  type LevelOverrideMatch<TContext extends LoggerContext> = Partial<TContext> & {
@@ -305,6 +308,7 @@ declare const LoggerConfigSchema: z.ZodObject<{
305
308
  telegram: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<TelegramConfig, unknown, z.core.$ZodTypeInternals<TelegramConfig, unknown>>, z.ZodArray<z.ZodType<TelegramConfig, unknown, z.core.$ZodTypeInternals<TelegramConfig, unknown>>>]>>;
306
309
  cloudwatch: z.ZodOptional<z.ZodUnion<readonly [z.ZodType<CloudWatchConfig, unknown, z.core.$ZodTypeInternals<CloudWatchConfig, unknown>>, z.ZodArray<z.ZodType<CloudWatchConfig, unknown, z.core.$ZodTypeInternals<CloudWatchConfig, unknown>>>]>>;
307
310
  caller: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodType<CallerConfig, unknown, z.core.$ZodTypeInternals<CallerConfig, unknown>>]>>;
311
+ hostname: z.ZodOptional<z.ZodString>;
308
312
  }, z.core.$strip>;
309
313
  declare function validateConfig(config: unknown): z.infer<typeof LoggerConfigSchema>;
310
314
  declare function safeValidateConfig(config: unknown): z.ZodSafeParseResult<{
@@ -315,6 +319,7 @@ declare function safeValidateConfig(config: unknown): z.ZodSafeParseResult<{
315
319
  telegram?: TelegramConfig | TelegramConfig[] | undefined;
316
320
  cloudwatch?: CloudWatchConfig | CloudWatchConfig[] | undefined;
317
321
  caller?: boolean | CallerConfig | undefined;
322
+ hostname?: string | undefined;
318
323
  }>;
319
324
 
320
325
  export { BaseHttpTransport, type BaseHttpTransportOptions, type BufferOptions, type BufferedMessage, type CallerConfig, CallerConfigSchema, type CallerInfo, type CloudWatchConfig, CloudWatchConfigSchema, CloudWatchTransport, type ConsoleConfig, ConsoleConfigSchema, type DiscordConfig, DiscordConfigSchema, DiscordTransport, type FileConfig, FileConfigSchema, type HttpTransportBaseConfig, HttpTransportBaseConfigSchema, LOG_LEVELS, type LevelConfig, type LevelConfigObject, LevelConfigObjectSchema, LevelConfigSchema, type LevelOverride, type LevelOverrideMatch, type LevelRule, LevelRuleSchema, type LogFormat, LogFormatSchema, type LogLevel, LogLevelSchema, Logger, type LoggerConfig, LoggerConfigSchema, type LoggerContext, LoggerStore, type MaskSecretsOptions, MessageBuffer, type Meta, type RequestIdOptions, type SingletonLogger, type TelegramConfig, TelegramConfigSchema, TelegramTransport, type TimingResult, assertLogLevel, createMasker, createSingletonLogger, extractRequestId, flattenObject, formatCallerInfo, formatLogfmt, formatLogfmtValue, generateRequestId, getCallerInfo, getOrGenerateRequestId, isValidLogLevel, maskSecrets, matchesContext, measureAsync, measureSync, safeValidateConfig, validateConfig };
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict';
2
2
 
3
+ var os = require('os');
3
4
  var pino = require('pino');
4
5
  var async_hooks = require('async_hooks');
5
6
  var stream = require('stream');
@@ -678,7 +679,7 @@ function createStreams(config, store) {
678
679
  {
679
680
  path: fileConfig.dirname,
680
681
  size: normalizeSize(fileConfig.maxSize || "20M"),
681
- interval: fileConfig.datePattern === "YYYY-MM-DD-HH" ? "1h" : "1d",
682
+ interval: fileConfig.interval || (fileConfig.datePattern === "YYYY-MM-DD-HH" ? "1h" : "1d"),
682
683
  compress: fileConfig.zippedArchive ? "gzip" : false,
683
684
  maxFiles: parseInt(fileConfig.maxFiles?.replace("d", "") || "14")
684
685
  }
@@ -809,8 +810,7 @@ function createState(config, store) {
809
810
  level: "trace",
810
811
  // Accept all, we filter in shouldLog()
811
812
  customLevels: CUSTOM_LEVELS,
812
- base: void 0
813
- // Disable pid and hostname
813
+ base: { hostname: config.hostname ?? os.hostname() }
814
814
  };
815
815
  const pinoLogger = pino__default.default(options, streams);
816
816
  let callerConfig;
@@ -884,6 +884,7 @@ var FileConfigSchema = zod.z.object({
884
884
  dirname: zod.z.string().min(1, "dirname is required"),
885
885
  filename: zod.z.string().min(1, "filename is required"),
886
886
  datePattern: zod.z.string().optional(),
887
+ interval: zod.z.string().regex(/^\d+[Mdhms]$/).optional(),
887
888
  zippedArchive: zod.z.boolean().optional(),
888
889
  maxSize: zod.z.string().optional(),
889
890
  maxFiles: zod.z.string().optional()
@@ -960,7 +961,8 @@ var LoggerConfigSchema = zod.z.object({
960
961
  discord: zod.z.union([DiscordConfigSchema, zod.z.array(DiscordConfigSchema)]).optional(),
961
962
  telegram: zod.z.union([TelegramConfigSchema, zod.z.array(TelegramConfigSchema)]).optional(),
962
963
  cloudwatch: zod.z.union([CloudWatchConfigSchema, zod.z.array(CloudWatchConfigSchema)]).optional(),
963
- caller: zod.z.union([zod.z.boolean(), CallerConfigSchema]).optional()
964
+ caller: zod.z.union([zod.z.boolean(), CallerConfigSchema]).optional(),
965
+ hostname: zod.z.string().optional()
964
966
  });
965
967
  function validateConfig(config) {
966
968
  return LoggerConfigSchema.parse(config);