@degel_lc/logger 0.1.7 → 0.1.9

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.
@@ -0,0 +1,84 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var chunkUDIZDVDO_cjs = require('./chunk-UDIZDVDO.cjs');
6
+ var chunk3QE5XQOJ_cjs = require('./chunk-3QE5XQOJ.cjs');
7
+
8
+ // src/browser.ts
9
+ async function createServerLogger(_config) {
10
+ console.warn("[logger] createServerLogger is not available in browser/edge environment");
11
+ return chunkUDIZDVDO_cjs.createClientLogger(_config);
12
+ }
13
+ function getLogger() {
14
+ if (globalThis.__DEGEL_LOGGER__) {
15
+ return globalThis.__DEGEL_LOGGER__;
16
+ }
17
+ globalThis.__DEGEL_LOGGER__ = chunkUDIZDVDO_cjs.createClientLogger();
18
+ return globalThis.__DEGEL_LOGGER__;
19
+ }
20
+ async function initializeLogger(config) {
21
+ if (globalThis.__DEGEL_LOGGER__ && globalThis.__DEGEL_LOGGER_INITIALIZED__) {
22
+ return globalThis.__DEGEL_LOGGER__;
23
+ }
24
+ globalThis.__DEGEL_LOGGER__ = chunkUDIZDVDO_cjs.createClientLogger(config);
25
+ globalThis.__DEGEL_LOGGER_INITIALIZED__ = true;
26
+ return globalThis.__DEGEL_LOGGER__;
27
+ }
28
+ var logger = {
29
+ debug: (ctxOrMessage, messageOrLocation, originalError) => getLogger().debug(ctxOrMessage, messageOrLocation, originalError),
30
+ info: (ctxOrMessage, messageOrLocation, originalError) => getLogger().info(ctxOrMessage, messageOrLocation, originalError),
31
+ warn: (ctxOrMessage, messageOrLocation, originalError) => getLogger().warn(ctxOrMessage, messageOrLocation, originalError),
32
+ error: (ctxOrMessage, messageOrLocation, originalError) => getLogger().error(
33
+ ctxOrMessage,
34
+ messageOrLocation,
35
+ originalError
36
+ ),
37
+ fatal: (ctxOrMessage, messageOrLocation, originalError) => getLogger().fatal(
38
+ ctxOrMessage,
39
+ messageOrLocation,
40
+ originalError
41
+ ),
42
+ sqlError: (message, location, originalError) => getLogger().sqlError(message, location, originalError)
43
+ };
44
+ var browser_default = logger;
45
+
46
+ Object.defineProperty(exports, "createClientLogger", {
47
+ enumerable: true,
48
+ get: function () { return chunkUDIZDVDO_cjs.createClientLogger; }
49
+ });
50
+ Object.defineProperty(exports, "LOG_FILE_PREFIX", {
51
+ enumerable: true,
52
+ get: function () { return chunk3QE5XQOJ_cjs.LOG_FILE_PREFIX; }
53
+ });
54
+ Object.defineProperty(exports, "LOG_LEVEL_PRIORITY", {
55
+ enumerable: true,
56
+ get: function () { return chunk3QE5XQOJ_cjs.LOG_LEVEL_PRIORITY; }
57
+ });
58
+ Object.defineProperty(exports, "LOG_ROTATION", {
59
+ enumerable: true,
60
+ get: function () { return chunk3QE5XQOJ_cjs.LOG_ROTATION; }
61
+ });
62
+ Object.defineProperty(exports, "TIMEZONE", {
63
+ enumerable: true,
64
+ get: function () { return chunk3QE5XQOJ_cjs.TIMEZONE; }
65
+ });
66
+ Object.defineProperty(exports, "VALID_LOG_LEVELS", {
67
+ enumerable: true,
68
+ get: function () { return chunk3QE5XQOJ_cjs.VALID_LOG_LEVELS; }
69
+ });
70
+ Object.defineProperty(exports, "isSentryEnabled", {
71
+ enumerable: true,
72
+ get: function () { return chunk3QE5XQOJ_cjs.isSentryEnabled; }
73
+ });
74
+ Object.defineProperty(exports, "setSentryModule", {
75
+ enumerable: true,
76
+ get: function () { return chunk3QE5XQOJ_cjs.setSentryModule; }
77
+ });
78
+ exports.createServerLogger = createServerLogger;
79
+ exports.default = browser_default;
80
+ exports.getLogger = getLogger;
81
+ exports.initializeLogger = initializeLogger;
82
+ exports.logger = logger;
83
+ //# sourceMappingURL=browser.cjs.map
84
+ //# sourceMappingURL=browser.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/browser.ts"],"names":["createClientLogger"],"mappings":";;;;;;;;AA0CA,eAAsB,mBAAmB,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,KACvC,WAAU,CAAE,KAAA;AAAA,IACV,YAAA;AAAA,IACA,iBAAA;AAAA,IACA;AAAA,GACF;AAAA,EACF,QAAA,EAAU,CAAC,OAAA,EAAS,QAAA,EAAU,aAAA,KAC5B,WAAU,CAAE,QAAA,CAAS,OAAA,EAAS,QAAA,EAAU,aAAa;AACzD;AAEA,IAAO,eAAA,GAAQ","file":"browser.cjs","sourcesContent":["/**\n * ブラウザ/Edge Runtime用エントリーポイント\n * サーバーサイドモジュール(fs, path)を一切参照しない\n */\nimport { createClientLogger } from './client.js';\nimport type {\n LogContext,\n LogLevel,\n LogMethod,\n LogMethodWithContext,\n LogTypeConfig,\n Logger,\n LoggerConfig,\n SentryModule,\n} from './types.js';\n\nexport type {\n LogContext,\n Logger,\n LoggerConfig,\n LogLevel,\n LogMethod,\n LogMethodWithContext,\n LogTypeConfig,\n SentryModule,\n};\n\nexport { createClientLogger };\nexport { isSentryEnabled, setSentryModule } from './sentry.js';\n\n// Constants\nexport {\n LOG_FILE_PREFIX,\n LOG_LEVEL_PRIORITY,\n LOG_ROTATION,\n TIMEZONE,\n VALID_LOG_LEVELS,\n} from './constants.js';\n\n/**\n * ブラウザ環境ではサーバーロガーは使用不可\n */\nexport async function createServerLogger(_config?: LoggerConfig): Promise<Logger> {\n console.warn('[logger] createServerLogger is not available in browser/edge environment');\n return createClientLogger(_config);\n}\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __DEGEL_LOGGER__: Logger | undefined;\n // eslint-disable-next-line no-var\n var __DEGEL_LOGGER_INITIALIZED__: boolean | undefined;\n}\n\nexport function getLogger(): Logger {\n if (globalThis.__DEGEL_LOGGER__) {\n return globalThis.__DEGEL_LOGGER__;\n }\n globalThis.__DEGEL_LOGGER__ = createClientLogger();\n return globalThis.__DEGEL_LOGGER__;\n}\n\nexport async function initializeLogger(config?: LoggerConfig): Promise<Logger> {\n if (globalThis.__DEGEL_LOGGER__ && globalThis.__DEGEL_LOGGER_INITIALIZED__) {\n return globalThis.__DEGEL_LOGGER__;\n }\n globalThis.__DEGEL_LOGGER__ = createClientLogger(config);\n globalThis.__DEGEL_LOGGER_INITIALIZED__ = true;\n return globalThis.__DEGEL_LOGGER__;\n}\n\nexport const logger: Logger = {\n debug: (ctxOrMessage, messageOrLocation, originalError) =>\n getLogger().debug(ctxOrMessage as string, messageOrLocation, originalError),\n info: (ctxOrMessage, messageOrLocation, originalError) =>\n getLogger().info(ctxOrMessage as string, messageOrLocation, originalError),\n warn: (ctxOrMessage, messageOrLocation, originalError) =>\n getLogger().warn(ctxOrMessage as string, messageOrLocation, originalError),\n error: (ctxOrMessage, messageOrLocation, originalError) =>\n getLogger().error(\n ctxOrMessage as string,\n messageOrLocation,\n originalError as Error | string | null | undefined\n ),\n fatal: (ctxOrMessage, messageOrLocation, originalError) =>\n getLogger().fatal(\n ctxOrMessage as string,\n messageOrLocation,\n originalError as Error | string | null | undefined\n ),\n sqlError: (message, location, originalError) =>\n getLogger().sqlError(message, location, originalError),\n} as Logger;\n\nexport default logger;\n"]}
@@ -0,0 +1,22 @@
1
+ import { L as Logger, a as LoggerConfig } from './constants-Dw2vmgrv.cjs';
2
+ export { h as LOG_FILE_PREFIX, j as LOG_LEVEL_PRIORITY, k as LOG_ROTATION, b as LogContext, c as LogLevel, d as LogMethod, e as LogMethodWithContext, f as LogTypeConfig, S as SentryModule, T as TIMEZONE, V as VALID_LOG_LEVELS, g as createClientLogger, i as isSentryEnabled, s as setSentryModule } from './constants-Dw2vmgrv.cjs';
3
+ import 'pino';
4
+
5
+ /**
6
+ * ブラウザ/Edge Runtime用エントリーポイント
7
+ * サーバーサイドモジュール(fs, path)を一切参照しない
8
+ */
9
+
10
+ /**
11
+ * ブラウザ環境ではサーバーロガーは使用不可
12
+ */
13
+ declare function createServerLogger(_config?: LoggerConfig): Promise<Logger>;
14
+ declare global {
15
+ var __DEGEL_LOGGER__: Logger | undefined;
16
+ var __DEGEL_LOGGER_INITIALIZED__: boolean | undefined;
17
+ }
18
+ declare function getLogger(): Logger;
19
+ declare function initializeLogger(config?: LoggerConfig): Promise<Logger>;
20
+ declare const logger: Logger;
21
+
22
+ export { Logger, LoggerConfig, createServerLogger, logger as default, getLogger, initializeLogger, logger };
@@ -0,0 +1,22 @@
1
+ import { L as Logger, a as LoggerConfig } from './constants-Dw2vmgrv.js';
2
+ export { h as LOG_FILE_PREFIX, j as LOG_LEVEL_PRIORITY, k as LOG_ROTATION, b as LogContext, c as LogLevel, d as LogMethod, e as LogMethodWithContext, f as LogTypeConfig, S as SentryModule, T as TIMEZONE, V as VALID_LOG_LEVELS, g as createClientLogger, i as isSentryEnabled, s as setSentryModule } from './constants-Dw2vmgrv.js';
3
+ import 'pino';
4
+
5
+ /**
6
+ * ブラウザ/Edge Runtime用エントリーポイント
7
+ * サーバーサイドモジュール(fs, path)を一切参照しない
8
+ */
9
+
10
+ /**
11
+ * ブラウザ環境ではサーバーロガーは使用不可
12
+ */
13
+ declare function createServerLogger(_config?: LoggerConfig): Promise<Logger>;
14
+ declare global {
15
+ var __DEGEL_LOGGER__: Logger | undefined;
16
+ var __DEGEL_LOGGER_INITIALIZED__: boolean | undefined;
17
+ }
18
+ declare function getLogger(): Logger;
19
+ declare function initializeLogger(config?: LoggerConfig): Promise<Logger>;
20
+ declare const logger: Logger;
21
+
22
+ export { Logger, LoggerConfig, createServerLogger, logger as default, getLogger, initializeLogger, logger };
@@ -0,0 +1,45 @@
1
+ import { createClientLogger } from './chunk-4NWY6SZL.js';
2
+ export { createClientLogger } from './chunk-4NWY6SZL.js';
3
+ export { LOG_FILE_PREFIX, LOG_LEVEL_PRIORITY, LOG_ROTATION, TIMEZONE, VALID_LOG_LEVELS, isSentryEnabled, setSentryModule } from './chunk-B7IDJBGL.js';
4
+
5
+ // src/browser.ts
6
+ async function createServerLogger(_config) {
7
+ console.warn("[logger] createServerLogger is not available in browser/edge environment");
8
+ return createClientLogger(_config);
9
+ }
10
+ function getLogger() {
11
+ if (globalThis.__DEGEL_LOGGER__) {
12
+ return globalThis.__DEGEL_LOGGER__;
13
+ }
14
+ globalThis.__DEGEL_LOGGER__ = createClientLogger();
15
+ return globalThis.__DEGEL_LOGGER__;
16
+ }
17
+ async function initializeLogger(config) {
18
+ if (globalThis.__DEGEL_LOGGER__ && globalThis.__DEGEL_LOGGER_INITIALIZED__) {
19
+ return globalThis.__DEGEL_LOGGER__;
20
+ }
21
+ globalThis.__DEGEL_LOGGER__ = createClientLogger(config);
22
+ globalThis.__DEGEL_LOGGER_INITIALIZED__ = true;
23
+ return globalThis.__DEGEL_LOGGER__;
24
+ }
25
+ var logger = {
26
+ debug: (ctxOrMessage, messageOrLocation, originalError) => getLogger().debug(ctxOrMessage, messageOrLocation, originalError),
27
+ info: (ctxOrMessage, messageOrLocation, originalError) => getLogger().info(ctxOrMessage, messageOrLocation, originalError),
28
+ warn: (ctxOrMessage, messageOrLocation, originalError) => getLogger().warn(ctxOrMessage, messageOrLocation, originalError),
29
+ error: (ctxOrMessage, messageOrLocation, originalError) => getLogger().error(
30
+ ctxOrMessage,
31
+ messageOrLocation,
32
+ originalError
33
+ ),
34
+ fatal: (ctxOrMessage, messageOrLocation, originalError) => getLogger().fatal(
35
+ ctxOrMessage,
36
+ messageOrLocation,
37
+ originalError
38
+ ),
39
+ sqlError: (message, location, originalError) => getLogger().sqlError(message, location, originalError)
40
+ };
41
+ var browser_default = logger;
42
+
43
+ export { createServerLogger, browser_default as default, getLogger, initializeLogger, logger };
44
+ //# sourceMappingURL=browser.js.map
45
+ //# sourceMappingURL=browser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/browser.ts"],"names":[],"mappings":";;;;;AA0CA,eAAsB,mBAAmB,OAAA,EAAyC;AAChF,EAAA,OAAA,CAAQ,KAAK,0EAA0E,CAAA;AACvF,EAAA,OAAO,mBAAmB,OAAO,CAAA;AACnC;AASO,SAAS,SAAA,GAAoB;AAClC,EAAA,IAAI,WAAW,gBAAA,EAAkB;AAC/B,IAAA,OAAO,UAAA,CAAW,gBAA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D;AAEA,IAAO,eAAA,GAAQ","file":"browser.js","sourcesContent":["/**\n * ブラウザ/Edge Runtime用エントリーポイント\n * サーバーサイドモジュール(fs, path)を一切参照しない\n */\nimport { createClientLogger } from './client.js';\nimport type {\n LogContext,\n LogLevel,\n LogMethod,\n LogMethodWithContext,\n LogTypeConfig,\n Logger,\n LoggerConfig,\n SentryModule,\n} from './types.js';\n\nexport type {\n LogContext,\n Logger,\n LoggerConfig,\n LogLevel,\n LogMethod,\n LogMethodWithContext,\n LogTypeConfig,\n SentryModule,\n};\n\nexport { createClientLogger };\nexport { isSentryEnabled, setSentryModule } from './sentry.js';\n\n// Constants\nexport {\n LOG_FILE_PREFIX,\n LOG_LEVEL_PRIORITY,\n LOG_ROTATION,\n TIMEZONE,\n VALID_LOG_LEVELS,\n} from './constants.js';\n\n/**\n * ブラウザ環境ではサーバーロガーは使用不可\n */\nexport async function createServerLogger(_config?: LoggerConfig): Promise<Logger> {\n console.warn('[logger] createServerLogger is not available in browser/edge environment');\n return createClientLogger(_config);\n}\n\ndeclare global {\n // eslint-disable-next-line no-var\n var __DEGEL_LOGGER__: Logger | undefined;\n // eslint-disable-next-line no-var\n var __DEGEL_LOGGER_INITIALIZED__: boolean | undefined;\n}\n\nexport function getLogger(): Logger {\n if (globalThis.__DEGEL_LOGGER__) {\n return globalThis.__DEGEL_LOGGER__;\n }\n globalThis.__DEGEL_LOGGER__ = createClientLogger();\n return globalThis.__DEGEL_LOGGER__;\n}\n\nexport async function initializeLogger(config?: LoggerConfig): Promise<Logger> {\n if (globalThis.__DEGEL_LOGGER__ && globalThis.__DEGEL_LOGGER_INITIALIZED__) {\n return globalThis.__DEGEL_LOGGER__;\n }\n globalThis.__DEGEL_LOGGER__ = createClientLogger(config);\n globalThis.__DEGEL_LOGGER_INITIALIZED__ = true;\n return globalThis.__DEGEL_LOGGER__;\n}\n\nexport const logger: Logger = {\n debug: (ctxOrMessage, messageOrLocation, originalError) =>\n getLogger().debug(ctxOrMessage as string, messageOrLocation, originalError),\n info: (ctxOrMessage, messageOrLocation, originalError) =>\n getLogger().info(ctxOrMessage as string, messageOrLocation, originalError),\n warn: (ctxOrMessage, messageOrLocation, originalError) =>\n getLogger().warn(ctxOrMessage as string, messageOrLocation, originalError),\n error: (ctxOrMessage, messageOrLocation, originalError) =>\n getLogger().error(\n ctxOrMessage as string,\n messageOrLocation,\n originalError as Error | string | null | undefined\n ),\n fatal: (ctxOrMessage, messageOrLocation, originalError) =>\n getLogger().fatal(\n ctxOrMessage as string,\n messageOrLocation,\n originalError as Error | string | null | undefined\n ),\n sqlError: (message, location, originalError) =>\n getLogger().sqlError(message, location, originalError),\n} as Logger;\n\nexport default logger;\n"]}
@@ -0,0 +1,57 @@
1
+ import { VALID_LOG_LEVELS, isLogContext, formatLogMessageWithContext, formatLogMessage, LOG_LEVEL_PRIORITY } from './chunk-B7IDJBGL.js';
2
+
3
+ // src/client.ts
4
+ function shouldLog(logLevel, minLevel) {
5
+ return LOG_LEVEL_PRIORITY[logLevel] >= LOG_LEVEL_PRIORITY[minLevel];
6
+ }
7
+ function createClientLogger(config = {}) {
8
+ const { timezoneOffset = 540, enableConsole = true, level = "debug" } = config;
9
+ const minLevel = VALID_LOG_LEVELS.includes(level) ? level : "debug";
10
+ const logToConsole = (logLevel, displayLevel, consoleMethod, ctxOrMessage, messageOrLocation, errorOrOriginal) => {
11
+ if (!enableConsole) return;
12
+ if (!shouldLog(logLevel, minLevel)) return;
13
+ let formattedMessage;
14
+ if (isLogContext(ctxOrMessage)) {
15
+ formattedMessage = formatLogMessageWithContext(
16
+ displayLevel,
17
+ messageOrLocation ?? "",
18
+ ctxOrMessage,
19
+ errorOrOriginal,
20
+ timezoneOffset
21
+ );
22
+ } else {
23
+ formattedMessage = formatLogMessage(
24
+ displayLevel,
25
+ ctxOrMessage,
26
+ messageOrLocation ?? null,
27
+ errorOrOriginal ?? null,
28
+ timezoneOffset
29
+ );
30
+ }
31
+ consoleMethod(formattedMessage);
32
+ };
33
+ return {
34
+ debug: (ctxOrMessage, messageOrLocation, originalError) => {
35
+ logToConsole("debug", "debug", console.debug, ctxOrMessage, messageOrLocation, originalError);
36
+ },
37
+ info: (ctxOrMessage, messageOrLocation, originalError) => {
38
+ logToConsole("info", "info", console.info, ctxOrMessage, messageOrLocation, originalError);
39
+ },
40
+ warn: (ctxOrMessage, messageOrLocation, originalError) => {
41
+ logToConsole("warn", "warn", console.warn, ctxOrMessage, messageOrLocation, originalError);
42
+ },
43
+ error: (ctxOrMessage, messageOrLocation, originalError) => {
44
+ logToConsole("error", "error", console.error, ctxOrMessage, messageOrLocation, originalError);
45
+ },
46
+ fatal: (ctxOrMessage, messageOrLocation, originalError) => {
47
+ logToConsole("fatal", "fatal", console.error, ctxOrMessage, messageOrLocation, originalError);
48
+ },
49
+ sqlError: (message, location, originalError) => {
50
+ logToConsole("error", "sql_error", console.error, message, location, originalError);
51
+ }
52
+ };
53
+ }
54
+
55
+ export { createClientLogger };
56
+ //# sourceMappingURL=chunk-4NWY6SZL.js.map
57
+ //# sourceMappingURL=chunk-4NWY6SZL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts"],"names":[],"mappings":";;;AAOA,SAAS,SAAA,CAAU,UAAoB,QAAA,EAA6B;AAClE,EAAA,OAAO,kBAAA,CAAmB,QAAQ,CAAA,IAAK,kBAAA,CAAmB,QAAQ,CAAA;AACpE;AAKO,SAAS,kBAAA,CAAmB,MAAA,GAAuB,EAAC,EAAW;AACpE,EAAA,MAAM,EAAE,cAAA,GAAiB,GAAA,EAAK,gBAAgB,IAAA,EAAM,KAAA,GAAQ,SAAQ,GAAI,MAAA;AAGxE,EAAA,MAAM,QAAA,GAAqB,gBAAA,CAAiB,QAAA,CAAS,KAAK,IAAI,KAAA,GAAQ,OAAA;AAEtE,EAAA,MAAM,eAAe,CACnB,QAAA,EACA,cACA,aAAA,EACA,YAAA,EACA,mBACA,eAAA,KACS;AACT,IAAA,IAAI,CAAC,aAAA,EAAe;AACpB,I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aAAa,CAAA;AAAA,IAC9F,CAAA;AAAA,IACA,KAAA,EAAO,CACL,YAAA,EACA,iBAAA,EACA,aAAA,KACG;AACH,MAAA,YAAA,CAAa,SAAS,OAAA,EAAS,OAAA,CAAQ,KAAA,EAAO,YAAA,EAAc,mBAAmB,aAAa,CAAA;AAAA,IAC9F,CAAA;AAAA,IACA,QAAA,EAAU,CACR,OAAA,EACA,QAAA,EACA,aAAA,KACG;AAEH,MAAA,YAAA,CAAa,SAAS,WAAA,EAAa,OAAA,CAAQ,KAAA,EAAO,OAAA,EAAS,UAAU,aAAa,CAAA;AAAA,IACpF;AAAA,GACF;AACF","file":"chunk-4NWY6SZL.js","sourcesContent":["import { LOG_LEVEL_PRIORITY, VALID_LOG_LEVELS } from './constants.js';\nimport type { LogContext, LogLevel, Logger, LoggerConfig } from './types.js';\nimport { formatLogMessage, formatLogMessageWithContext, isLogContext } from './utils.js';\n\n/**\n * 指定されたログレベルが最小レベル以上かどうかを判定\n */\nfunction shouldLog(logLevel: LogLevel, minLevel: LogLevel): boolean {\n return LOG_LEVEL_PRIORITY[logLevel] >= LOG_LEVEL_PRIORITY[minLevel];\n}\n\n/**\n * クライアントサイド用ロガーを作成\n */\nexport function createClientLogger(config: LoggerConfig = {}): Logger {\n const { timezoneOffset = 540, enableConsole = true, level = 'debug' } = config;\n\n // 有効なログレベルかどうかを検証\n const minLevel: LogLevel = VALID_LOG_LEVELS.includes(level) ? level : 'debug';\n\n const logToConsole = (\n logLevel: LogLevel,\n displayLevel: string,\n consoleMethod: (...args: unknown[]) => void,\n ctxOrMessage: LogContext | string,\n messageOrLocation?: string | null,\n errorOrOriginal?: unknown\n ): void => {\n if (!enableConsole) return;\n if (!shouldLog(logLevel, minLevel)) return;\n\n let formattedMessage: string;\n\n if (isLogContext(ctxOrMessage)) {\n // 構造化コンテキスト形式: (ctx, message, error?)\n formattedMessage = formatLogMessageWithContext(\n displayLevel,\n messageOrLocation ?? '',\n ctxOrMessage,\n errorOrOriginal,\n timezoneOffset\n );\n } else {\n // レガシー形式: (message, location?, originalError?)\n formattedMessage = formatLogMessage(\n displayLevel,\n ctxOrMessage,\n (messageOrLocation as string) ?? null,\n (errorOrOriginal as Error | string) ?? null,\n timezoneOffset\n );\n }\n\n consoleMethod(formattedMessage);\n };\n\n return {\n debug: (\n ctxOrMessage: LogContext | string,\n messageOrLocation?: string | null,\n originalError?: unknown\n ) => {\n logToConsole('debug', 'debug', console.debug, ctxOrMessage, messageOrLocation, originalError);\n },\n info: (\n ctxOrMessage: LogContext | string,\n messageOrLocation?: string | null,\n originalError?: unknown\n ) => {\n logToConsole('info', 'info', console.info, ctxOrMessage, messageOrLocation, originalError);\n },\n warn: (\n ctxOrMessage: LogContext | string,\n messageOrLocation?: string | null,\n originalError?: unknown\n ) => {\n logToConsole('warn', 'warn', console.warn, ctxOrMessage, messageOrLocation, originalError);\n },\n error: (\n ctxOrMessage: LogContext | string,\n messageOrLocation?: string | null,\n originalError?: unknown\n ) => {\n logToConsole('error', 'error', console.error, ctxOrMessage, messageOrLocation, originalError);\n },\n fatal: (\n ctxOrMessage: LogContext | string,\n messageOrLocation?: string | null,\n originalError?: unknown\n ) => {\n logToConsole('fatal', 'fatal', console.error, ctxOrMessage, messageOrLocation, originalError);\n },\n sqlError: (\n message: string,\n location?: string | null,\n originalError?: Error | string | null\n ) => {\n // sqlErrorはerrorレベルとしてフィルタリング、表示はsql_error\n logToConsole('error', 'sql_error', console.error, message, location, originalError);\n },\n } as Logger;\n}\n"]}
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ var chunk3QE5XQOJ_cjs = require('./chunk-3QE5XQOJ.cjs');
4
+
5
+ // src/client.ts
6
+ function shouldLog(logLevel, minLevel) {
7
+ return chunk3QE5XQOJ_cjs.LOG_LEVEL_PRIORITY[logLevel] >= chunk3QE5XQOJ_cjs.LOG_LEVEL_PRIORITY[minLevel];
8
+ }
9
+ function createClientLogger(config = {}) {
10
+ const { timezoneOffset = 540, enableConsole = true, level = "debug" } = config;
11
+ const minLevel = chunk3QE5XQOJ_cjs.VALID_LOG_LEVELS.includes(level) ? level : "debug";
12
+ const logToConsole = (logLevel, displayLevel, consoleMethod, ctxOrMessage, messageOrLocation, errorOrOriginal) => {
13
+ if (!enableConsole) return;
14
+ if (!shouldLog(logLevel, minLevel)) return;
15
+ let formattedMessage;
16
+ if (chunk3QE5XQOJ_cjs.isLogContext(ctxOrMessage)) {
17
+ formattedMessage = chunk3QE5XQOJ_cjs.formatLogMessageWithContext(
18
+ displayLevel,
19
+ messageOrLocation ?? "",
20
+ ctxOrMessage,
21
+ errorOrOriginal,
22
+ timezoneOffset
23
+ );
24
+ } else {
25
+ formattedMessage = chunk3QE5XQOJ_cjs.formatLogMessage(
26
+ displayLevel,
27
+ ctxOrMessage,
28
+ messageOrLocation ?? null,
29
+ errorOrOriginal ?? null,
30
+ timezoneOffset
31
+ );
32
+ }
33
+ consoleMethod(formattedMessage);
34
+ };
35
+ return {
36
+ debug: (ctxOrMessage, messageOrLocation, originalError) => {
37
+ logToConsole("debug", "debug", console.debug, ctxOrMessage, messageOrLocation, originalError);
38
+ },
39
+ info: (ctxOrMessage, messageOrLocation, originalError) => {
40
+ logToConsole("info", "info", console.info, ctxOrMessage, messageOrLocation, originalError);
41
+ },
42
+ warn: (ctxOrMessage, messageOrLocation, originalError) => {
43
+ logToConsole("warn", "warn", console.warn, ctxOrMessage, messageOrLocation, originalError);
44
+ },
45
+ error: (ctxOrMessage, messageOrLocation, originalError) => {
46
+ logToConsole("error", "error", console.error, ctxOrMessage, messageOrLocation, originalError);
47
+ },
48
+ fatal: (ctxOrMessage, messageOrLocation, originalError) => {
49
+ logToConsole("fatal", "fatal", console.error, ctxOrMessage, messageOrLocation, originalError);
50
+ },
51
+ sqlError: (message, location, originalError) => {
52
+ logToConsole("error", "sql_error", console.error, message, location, originalError);
53
+ }
54
+ };
55
+ }
56
+
57
+ exports.createClientLogger = createClientLogger;
58
+ //# sourceMappingURL=chunk-UDIZDVDO.cjs.map
59
+ //# sourceMappingURL=chunk-UDIZDVDO.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/client.ts"],"names":["LOG_LEVEL_PRIORITY","VALID_LOG_LEVELS","isLogContext","formatLogMessageWithContext","formatLogMessage"],"mappings":";;;;;AAOA,SAAS,SAAA,CAAU,UAAoB,QAAA,EAA6B;AAClE,EAAA,OAAOA,oCAAA,CAAmB,QAAQ,CAAA,IAAKA,oCAAA,CAAmB,QAAQ,CAAA;AACpE;AAKO,SAAS,kBAAA,CAAmB,MAAA,GAAuB,EAAC,EAAW;AACpE,EAAA,MAAM,EAAE,cAAA,GAAiB,GAAA,EAAK,gBAAgB,IAAA,EAAM,KAAA,GAAQ,SAAQ,GAAI,MAAA;AAGxE,EAAA,MAAM,QAAA,GAAqBC,kCAAA,CAAiB,QAAA,CAAS,KAAK,IAAI,KAAA,GAAQ,OAAA;AAEtE,EAAA,MAAM,eAAe,CACnB,QAAA,EACA,cACA,aAAA,EACA,YAAA,EACA,mBACA,eAAA,KACS;AACT,IAAA,IAAI,CAAC,aAAA,EAAe;AACpB,IAAA,IAAI,CAAC,SAAA,CAAU,QAAA,EAAU,QAAQ,CAAA,EAAG;AAEpC,IAAA,IAAI,gBAAA;AAEJ,IAAA,IAAIC,8BAAA,CAAa,YAAY,CAAA,EAAG;AAE9B,MAAA,gBAAA,GAAmBC,6CAAA;AAAA,QACjB,YAAA;AAAA,QACA,iBAAA,IAAqB,EAAA;AAAA,QACrB,YAAA;AAAA,QACA,eAAA;AAAA,QACA;AAAA,OACF;AAAA,IACF,CAAA,MAAO;AAEL,MAAA,gBAAA,GAAmBC,kCAAA;AAAA,QACjB,YAAA;AAAA,QACA,YAAA;AAAA,QACC,iBAAA,IAAgC,IAAA;AAAA,QAChC,eAAA,IAAsC,IAAA;AAAA,QACvC;AAAA,OACF;AAAA,IACF;AAEA,IAAA,aAAA,CAAc,gBAAgB,CAAA;AAAA,EAChC,CAAA;AAEA,EAAA,OAAO;AAAA,IACL,KAAA,EAAO,CACL,YAAA,EACA,iBAAA,EACA,aAAA,KACG;AACH,MAAA,YAAA,CAAa,SAAS,OAAA,EAAS,OAAA,CAAQ,KAAA,EAAO,YAAA,EAAc,mBAAmB,aAAa,CAAA;AAAA,IAC9F,CAAA;AAAA,IACA,IAAA,EAAM,CACJ,YAAA,EACA,iBAAA,EACA,aAAA,KACG;AACH,MAAA,YAAA,CAAa,QAAQ,MAAA,EAAQ,OAAA,CAAQ,IAAA,EAAM,YAAA,EAAc,mBAAmB,aAAa,CAAA;AAAA,IAC3F,CAAA;AAAA,IACA,IAAA,EAAM,CACJ,YAAA,EACA,iBAAA,EACA,aAAA,KACG;AACH,MAAA,YAAA,CAAa,QAAQ,MAAA,EAAQ,OAAA,CAAQ,IAAA,EAAM,YAAA,EAAc,mBAAmB,aAAa,CAAA;AAAA,IAC3F,CAAA;AAAA,IACA,KAAA,EAAO,CACL,YAAA,EACA,iBAAA,EACA,aAAA,KACG;AACH,MAAA,YAAA,CAAa,SAAS,OAAA,EAAS,OAAA,CAAQ,KAAA,EAAO,YAAA,EAAc,mBAAmB,aAAa,CAAA;AAAA,IAC9F,CAAA;AAAA,IACA,KAAA,EAAO,CACL,YAAA,EACA,iBAAA,EACA,aAAA,KACG;AACH,MAAA,YAAA,CAAa,SAAS,OAAA,EAAS,OAAA,CAAQ,KAAA,EAAO,YAAA,EAAc,mBAAmB,aAAa,CAAA;AAAA,IAC9F,CAAA;AAAA,IACA,QAAA,EAAU,CACR,OAAA,EACA,QAAA,EACA,aAAA,KACG;AAEH,MAAA,YAAA,CAAa,SAAS,WAAA,EAAa,OAAA,CAAQ,KAAA,EAAO,OAAA,EAAS,UAAU,aAAa,CAAA;AAAA,IACpF;AAAA,GACF;AACF","file":"chunk-UDIZDVDO.cjs","sourcesContent":["import { LOG_LEVEL_PRIORITY, VALID_LOG_LEVELS } from './constants.js';\nimport type { LogContext, LogLevel, Logger, LoggerConfig } from './types.js';\nimport { formatLogMessage, formatLogMessageWithContext, isLogContext } from './utils.js';\n\n/**\n * 指定されたログレベルが最小レベル以上かどうかを判定\n */\nfunction shouldLog(logLevel: LogLevel, minLevel: LogLevel): boolean {\n return LOG_LEVEL_PRIORITY[logLevel] >= LOG_LEVEL_PRIORITY[minLevel];\n}\n\n/**\n * クライアントサイド用ロガーを作成\n */\nexport function createClientLogger(config: LoggerConfig = {}): Logger {\n const { timezoneOffset = 540, enableConsole = true, level = 'debug' } = config;\n\n // 有効なログレベルかどうかを検証\n const minLevel: LogLevel = VALID_LOG_LEVELS.includes(level) ? level : 'debug';\n\n const logToConsole = (\n logLevel: LogLevel,\n displayLevel: string,\n consoleMethod: (...args: unknown[]) => void,\n ctxOrMessage: LogContext | string,\n messageOrLocation?: string | null,\n errorOrOriginal?: unknown\n ): void => {\n if (!enableConsole) return;\n if (!shouldLog(logLevel, minLevel)) return;\n\n let formattedMessage: string;\n\n if (isLogContext(ctxOrMessage)) {\n // 構造化コンテキスト形式: (ctx, message, error?)\n formattedMessage = formatLogMessageWithContext(\n displayLevel,\n messageOrLocation ?? '',\n ctxOrMessage,\n errorOrOriginal,\n timezoneOffset\n );\n } else {\n // レガシー形式: (message, location?, originalError?)\n formattedMessage = formatLogMessage(\n displayLevel,\n ctxOrMessage,\n (messageOrLocation as string) ?? null,\n (errorOrOriginal as Error | string) ?? null,\n timezoneOffset\n );\n }\n\n consoleMethod(formattedMessage);\n };\n\n return {\n debug: (\n ctxOrMessage: LogContext | string,\n messageOrLocation?: string | null,\n originalError?: unknown\n ) => {\n logToConsole('debug', 'debug', console.debug, ctxOrMessage, messageOrLocation, originalError);\n },\n info: (\n ctxOrMessage: LogContext | string,\n messageOrLocation?: string | null,\n originalError?: unknown\n ) => {\n logToConsole('info', 'info', console.info, ctxOrMessage, messageOrLocation, originalError);\n },\n warn: (\n ctxOrMessage: LogContext | string,\n messageOrLocation?: string | null,\n originalError?: unknown\n ) => {\n logToConsole('warn', 'warn', console.warn, ctxOrMessage, messageOrLocation, originalError);\n },\n error: (\n ctxOrMessage: LogContext | string,\n messageOrLocation?: string | null,\n originalError?: unknown\n ) => {\n logToConsole('error', 'error', console.error, ctxOrMessage, messageOrLocation, originalError);\n },\n fatal: (\n ctxOrMessage: LogContext | string,\n messageOrLocation?: string | null,\n originalError?: unknown\n ) => {\n logToConsole('fatal', 'fatal', console.error, ctxOrMessage, messageOrLocation, originalError);\n },\n sqlError: (\n message: string,\n location?: string | null,\n originalError?: Error | string | null\n ) => {\n // sqlErrorはerrorレベルとしてフィルタリング、表示はsql_error\n logToConsole('error', 'sql_error', console.error, message, location, originalError);\n },\n } as Logger;\n}\n"]}
@@ -0,0 +1,165 @@
1
+ import { Level } from 'pino';
2
+
3
+ /**
4
+ * ログコンテキスト(構造化ログ用)
5
+ */
6
+ interface LogContext {
7
+ /** APIパス */
8
+ path?: string;
9
+ /** HTTPメソッド */
10
+ method?: string;
11
+ /** ユーザーID */
12
+ userId?: string;
13
+ /** テナントID */
14
+ tenantId?: string;
15
+ /** ファイル位置(レガシー互換) */
16
+ location?: string;
17
+ /** その他の任意データ */
18
+ [key: string]: unknown;
19
+ }
20
+ /**
21
+ * ログメソッドのシグネチャ(レガシー形式)
22
+ */
23
+ type LogMethod = (message: string, location?: string | null, originalError?: Error | string | null) => void;
24
+ /**
25
+ * ログメソッドのシグネチャ(構造化コンテキスト形式)
26
+ */
27
+ type LogMethodWithContext = (ctx: LogContext, message: string, error?: unknown) => void;
28
+ /**
29
+ * Loggerインターフェース(オーバーロード対応)
30
+ */
31
+ interface Logger {
32
+ debug(ctx: LogContext, message: string): void;
33
+ info(ctx: LogContext, message: string): void;
34
+ warn(ctx: LogContext, message: string): void;
35
+ error(ctx: LogContext, message: string, error?: unknown): void;
36
+ fatal(ctx: LogContext, message: string, error?: unknown): void;
37
+ debug(message: string, location?: string | null, originalError?: Error | string | null): void;
38
+ info(message: string, location?: string | null, originalError?: Error | string | null): void;
39
+ warn(message: string, location?: string | null, originalError?: Error | string | null): void;
40
+ error(message: string, location?: string | null, originalError?: Error | string | null): void;
41
+ fatal(message: string, location?: string | null, originalError?: Error | string | null): void;
42
+ sqlError(message: string, location?: string | null, originalError?: Error | string | null): void;
43
+ }
44
+ /**
45
+ * ログレベル
46
+ */
47
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'fatal';
48
+ /**
49
+ * ログタイプの設定
50
+ */
51
+ interface LogTypeConfig {
52
+ fileNamePrefix: string;
53
+ level: Level;
54
+ }
55
+ /**
56
+ * Sentryモジュールの型
57
+ * @sentry/node と @sentry/nextjs の両方で使用可能
58
+ * メソッド構文を使用して双変(bivariant)にし、型互換性を確保
59
+ */
60
+ interface SentryModule {
61
+ /**
62
+ * 例外をSentryに送信
63
+ */
64
+ captureException(error: unknown, hint?: {
65
+ extra?: Record<string, unknown>;
66
+ }): string;
67
+ /**
68
+ * メッセージをSentryに送信
69
+ */
70
+ captureMessage(message: string, captureContext?: unknown): string;
71
+ }
72
+ /**
73
+ * ロガー設定オプション
74
+ */
75
+ interface LoggerConfig {
76
+ /**
77
+ * ログ出力ディレクトリ(サーバーサイドのみ)
78
+ * デフォルト: process.cwd() + '/logs'
79
+ */
80
+ logDir?: string;
81
+ /**
82
+ * 最小ログレベル
83
+ * デフォルト: 'debug'
84
+ */
85
+ level?: LogLevel;
86
+ /**
87
+ * ログローテーションのチェック間隔(ミリ秒)
88
+ * デフォルト: 3600000 (1時間)
89
+ */
90
+ rotationCheckInterval?: number;
91
+ /**
92
+ * タイムゾーンオフセット(分)
93
+ * デフォルト: 540 (JST = UTC+9)
94
+ */
95
+ timezoneOffset?: number;
96
+ /**
97
+ * クライアントサイドでコンソール出力を有効化
98
+ * デフォルト: true
99
+ */
100
+ enableConsole?: boolean;
101
+ /**
102
+ * Sentry連携を有効化
103
+ * @default false
104
+ */
105
+ enableSentry?: boolean;
106
+ }
107
+
108
+ /**
109
+ * クライアントサイド用ロガーを作成
110
+ */
111
+ declare function createClientLogger(config?: LoggerConfig): Logger;
112
+
113
+ /**
114
+ * Sentry連携ヘルパー
115
+ */
116
+
117
+ /**
118
+ * Sentryモジュールを設定
119
+ */
120
+ declare function setSentryModule(sentry: SentryModule): void;
121
+ /**
122
+ * Sentryが有効かどうか
123
+ */
124
+ declare function isSentryEnabled(): boolean;
125
+
126
+ /**
127
+ * ログレベル関連の定数
128
+ */
129
+
130
+ /**
131
+ * 有効なログレベル一覧
132
+ * LogLevel型と同期した配列
133
+ */
134
+ declare const VALID_LOG_LEVELS: readonly LogLevel[];
135
+ /**
136
+ * ログレベルの優先度マップ
137
+ * 数値が大きいほど優先度が高い
138
+ */
139
+ declare const LOG_LEVEL_PRIORITY: Record<LogLevel, number>;
140
+ /**
141
+ * タイムゾーン関連
142
+ */
143
+ declare const TIMEZONE: {
144
+ /** 日本標準時(JST)のUTCオフセット(分) */
145
+ JST_OFFSET_MINUTES: number;
146
+ };
147
+ /**
148
+ * ログローテーション関連
149
+ */
150
+ declare const LOG_ROTATION: {
151
+ /** デフォルトのローテーションチェック間隔(ミリ秒): 1時間 */
152
+ readonly DEFAULT_CHECK_INTERVAL_MS: number;
153
+ };
154
+ /**
155
+ * ログファイル名プレフィックス
156
+ */
157
+ declare const LOG_FILE_PREFIX: {
158
+ readonly DEBUG: "debug_log";
159
+ readonly INFO: "info_log";
160
+ readonly ERROR: "error_log";
161
+ readonly FATAL: "fatal_log";
162
+ readonly SQL_ERROR: "sql_error_log";
163
+ };
164
+
165
+ export { type Logger as L, type SentryModule as S, TIMEZONE as T, VALID_LOG_LEVELS as V, type LoggerConfig as a, type LogContext as b, type LogLevel as c, type LogMethod as d, type LogMethodWithContext as e, type LogTypeConfig as f, createClientLogger as g, LOG_FILE_PREFIX as h, isSentryEnabled as i, LOG_LEVEL_PRIORITY as j, LOG_ROTATION as k, setSentryModule as s };
@@ -0,0 +1,165 @@
1
+ import { Level } from 'pino';
2
+
3
+ /**
4
+ * ログコンテキスト(構造化ログ用)
5
+ */
6
+ interface LogContext {
7
+ /** APIパス */
8
+ path?: string;
9
+ /** HTTPメソッド */
10
+ method?: string;
11
+ /** ユーザーID */
12
+ userId?: string;
13
+ /** テナントID */
14
+ tenantId?: string;
15
+ /** ファイル位置(レガシー互換) */
16
+ location?: string;
17
+ /** その他の任意データ */
18
+ [key: string]: unknown;
19
+ }
20
+ /**
21
+ * ログメソッドのシグネチャ(レガシー形式)
22
+ */
23
+ type LogMethod = (message: string, location?: string | null, originalError?: Error | string | null) => void;
24
+ /**
25
+ * ログメソッドのシグネチャ(構造化コンテキスト形式)
26
+ */
27
+ type LogMethodWithContext = (ctx: LogContext, message: string, error?: unknown) => void;
28
+ /**
29
+ * Loggerインターフェース(オーバーロード対応)
30
+ */
31
+ interface Logger {
32
+ debug(ctx: LogContext, message: string): void;
33
+ info(ctx: LogContext, message: string): void;
34
+ warn(ctx: LogContext, message: string): void;
35
+ error(ctx: LogContext, message: string, error?: unknown): void;
36
+ fatal(ctx: LogContext, message: string, error?: unknown): void;
37
+ debug(message: string, location?: string | null, originalError?: Error | string | null): void;
38
+ info(message: string, location?: string | null, originalError?: Error | string | null): void;
39
+ warn(message: string, location?: string | null, originalError?: Error | string | null): void;
40
+ error(message: string, location?: string | null, originalError?: Error | string | null): void;
41
+ fatal(message: string, location?: string | null, originalError?: Error | string | null): void;
42
+ sqlError(message: string, location?: string | null, originalError?: Error | string | null): void;
43
+ }
44
+ /**
45
+ * ログレベル
46
+ */
47
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'fatal';
48
+ /**
49
+ * ログタイプの設定
50
+ */
51
+ interface LogTypeConfig {
52
+ fileNamePrefix: string;
53
+ level: Level;
54
+ }
55
+ /**
56
+ * Sentryモジュールの型
57
+ * @sentry/node と @sentry/nextjs の両方で使用可能
58
+ * メソッド構文を使用して双変(bivariant)にし、型互換性を確保
59
+ */
60
+ interface SentryModule {
61
+ /**
62
+ * 例外をSentryに送信
63
+ */
64
+ captureException(error: unknown, hint?: {
65
+ extra?: Record<string, unknown>;
66
+ }): string;
67
+ /**
68
+ * メッセージをSentryに送信
69
+ */
70
+ captureMessage(message: string, captureContext?: unknown): string;
71
+ }
72
+ /**
73
+ * ロガー設定オプション
74
+ */
75
+ interface LoggerConfig {
76
+ /**
77
+ * ログ出力ディレクトリ(サーバーサイドのみ)
78
+ * デフォルト: process.cwd() + '/logs'
79
+ */
80
+ logDir?: string;
81
+ /**
82
+ * 最小ログレベル
83
+ * デフォルト: 'debug'
84
+ */
85
+ level?: LogLevel;
86
+ /**
87
+ * ログローテーションのチェック間隔(ミリ秒)
88
+ * デフォルト: 3600000 (1時間)
89
+ */
90
+ rotationCheckInterval?: number;
91
+ /**
92
+ * タイムゾーンオフセット(分)
93
+ * デフォルト: 540 (JST = UTC+9)
94
+ */
95
+ timezoneOffset?: number;
96
+ /**
97
+ * クライアントサイドでコンソール出力を有効化
98
+ * デフォルト: true
99
+ */
100
+ enableConsole?: boolean;
101
+ /**
102
+ * Sentry連携を有効化
103
+ * @default false
104
+ */
105
+ enableSentry?: boolean;
106
+ }
107
+
108
+ /**
109
+ * クライアントサイド用ロガーを作成
110
+ */
111
+ declare function createClientLogger(config?: LoggerConfig): Logger;
112
+
113
+ /**
114
+ * Sentry連携ヘルパー
115
+ */
116
+
117
+ /**
118
+ * Sentryモジュールを設定
119
+ */
120
+ declare function setSentryModule(sentry: SentryModule): void;
121
+ /**
122
+ * Sentryが有効かどうか
123
+ */
124
+ declare function isSentryEnabled(): boolean;
125
+
126
+ /**
127
+ * ログレベル関連の定数
128
+ */
129
+
130
+ /**
131
+ * 有効なログレベル一覧
132
+ * LogLevel型と同期した配列
133
+ */
134
+ declare const VALID_LOG_LEVELS: readonly LogLevel[];
135
+ /**
136
+ * ログレベルの優先度マップ
137
+ * 数値が大きいほど優先度が高い
138
+ */
139
+ declare const LOG_LEVEL_PRIORITY: Record<LogLevel, number>;
140
+ /**
141
+ * タイムゾーン関連
142
+ */
143
+ declare const TIMEZONE: {
144
+ /** 日本標準時(JST)のUTCオフセット(分) */
145
+ JST_OFFSET_MINUTES: number;
146
+ };
147
+ /**
148
+ * ログローテーション関連
149
+ */
150
+ declare const LOG_ROTATION: {
151
+ /** デフォルトのローテーションチェック間隔(ミリ秒): 1時間 */
152
+ readonly DEFAULT_CHECK_INTERVAL_MS: number;
153
+ };
154
+ /**
155
+ * ログファイル名プレフィックス
156
+ */
157
+ declare const LOG_FILE_PREFIX: {
158
+ readonly DEBUG: "debug_log";
159
+ readonly INFO: "info_log";
160
+ readonly ERROR: "error_log";
161
+ readonly FATAL: "fatal_log";
162
+ readonly SQL_ERROR: "sql_error_log";
163
+ };
164
+
165
+ export { type Logger as L, type SentryModule as S, TIMEZONE as T, VALID_LOG_LEVELS as V, type LoggerConfig as a, type LogContext as b, type LogLevel as c, type LogMethod as d, type LogMethodWithContext as e, type LogTypeConfig as f, createClientLogger as g, LOG_FILE_PREFIX as h, isSentryEnabled as i, LOG_LEVEL_PRIORITY as j, LOG_ROTATION as k, setSentryModule as s };