egg 3.5.1 → 3.7.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/History.md CHANGED
@@ -1,13 +1,41 @@
1
+ # History
1
2
 
2
- 3.5.1 / 2022-11-28
3
- ==================
3
+ ## 2022-12-11, Version 3.7.0 @fengmk2
4
4
 
5
- **fixes**
6
- * [[`c859506a0`](http://github.com/eggjs/egg/commit/c859506a094181f5f45db16a8501daaaea56b3d3)] - fix: dump config/timing when timeout (#5069) (killa <<killa123@126.com>>)
5
+ ### Notable Changes
7
6
 
8
- **others**
9
- * [[`ee2f0614a`](http://github.com/eggjs/egg/commit/ee2f0614af85e4293240b768c09b2c4e3da0ec1d)] - chore: Change version to 3.5.0 (fengmk2 <<fengmk2@gmail.com>>),
10
- # History
7
+ * **features**
8
+ * 📦 NEW: Set `config.logger.enableFastContextLogger = true` to enable faster context logger
9
+
10
+ ### Commits
11
+
12
+ * [[`e94c7df63`](http://github.com/eggjs/egg/commit/e94c7df63e1812da672dbaf7200e652cc4537c7b)] - 📦 NEW: Upgrade egg-logger v3 to enable localStorage (#5085) (fengmk2 <<fengmk2@gmail.com>>)
13
+ * [[`c76e16cf7`](http://github.com/eggjs/egg/commit/c76e16cf7fb67d5f2c1b19252e01a5e3fed9cf96)] - 📖 DOC: Use @eggjs/tsconfig for tsconfig.json (#5066) (fengmk2 <<fengmk2@gmail.com>>)
14
+
15
+ ## 2022-12-09, Version 3.6.0 @fengmk2
16
+
17
+ ### Notable Changes
18
+
19
+ * **features**
20
+ * 🚀🚀🚀 Support `app.ctxStorage` and `app.currentContext` to get current execute ctx, see [koa#1455](https://github.com/koajs/koa/pull/1455)
21
+
22
+ ### Commits
23
+
24
+ * [[`bf36904e0`](http://github.com/eggjs/egg/commit/bf36904e0fb1d4477ebb7068dd8ad6726d29182f)] - 📦 NEW: Add ctxStorage and currentContext d.ts (#5079) (fengmk2 <<fengmk2@gmail.com>>)
25
+ * [[`c68992ab7`](http://github.com/eggjs/egg/commit/c68992ab71b854f825df0ff3ea4b82e7666ec828)] - chore: ignore gp-pages branch while deploying preview (#5077) (Suyi <<thonatos.yang@gmail.com>>)
26
+ * [[`13906825b`](http://github.com/eggjs/egg/commit/13906825bc3fab260aa0dd8888ce9fd19f2f70c5)] - chore: use actions to deploy vercel project (#5076) (Suyi <<thonatos.yang@gmail.com>>)
27
+ * [[`5d825bb59`](http://github.com/eggjs/egg/commit/5d825bb59ed691bd45c3a8b2f6c222496910e250)] - docs: update communite links (#5073) (Suyi <<thonatos.yang@gmail.com>>)
28
+
29
+ ## 2022-11-28, Version 3.5.1 @killagu
30
+
31
+ ### Notable Changes
32
+
33
+ * **fixes**
34
+ * Dump `config/timing` when app start timeout
35
+
36
+ ### Commits
37
+
38
+ * [[`c859506a0`](http://github.com/eggjs/egg/commit/c859506a094181f5f45db16a8501daaaea56b3d3)] - fix: dump config/timing when timeout (#5069) (killa <<killa123@126.com>>)
11
39
 
12
40
  ## 2022-11-15, Version 3.5.0 @fengmk2
13
41
 
@@ -95,6 +95,9 @@ const proto = module.exports = {
95
95
  * @return {Logger} logger
96
96
  */
97
97
  getLogger(name) {
98
+ if (this.app.config.logger.enableFastContextLogger) {
99
+ return this.app.getLogger(name);
100
+ }
98
101
  let cache = this[CONTEXT_LOGGERS];
99
102
  if (!cache) {
100
103
  cache = this[CONTEXT_LOGGERS] = {};
@@ -258,6 +258,7 @@ module.exports = appInfo => {
258
258
  * @property {Object} coreLogger - custom config of coreLogger
259
259
  * @property {Boolean} allowDebugAtProd - allow debug log at prod, defaults to false
260
260
  * @property {Boolean} enablePerformanceTimer - using performance.now() timer instead of Date.now() for more more precise milliseconds, defaults to false. e.g.: logger will set 1.456ms instead of 1ms.
261
+ * @property {Boolean} enableFastContextLogger - using the app logger instead of EggContextLogger, defaults to false
261
262
  */
262
263
  config.logger = {
263
264
  dir: path.join(appInfo.root, 'logs', appInfo.name),
@@ -275,6 +276,7 @@ module.exports = appInfo => {
275
276
  coreLogger: {},
276
277
  allowDebugAtProd: false,
277
278
  enablePerformanceTimer: false,
279
+ enableFastContextLogger: false,
278
280
  };
279
281
 
280
282
  /**
package/index.d.ts CHANGED
@@ -2,11 +2,19 @@
2
2
  import accepts = require('accepts');
3
3
  import KoaApplication = require('koa');
4
4
  import KoaRouter = require('koa-router');
5
+ import { AsyncLocalStorage } from 'async_hooks';
5
6
  import { EventEmitter } from 'events'
6
7
  import { Readable } from 'stream';
7
8
  import { Socket } from 'net';
8
9
  import { IncomingMessage, ServerResponse } from 'http';
9
- import { EggLogger as Logger, EggLoggers, LoggerLevel as EggLoggerLevel, EggLoggersOptions, EggLoggerOptions, EggContextLogger } from 'egg-logger';
10
+ import {
11
+ EggLogger as Logger,
12
+ EggLoggers,
13
+ LoggerLevel as EggLoggerLevel,
14
+ EggLoggersOptions,
15
+ EggLoggerOptions,
16
+ EggContextLogger
17
+ } from 'egg-logger';
10
18
  import { HttpClient, RequestOptions2 as RequestOptions } from 'urllib';
11
19
  import {
12
20
  EggCoreBase,
@@ -223,6 +231,8 @@ declare module 'egg' {
223
231
  disableConsoleAfterReady?: boolean;
224
232
  /** using performance.now() timer instead of Date.now() for more more precise milliseconds, defaults to `false`. e.g.: logger will set 1.456ms instead of 1ms. */
225
233
  enablePerformanceTimer?: boolean;
234
+ /** using the app logger instead of EggContextLogger, defaults to `false` */
235
+ enableFastContextLogger?: boolean;
226
236
  }
227
237
 
228
238
  /** Custom Loader Configuration */
@@ -335,6 +345,7 @@ declare module 'egg' {
335
345
  * @property {Object} coreLogger - custom config of coreLogger
336
346
  * @property {Boolean} allowDebugAtProd - allow debug log at prod, defaults to false
337
347
  * @property {Boolean} enablePerformanceTimer - using performance.now() timer instead of Date.now() for more more precise milliseconds, defaults to false. e.g.: logger will set 1.456ms instead of 1ms.
348
+ * @property {Boolean} enableFastContextLogger - using the app logger instead of EggContextLogger, defaults to false
338
349
  */
339
350
  logger: EggLoggerConfig;
340
351
 
@@ -683,6 +694,18 @@ declare module 'egg' {
683
694
  * @param {Function} scope - the first args is an anonymous ctx
684
695
  */
685
696
  runInBackground(scope: (ctx: Context) => void): void;
697
+
698
+ /**
699
+ * Get current execute ctx async local storage
700
+ * @returns {AsyncLocalStorage} localStorage - store current execute Context
701
+ */
702
+ get ctxStorage(): AsyncLocalStorage<Context>;
703
+
704
+ /**
705
+ * Get current execute ctx, maybe undefined
706
+ * @returns {Context} ctx - current execute Context
707
+ */
708
+ get currentConext(): Context;
686
709
  }
687
710
 
688
711
  export interface IApplicationLocals extends PlainObject { }
@@ -5,6 +5,7 @@ const Loggers = require('egg-logger').EggLoggers;
5
5
  module.exports = function createLoggers(app) {
6
6
  const loggerConfig = app.config.logger;
7
7
  loggerConfig.type = app.type;
8
+ loggerConfig.localStorage = app.ctxStorage;
8
9
 
9
10
  if (app.config.env === 'prod' && loggerConfig.level === 'DEBUG' && !loggerConfig.allowDebugAtProd) {
10
11
  loggerConfig.level = 'INFO';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "egg",
3
- "version": "3.5.1",
3
+ "version": "3.7.0",
4
4
  "publishConfig": {
5
5
  "tag": "next"
6
6
  },
@@ -28,12 +28,12 @@
28
28
  "delegates": "^1.0.0",
29
29
  "egg-cluster": "^2.0.0",
30
30
  "egg-cookies": "^2.6.1",
31
- "egg-core": "^4.26.1",
31
+ "egg-core": "^4.29.0",
32
32
  "egg-development": "^2.7.0",
33
33
  "egg-errors": "^2.3.1",
34
34
  "egg-i18n": "^2.1.1",
35
35
  "egg-jsonp": "^2.0.0",
36
- "egg-logger": "^2.9.0",
36
+ "egg-logger": "^3.0.1",
37
37
  "egg-logrotator": "^3.1.0",
38
38
  "egg-multipart": "^3.1.0",
39
39
  "egg-onerror": "^2.1.1",