@rife/logger 0.0.6-beta.12 → 0.0.6-beta.13

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,116 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.n = (module)=>{
5
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
6
+ __webpack_require__.d(getter, {
7
+ a: getter
8
+ });
9
+ return getter;
10
+ };
11
+ })();
12
+ (()=>{
13
+ __webpack_require__.d = (exports1, definition)=>{
14
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
15
+ enumerable: true,
16
+ get: definition[key]
17
+ });
18
+ };
19
+ })();
20
+ (()=>{
21
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
22
+ })();
23
+ (()=>{
24
+ __webpack_require__.r = (exports1)=>{
25
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
26
+ value: 'Module'
27
+ });
28
+ Object.defineProperty(exports1, '__esModule', {
29
+ value: true
30
+ });
31
+ };
32
+ })();
33
+ var __webpack_exports__ = {};
34
+ __webpack_require__.r(__webpack_exports__);
35
+ __webpack_require__.d(__webpack_exports__, {
36
+ createLogger: ()=>createLogger
37
+ });
38
+ const external_pino_namespaceObject = require("pino");
39
+ var external_pino_default = /*#__PURE__*/ __webpack_require__.n(external_pino_namespaceObject);
40
+ const external_path_namespaceObject = require("path");
41
+ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
42
+ const external_trace_cjs_namespaceObject = require("../trace.cjs");
43
+ function getPinoConfig() {
44
+ const targets = [];
45
+ if ('production' === process.env.NODE_ENV) ;
46
+ else {
47
+ const rotate = `./rotate${external_path_default().extname(__filename)}`;
48
+ targets.push({
49
+ level: 'debug',
50
+ target: rotate,
51
+ options: {
52
+ path: './logs/'
53
+ }
54
+ });
55
+ targets.push({
56
+ level: 'debug',
57
+ target: 'pino-pretty',
58
+ options: {
59
+ ignore: 'pid',
60
+ messageKey: 'message'
61
+ }
62
+ });
63
+ }
64
+ const config = {
65
+ transport: {
66
+ targets
67
+ },
68
+ mixin (data) {
69
+ const traceId = data?.traceId;
70
+ delete data.traceId;
71
+ delete data.level;
72
+ delete data.time;
73
+ delete data.pid;
74
+ delete data.name;
75
+ delete data.hostname;
76
+ if (!traceId) return {
77
+ traceId: (0, external_trace_cjs_namespaceObject.getTraceId)()
78
+ };
79
+ return {
80
+ traceId
81
+ };
82
+ },
83
+ browser: {
84
+ write: (o)=>{
85
+ const { name, time, level, ...rest } = o;
86
+ if (name) rest.message = rest.message ? `[${name}] ${rest.message}` : `[${name}]`;
87
+ if (!rest.traceId) rest.traceId = (0, external_trace_cjs_namespaceObject.getTraceId)();
88
+ if (level >= 50) console.error(rest);
89
+ else if (level >= 40) console.warn(rest);
90
+ else console.log(rest);
91
+ }
92
+ }
93
+ };
94
+ return config;
95
+ }
96
+ function createLogger() {
97
+ const logger = external_pino_default()({
98
+ base: {
99
+ pid: process.pid
100
+ },
101
+ messageKey: 'message',
102
+ errorKey: 'error',
103
+ timestamp: external_pino_default().stdTimeFunctions.epochTime,
104
+ ...getPinoConfig()
105
+ });
106
+ return {
107
+ logger
108
+ };
109
+ }
110
+ exports.createLogger = __webpack_exports__.createLogger;
111
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
112
+ "createLogger"
113
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
114
+ Object.defineProperty(exports, '__esModule', {
115
+ value: true
116
+ });
@@ -0,0 +1,5 @@
1
+ var __webpack_exports__ = {};
2
+ for(var __rspack_i in __webpack_exports__)exports[__rspack_i] = __webpack_exports__[__rspack_i];
3
+ Object.defineProperty(exports, '__esModule', {
4
+ value: true
5
+ });
@@ -1,7 +1,6 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
1
+ import "node:module";
4
2
  import path from "path";
