Skip to content

Commit 2aeb0e2

Browse files
authored
fix: deprecated should print to stdout (#281)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Chores** - Updated logging namespaces from `@eggjs/core:*` to `@eggjs/core/*` across multiple files - Standardized debug and error logging formats - Minor adjustments to logging messages in test cases - **Documentation** - Improved consistency in logging message formats Note: These changes do not impact the core functionality of the application and are primarily related to internal logging conventions. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent cb0a099 commit 2aeb0e2

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

Diff for: src/egg.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Lifecycle } from './lifecycle.js';
2020
import { EggLoader } from './loader/egg_loader.js';
2121
import utils from './utils/index.js';
2222

23-
const debug = debuglog('@eggjs/core:egg');
23+
const debug = debuglog('@eggjs/core/egg');
2424

2525
export const EGG_LOADER = Symbol.for('egg#loader');
2626

Diff for: src/loader/egg_loader.ts

+8-8
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export class EggLoader {
135135
// eslint-disable-next-line @typescript-eslint/no-var-requires
136136
require('tsconfig-paths').register({ cwd: this.options.baseDir });
137137
} else {
138-
this.logger.info('[@eggjs/core:egg_loader] skip register "tsconfig-paths" because tsconfig.json not exists at %s',
138+
this.logger.info('[@eggjs/core/egg_loader] skip register "tsconfig-paths" because tsconfig.json not exists at %s',
139139
tsConfigFile);
140140
}
141141
}
@@ -639,14 +639,14 @@ export class EggLoader {
639639

640640
const logger = this.options.logger;
641641
if (!config) {
642-
logger.warn(`[@eggjs/core:egg_loader] pkg.eggPlugin is missing in ${pluginPackage}`);
642+
logger.warn(`[@eggjs/core/egg_loader] pkg.eggPlugin is missing in ${pluginPackage}`);
643643
return;
644644
}
645645

646646
if (config.name && config.strict !== false && config.name !== plugin.name) {
647647
// pluginName is configured in config/plugin.js
648648
// pluginConfigName is pkg.eggPlugin.name
649-
logger.warn(`[@eggjs/core:egg_loader] pluginName(${plugin.name}) is different from pluginConfigName(${config.name})`);
649+
logger.warn(`[@eggjs/core/egg_loader] pluginName(${plugin.name}) is different from pluginConfigName(${config.name})`);
650650
}
651651

652652
// dep compatible
@@ -1184,7 +1184,7 @@ export class EggLoader {
11841184
this.lifecycle.addFunctionAsBootHook(bootHook, bootFilePath);
11851185
debug('[loadBootHook] add bootHookFunction from %o', bootFilePath);
11861186
} else {
1187-
this.options.logger.warn('[@eggjs/core:egg_loader] %s must exports a boot class', bootFilePath);
1187+
this.options.logger.warn('[@eggjs/core/egg_loader] %s must exports a boot class', bootFilePath);
11881188
}
11891189
}
11901190
// init boots
@@ -1295,13 +1295,13 @@ export class EggLoader {
12951295
}
12961296
app.use(mw);
12971297
debug('[loadMiddleware] Use middleware: %s with options: %j', name, options);
1298-
this.options.logger.info('[@eggjs/core:egg_loader] Use middleware: %s', name);
1298+
this.options.logger.info('[@eggjs/core/egg_loader] Use middleware: %s', name);
12991299
} else {
1300-
this.options.logger.info('[@eggjs/core:egg_loader] Disable middleware: %s', name);
1300+
this.options.logger.info('[@eggjs/core/egg_loader] Disable middleware: %s', name);
13011301
}
13021302
}
13031303

1304-
this.options.logger.info('[@eggjs/core:egg_loader] Loaded middleware from %j', middlewarePaths);
1304+
this.options.logger.info('[@eggjs/core/egg_loader] Loaded middleware from %j', middlewarePaths);
13051305
this.timing.end('Load Middleware');
13061306

