@joystick.js/node-canary 0.0.0-canary.421 → 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.
@@ -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})]}),r=()=>{process.stdout.write=o=>{e.debug(o)},process.stderr.write=o=>{e.error(o)},process.on("uncaughtException",o=>{e.error(o instanceof Error?o?.toString():o)}),process.on("unhandledRejection",o=>{e.error(o instanceof Error?o?.toString():o)})};var n=r;export{n as default};
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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@joystick.js/node-canary",
3
3
  "type": "module",
4
- "version": "0.0.0-canary.421",
4
+ "version": "0.0.0-canary.422",
5
5
  "description": "The Node.js framework for Joystick.",
6
6
  "main": "./dist/index.js",
7
7
  "scripts": {
@@ -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 logger = winston.createLogger({
4
- format: winston.format.combine(
5
- winston.format.timestamp(),
6
- winston.format.json(),
7
- ),
8
- transports: [
9
- new winston.transports.File({
10
- filename: '/push/logs/app.log',
11
- maxsize: 1024 * 1024 * 20, // 20MB,
12
- maxFiles: 1,
13
- tailable: true,
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
  };