3
+ import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
5
4
  var common_filename = __rspack_fileURLToPath(import.meta.url);
6
5
  const isEsm = '.mjs' === path.extname(common_filename);
7
6
  const isCjs = !isEsm;
package/dist/esm/env.mjs CHANGED
@@ -1,5 +1,4 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  const isProd = ()=>'production' === process.env.NODE_ENV;
4
3
  const isDev = ()=>!isProd();
5
4
  export { isDev, isProd };
@@ -1,3 +1,2 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
3
2
  export * from "./trace.mjs";
@@ -1,26 +1,16 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
4
- import { dirname as __rspack_dirname } from "node:path";
5
- import * as __rspack_external_pino_std_serializers_719fa64c from "pino-std-serializers";
1
+ import "node:module";
6
2
  import path from "path";
7
3
  import pino from "pino";
8
4
  import { genTraceId, getTraceId, runInTrace } from "../trace.mjs";
9
- var __webpack_modules__ = {
5
+ import { __webpack_require__ } from "../rslib-runtime.mjs";
6
+ import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
7
+ import { dirname as __rspack_dirname } from "node:path";
8
+ import * as __rspack_external_pino_std_serializers_719fa64c from "pino-std-serializers";
9
+ __webpack_require__.add({
10
10
  "pino-std-serializers" (module) {
11
11
  module.exports = __rspack_external_pino_std_serializers_719fa64c;
12
12
  }
13
- };
14
- var __webpack_module_cache__ = {};
15
- function __webpack_require__(moduleId) {
16
- var cachedModule = __webpack_module_cache__[moduleId];
17
- if (void 0 !== cachedModule) return cachedModule.exports;
18
- var module = __webpack_module_cache__[moduleId] = {
19
- exports: {}
20
- };
21
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
22
- return module.exports;
23
- }
13
+ });
24
14
  var pino_filename = __rspack_fileURLToPath(import.meta.url);
25
15
  var pino_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
26
16
  function getPinoConfig() {
@@ -67,6 +57,16 @@ function getPinoConfig() {
67
57
  return {
68
58
  traceId
69
59
  };
60
+ },
61
+ browser: {
62
+ write: (o)=>{
63
+ const { name, time, level, ...rest } = o;
64
+ if (name) rest.message = rest.message ? `[${name}] ${rest.message}` : `[${name}]`;
65
+ if (!rest.traceId) rest.traceId = getTraceId();
66
+ if (level >= 50) console.error(rest);
67
+ else if (level >= 40) console.warn(rest);
68
+ else console.log(rest);
69
+ }
70
70
  }
71
71
  };
72
72
  return config;
@@ -117,4 +117,4 @@ function useExpress(logger, format) {
117
117
  }, next);
118
118
  };
119
119
  }
120
- export { createLogger, useExpress };
120
+ export { createLogger, pino, useExpress };
@@ -1,21 +1,11 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
1
+ import "node:module";
2
+ import { __webpack_require__ } from "../rslib-runtime.mjs";
3
3
  import * as __rspack_external_rotating_file_stream_66c5ea63 from "rotating-file-stream";
4
- var __webpack_modules__ = {
4
+ __webpack_require__.add({
5
5
  "rotating-file-stream" (module) {
6
6
  module.exports = __rspack_external_rotating_file_stream_66c5ea63;
7
7
  }
8
- };
9
- var __webpack_module_cache__ = {};
10
- function __webpack_require__(moduleId) {
11
- var cachedModule = __webpack_module_cache__[moduleId];
12
- if (void 0 !== cachedModule) return cachedModule.exports;
13
- var module = __webpack_module_cache__[moduleId] = {
14
- exports: {}
15
- };
16
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
17
- return module.exports;
18
- }
8
+ });
19
9
  const generator = (time, index)=>{
20
10
  if (!time) return 'server.log';
21
11
  time = new Date(time);
@@ -37,4 +27,4 @@ const rotate = (options)=>{
37
27
  path
38
28
  });
39
29
  };
40
- export { rotate as default };
30
+ export default rotate;