@crimsonsunset/jsg-logger 1.7.8 → 1.7.11
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/index.js +14 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import {createCLIFormatter} from './formatters/cli-formatter.js';
|
|
|
13
13
|
import {createServerFormatter, getServerConfig} from './formatters/server-formatter.js';
|
|
14
14
|
import {LogStore} from './stores/log-store.js';
|
|
15
15
|
import {metaLog, metaWarn, metaError} from './utils/meta-logger.js';
|
|
16
|
+
import packageJson from './package.json' with {type: 'json'};
|
|
16
17
|
|
|
17
18
|
// Check default config for devtools at module load time
|
|
18
19
|
// This allows bundlers to tree-shake if disabled
|
|
@@ -47,6 +48,7 @@ class JSGLogger {
|
|
|
47
48
|
// Static singleton instance
|
|
48
49
|
static _instance = null;
|
|
49
50
|
static _enhancedLoggers = null;
|
|
51
|
+
static _hasLoggedInitialization = false;
|
|
50
52
|
|
|
51
53
|
constructor() {
|
|
52
54
|
this.loggers = {};
|
|
@@ -152,15 +154,17 @@ class JSGLogger {
|
|
|
152
154
|
|
|
153
155
|
this.initialized = true;
|
|
154
156
|
|
|
155
|
-
// Log initialization success
|
|
156
|
-
if (this.loggers.core) {
|
|
157
|
+
// Log initialization success (only on first initialization)
|
|
158
|
+
if (!JSGLogger._hasLoggedInitialization && this.loggers.core) {
|
|
157
159
|
this.loggers.core.info('JSG Logger initialized', {
|
|
160
|
+
version: packageJson.version,
|
|
158
161
|
environment: this.environment,
|
|
159
162
|
components: components.length,
|
|
160
163
|
projectName: configManager.getProjectName(),
|
|
161
164
|
configPaths: configManager.loadedPaths,
|
|
162
165
|
fileOverrides: Object.keys(configManager.config.fileOverrides || {}).length
|
|
163
166
|
});
|
|
167
|
+
JSGLogger._hasLoggedInitialization = true;
|
|
164
168
|
}
|
|
165
169
|
|
|
166
170
|
return this.getLoggerExports();
|
|
@@ -183,6 +187,9 @@ class JSGLogger {
|
|
|
183
187
|
*/
|
|
184
188
|
initSync(options = {}) {
|
|
185
189
|
try {
|
|
190
|
+
// Track if this is a reinitialization (already initialized)
|
|
191
|
+
const isReinit = this.initialized;
|
|
192
|
+
|
|
186
193
|
// Load inline config if provided (sync loading for objects)
|
|
187
194
|
if (options && Object.keys(options).length > 0) {
|
|
188
195
|
// Reset to default config for clean reinitialization
|
|
@@ -229,15 +236,18 @@ class JSGLogger {
|
|
|
229
236
|
|
|
230
237
|
this.initialized = true;
|
|
231
238
|
|
|
232
|
-
// Log initialization success
|
|
233
|
-
|
|
239
|
+
// Log initialization success (only on first initialization, not on reinit)
|
|
240
|
+
// This prevents duplicate logs when multiple libraries call getInstanceSync
|
|
241
|
+
if (!JSGLogger._hasLoggedInitialization && !isReinit && this.loggers.core) {
|
|
234
242
|
this.loggers.core.info('JSG Logger initialized (sync)', {
|
|
243
|
+
version: packageJson.version,
|
|
235
244
|
environment: this.environment,
|
|
236
245
|
components: components.length,
|
|
237
246
|
projectName: configManager.getProjectName(),
|
|
238
247
|
fileOverrides: Object.keys(configManager.config.fileOverrides || {}).length,
|
|
239
248
|
timestampMode: configManager.getTimestampMode()
|
|
240
249
|
});
|
|
250
|
+
JSGLogger._hasLoggedInitialization = true;
|
|
241
251
|
}
|
|
242
252
|
|
|
243
253
|
return this.getLoggerExports();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crimsonsunset/jsg-logger",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Multi-environment logger with smart detection, file-level overrides, and beautiful console formatting. Test it live: https://logger.joesangiorgio.com/",
|
|
6
6
|
"main": "index.js",
|