REST Service for POPCORN - ILIAS
alex
2025-07-12 0bd7641049b2d3d45c3eb814e76a2fbe2c667c63
adding better logging
4 files modified
104 ■■■■■ changed files
app.js 2 ●●● patch | view | raw | blame | history
logger.js 17 ●●●●● patch | view | raw | blame | history
package-lock.json 84 ●●●●● patch | view | raw | blame | history
package.json 1 ●●●● patch | view | raw | blame | history
app.js
@@ -34,7 +34,7 @@
      return res.send({status: "error", error: "access denied"})
   }
   else {
      log.debug("AUTH FOR ", req.url)
      // log.debug("AUTH FOR ", req.url)
   }
})
logger.js
@@ -1,5 +1,6 @@
const _ = require("lodash")
const dayjs = require("dayjs")
const colors = require("colors/safe")
/////////////////////////////////////////////////////////////////////////
@@ -21,5 +22,21 @@
         msg = JSON.stringify(msg)
      }
   }
   level = _.padEnd(level, 5)
   level = format(level.toLowerCase())
   console.log(`${level} ${dayjs().format("DD.MM.YYYY HH:mm:ss")} - ${msg}`)
}
function format (level) {
   switch (level.trim()) {
      case "info":
         return colors.green(level.toUpperCase())
      case "warn":
         return colors.blue(level.toUpperCase())
      case "error":
         return colors.red(level.toUpperCase())
      case "debug":
         return colors.grey(level.toUpperCase())
   }
   return level
}
package-lock.json
@@ -13,6 +13,7 @@
        "@vueuse/core": "^13.3.0",
        "@vueuse/router": "^13.3.0",
        "chai": "^5.2.0",
        "colors": "^1.4.0",
        "dayjs": "^1.11.13",
        "dotenv": "^16.5.0",
        "enquirer": "^2.4.1",
@@ -2304,43 +2305,6 @@
        "node": ">=12"
      }
    },
    "node_modules/chalk": {
      "version": "4.1.2",
      "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
      "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
      "license": "MIT",
      "dependencies": {
        "ansi-styles": "^4.1.0",
        "supports-color": "^7.1.0"
      },
      "engines": {
        "node": ">=10"
      },
      "funding": {
        "url": "https://github.com/chalk/chalk?sponsor=1"
      }
    },
    "node_modules/chalk/node_modules/has-flag": {
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
      "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/chalk/node_modules/supports-color": {
      "version": "7.2.0",
      "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
      "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
      "license": "MIT",
      "dependencies": {
        "has-flag": "^4.0.0"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/check-error": {
      "version": "2.1.1",
      "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz",
@@ -2402,6 +2366,15 @@
      "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
      "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
      "license": "MIT"
    },
    "node_modules/colors": {
      "version": "1.4.0",
      "resolved": "https://registry.npmjs.org/colors/-/colors-1.4.0.tgz",
      "integrity": "sha512-a+UqTh4kgZg/SlGvfbzDHpgRu7AAQOmmqRHJnxhRZICKFUT91brVhNNt58CMWU9PsBbv3PDCZUHbVxuDiH2mtA==",
      "license": "MIT",
      "engines": {
        "node": ">=0.1.90"
      }
    },
    "node_modules/concat-map": {
      "version": "0.0.1",
@@ -3676,6 +3649,31 @@
        "url": "https://github.com/sponsors/sindresorhus"
      }
    },
    "node_modules/log-symbols/node_modules/chalk": {
      "version": "4.1.2",
      "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
      "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
      "license": "MIT",
      "dependencies": {
        "ansi-styles": "^4.1.0",
        "supports-color": "^7.1.0"
      },
      "engines": {
        "node": ">=10"
      },
      "funding": {
        "url": "https://github.com/chalk/chalk?sponsor=1"
      }
    },
    "node_modules/log-symbols/node_modules/has-flag": {
      "version": "4.0.0",
      "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
      "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
      "license": "MIT",
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/log-symbols/node_modules/is-unicode-supported": {
      "version": "0.1.0",
      "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz",
@@ -3688,6 +3686,18 @@
        "url": "https://github.com/sponsors/sindresorhus"
      }
    },
    "node_modules/log-symbols/node_modules/supports-color": {
      "version": "7.2.0",
      "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
      "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
      "license": "MIT",
      "dependencies": {
        "has-flag": "^4.0.0"
      },
      "engines": {
        "node": ">=8"
      }
    },
    "node_modules/long": {
      "version": "5.3.2",
      "resolved": "https://registry.npmjs.org/long/-/long-5.3.2.tgz",
package.json
@@ -18,6 +18,7 @@
    "@vueuse/core": "^13.3.0",
    "@vueuse/router": "^13.3.0",
    "chai": "^5.2.0",
    "colors": "^1.4.0",
    "dayjs": "^1.11.13",
    "dotenv": "^16.5.0",
    "enquirer": "^2.4.1",