@rife/logger 0.0.6-beta.18 → 0.0.6-beta.20

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.
@@ -26,12 +26,12 @@ var __webpack_modules__ = {
26
26
  "use strict";
27
27
  const WAIT_MS = 10000;
28
28
  function wait(state, index, expected, timeout, done) {
29
- const max = timeout === 1 / 0 ? 1 / 0 : Date.now() + timeout;
29
+ const max = 1 / 0 === timeout ? 1 / 0 : Date.now() + timeout;
30
30
  const check = ()=>{
31
31
  const current = Atomics.load(state, index);
32
32
  if (current === expected) return void done(null, 'ok');
33
- if (max !== 1 / 0 && Date.now() > max) return void done(null, 'timed-out');
34
- const remaining = max === 1 / 0 ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
33
+ if (1 / 0 !== max && Date.now() > max) return void done(null, 'timed-out');
34
+ const remaining = 1 / 0 === max ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
35
35
  const result = Atomics.waitAsync(state, index, current, remaining);
36
36
  if (result.async) result.value.then(check);
37
37
  else setImmediate(check);
@@ -39,12 +39,12 @@ var __webpack_modules__ = {
39
39
  check();
40
40
  }
41
41
  function waitDiff(state, index, expected, timeout, done) {
42
- const max = timeout === 1 / 0 ? 1 / 0 : Date.now() + timeout;
42
+ const max = 1 / 0 === timeout ? 1 / 0 : Date.now() + timeout;
43
43
  const check = ()=>{
44
44
  const current = Atomics.load(state, index);
45
45
  if (current !== expected) return void done(null, 'ok');
46
- if (max !== 1 / 0 && Date.now() > max) return void done(null, 'timed-out');
47
- const remaining = max === 1 / 0 ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
46
+ if (1 / 0 !== max && Date.now() > max) return void done(null, 'timed-out');
47
+ const remaining = 1 / 0 === max ? WAIT_MS : Math.min(WAIT_MS, Math.max(1, max - Date.now()));
48
48
  const result = Atomics.waitAsync(state, index, expected, remaining);
49
49
  if (result.async) result.value.then((res)=>{
50
50
  if ('ok' === res) return void done(null, 'ok');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rife/logger",
3
- "version": "0.0.6-beta.18",
3
+ "version": "0.0.6-beta.20",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "types": "./src/index.ts",
@@ -37,15 +37,15 @@
37
37
  "tsconfig.json"
38
38
  ],
39
39
  "dependencies": {
40
- "pino": "^10.3.1",
41
- "pino-pretty": "^13.1.3",
40
+ "pino": "^10.4.0",
41
+ "pino-pretty": "^13.2.0",
42
42
  "pino-std-serializers": "^7.1.0",
43
43
  "rotating-file-stream": "^3.2.9"
44
44
  },
45
45
  "devDependencies": {
46
- "thread-stream": "^4.0.0",
47
- "@rife/plugin-rstack": "0.0.1-beta.25",
48
- "@rife/cli": "0.0.6-beta.25"
46
+ "@rife/cli": "0.0.6-beta.28",
47
+ "@rife/plugin-rstack": "0.0.1-beta.27",
48
+ "thread-stream": "^4.0.0"
49
49
  },
50
50
  "scripts": {
51
51
  "dev": "rife dev",
package/src/pino/index.ts CHANGED
@@ -5,11 +5,12 @@ export { pino };
5
5
 
6
6
  import { genTraceId, getTraceId, runInTrace } from '../trace';
7
7
 
8
- declare var __isNodeSingleFileBundle: any;
9
- declare var __isVite: any;
8
+ declare let RSTACK_NODE_SINGLE_FILE_BUNDLE: any;
9
+
10
+ export type Logger = pino.Logger;
10
11
 
11
12
  // https://github.com/pinojs/pino/blob/master/docs/api.md
12
- function getPinoConfig() {
13
+ export function createLogger() {
13
14
  const targets: any = [];
14
15
 
15
16
  const rotate = `./rotate${path.extname(__filename)}`;
@@ -20,12 +21,7 @@ function getPinoConfig() {
20
21
  options: { path: './logs/' },
21
22
  });
22
23
 
23
- if (
24
- typeof __isNodeSingleFileBundle !== 'undefined' ||
25
- typeof __isVite !== 'undefined' || // remix
26
- (global as any)?.__remix_devServerHooks || // remix
27
- process.env.NODE_ENV !== 'development'
28
- ) {
24
+ if (typeof (RSTACK_NODE_SINGLE_FILE_BUNDLE as any) !== 'undefined' || process.env.NODE_ENV !== 'development') {
29
25
  // 打包单文件的时候自动拷贝worker
30
26
  (globalThis as any).__bundlerPathsOverrides = {
31
27
  'pino-pretty': path.join(__dirname, './worker/pino-pretty.cjs'),
@@ -103,12 +99,6 @@ function getPinoConfig() {
103
99
  },
104
100
  };
105
101
 
106
- return config;
107
- }
108
-
109
- export type Logger = pino.Logger<never, boolean>;
110
-
111
- export function createLogger() {
112
102
  const logger: Logger = pino({
113
103
  // https://github.com/pinojs/pino/blob/main/docs/api.md#opt-serializers
114
104
  base: { pid: process.pid },
@@ -116,7 +106,7 @@ export function createLogger() {
116
106
  errorKey: 'error',
117
107
  timestamp: pino.stdTimeFunctions.epochTime,
118
108
  // timestamp: process.env.NODE_ENV === 'production' ? pino.stdTimeFunctions.epochTime : pino.stdTimeFunctions.isoTime,
119
- ...getPinoConfig(),
109
+ ...config,
120
110
  });
121
111
 
122
112
  return { logger };
package/src/trace.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AsyncLocalStorage } from 'async_hooks';
2
2
 
3
- const als = new AsyncLocalStorage<{ traceId: string } & any>();
3
+ const als = new AsyncLocalStorage<{ traceId: string } & Record<string, any>>();
4
4
 
5
5
  export function runInTrace<T>(data: any, fn: (...args: any[]) => T): T {
6
6
  return als.run(data, fn);
package/tsconfig.json CHANGED
@@ -4,7 +4,8 @@
4
4
  "declaration": true,
5
5
  "paths": {
6
6
  "@/*": ["./src/*"]
7
- }
7
+ },
8
+ "tsBuildInfoFile": "./node_modules/.cache/.tsbuildinfo"
8
9
  },
9
10
  "include": ["./src/**/*"]
10
11
  }
@@ -1,19 +0,0 @@
1
- import "node:module";
2
- var __webpack_modules__ = {};
3
- var __webpack_module_cache__ = {};
4
- function __webpack_require__(moduleId) {
5
- var cachedModule = __webpack_module_cache__[moduleId];
6
- if (void 0 !== cachedModule) return cachedModule.exports;
7
- var module = __webpack_module_cache__[moduleId] = {
8
- exports: {}
9
- };
10
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
11
- return module.exports;
12
- }
13
- __webpack_require__.m = __webpack_modules__;
14
- (()=>{
15
- __webpack_require__.add = function(modules) {
16
- Object.assign(__webpack_require__.m, modules);
17
- };
18
- })();
19
- export { __webpack_require__ };