13071307
// add router middleware, make sure router is the last middleware
@@ -1359,7 +1359,7 @@ export class EggLoader {
13591359
};
13601360
await this.loadToApp(controllerBase, 'controller', opt as FileLoaderOptions);
13611361
debug('[loadController] app.controller => %o', this.app.controller);
1362-
this.options.logger.info('[@eggjs/core:egg_loader] Controller loaded: %s', controllerBase);
1362+
this.options.logger.info('[@eggjs/core/egg_loader] Controller loaded: %s', controllerBase);
13631363
this.timing.end('Load Controller');
13641364
}
13651365
/** end Controller loader */

Diff for: src/utils/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { stat } from 'node:fs/promises';
55
import BuiltinModule from 'node:module';
66
import { importResolve, importModule } from '@eggjs/utils';
77

8-
const debug = debuglog('@eggjs/core:utils');
8+
const debug = debuglog('@eggjs/core/utils');
99

1010
export type Fun = (...args: any[]) => any;
1111

@@ -55,10 +55,10 @@ function getCalleeFromStack(withLine?: boolean, stackIndex?: number) {
5555
export default {
5656
deprecated(message: string) {
5757
if (debug.enabled) {
58-
console.trace('[@eggjs/core:deprecated] %s', message);
58+
console.trace('[@eggjs/core/deprecated] %s', message);
5959
} else {
60-
console.warn('[@eggjs/core:deprecated] %s', message);
61-
console.warn('[@eggjs/core:deprecated] set NODE_DEBUG=@eggjs/core:utils can show call stack');
60+
console.log('[@eggjs/core/deprecated] %s', message);
61+
console.log('[@eggjs/core/deprecated] set NODE_DEBUG=@eggjs/core/utils can show call stack');
6262
}
6363
},
6464

Diff for: src/utils/sequencify.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { debuglog } from 'node:util';
22

3-
const debug = debuglog('@eggjs/core:utils:sequencify');
3+
const debug = debuglog('@eggjs/core/utils/sequencify');
44

55
export interface SequencifyResult {
66
sequence: string[];

Diff for: src/utils/timing.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { EOL } from 'node:os';
22
import { debuglog } from 'node:util';
33
import assert from 'node:assert';
44

5-
const debug = debuglog('@eggjs/core:utils:timing');
5+
const debug = debuglog('@eggjs/core/utils/timing');
66

77
export interface TimingItem {
88
name: string;

Diff for: test/loader/mixin/load_plugin.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -200,15 +200,15 @@ describe('test/loader/mixin/load_plugin.test.ts', () => {
200200
let message = '';
201201
app = createApp('plugin');
202202
mm(app.console, 'warn', function(m: string) {
203-
if (!m.startsWith('[@eggjs/core:egg_loader] eggPlugin is missing') && !message) {
203+
if (!m.startsWith('[@eggjs/core/egg_loader] eggPlugin is missing') && !message) {
204204
message = m;
205205
}
206206
});
207207
const loader = app.loader;
208208
await loader.loadPlugin();
209209
await loader.loadConfig();
210210

211-
assert.equal(message, '[@eggjs/core:egg_loader] pluginName(e) is different from pluginConfigName(wrong-name)');
211+
assert.equal(message, '[@eggjs/core/egg_loader] pluginName(e) is different from pluginConfigName(wrong-name)');
212212
});
213213

214214
it('should not warn when the config.strict is false', async () => {
@@ -496,7 +496,7 @@ describe('test/loader/mixin/load_plugin.test.ts', () => {
496496
await loader.loadPlugin();
497497
const plugin = loader.plugins.a;
498498
assert.equal(plugin.name, 'a');
499-
assert.equal(plugin.path, getFilepath('realpath/a'));
499+
assert.equal(plugin.path, getFilepath('realpath/node_modules/a'));
500500
});
501501

502502
it('should get the defining plugin path in every plugin', async () => {

0 commit comments

Comments
 (0)