@joystick.js/node-canary 0.0.0-canary.420 → 0.0.0-canary.422
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/dist/app/push_logs.js +1 -1
- package/package.json +1 -1
- package/src/app/push_logs.js +23 -15
package/dist/app/push_logs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"winston";const e=t.createLogger({format:t.format.combine(t.format.timestamp(),t.format.json()),transports:[new t.transports.File({filename:"/push/logs/app.log",maxsize:1024*1024*20,maxFiles:1,tailable:!0})]})
|
|
1
|
+
import t from"winston";import r from"fs";import e from"../lib/path_exists.js";const{mkdir:i}=r.promises,a=async()=>{await e("/push/logs")||await i("/push/logs",{recursive:!0});const s=t.createLogger({format:t.format.combine(t.format.timestamp(),t.format.json()),transports:[new t.transports.File({filename:"/push/logs/app.log",maxsize:1024*1024*20,maxFiles:1,tailable:!0})]});process.stdout.write=o=>{s.debug(o)},process.stderr.write=o=>{s.error(o)},process.on("uncaughtException",o=>{s.error(o instanceof Error?o?.toString():o)}),process.on("unhandledRejection",o=>{s.error(o instanceof Error?o?.toString():o)})};var c=a;export{c as default};
|
package/package.json
CHANGED
package/src/app/push_logs.js
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import winston from 'winston';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path_exists from '../lib/path_exists.js';
|
|
2
4
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
const { mkdir } = fs.promises;
|
|
6
|
+
|
|
7
|
+
const push_logs = async () => {
|
|
8
|
+
if (!(await path_exists('/push/logs'))) {
|
|
9
|
+
await mkdir('/push/logs', { recursive: true });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const logger = winston.createLogger({
|
|
13
|
+
format: winston.format.combine(
|
|
14
|
+
winston.format.timestamp(),
|
|
15
|
+
winston.format.json(),
|
|
16
|
+
),
|
|
17
|
+
transports: [
|
|
18
|
+
new winston.transports.File({
|
|
19
|
+
filename: '/push/logs/app.log',
|
|
20
|
+
maxsize: 1024 * 1024 * 20, // 20MB,
|
|
21
|
+
maxFiles: 1,
|
|
22
|
+
tailable: true,
|
|
23
|
+
})
|
|
24
|
+
],
|
|
25
|
+
});
|
|
17
26
|
|
|
18
|
-
const push_logs = () => {
|
|
19
27
|
process.stdout.write = (data) => {
|
|
20
28
|
logger.debug(data);
|
|
21
29
|
};
|