@akc42/server-utils 3.3.0 → 3.4.0

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.
Files changed (2) hide show
  1. package/debug.js +11 -2
  2. package/package.json +1 -1
package/debug.js CHANGED
@@ -22,7 +22,7 @@ import chalk from 'chalk';
22
22
  let config = process.env.DEBUG || '';
23
23
  let cache = [];
24
24
  let cachelimit = 50;
25
-
25
+
26
26
  export function Debug (topic) {
27
27
  const t = topic;
28
28
  let timestamp = new Date().getTime();
@@ -40,8 +40,17 @@ export function Debug (topic) {
40
40
  }, '');
41
41
  const output = `${chalk.greenBright(topic)} ${chalk.cyan(message)} ${chalk.whiteBright(`(${gap}ms)`)}`
42
42
  if (enabled) {
43
+ let logLine = '';
44
+ if (typeof process.env.LOG_NO_DATE === 'undefined') {
45
+ if (typeof process.env.LOG_ISO_DATE !== 'undefined') {
46
+ logLine += new Date().toISOString() + ': ';
47
+ } else {
48
+ logLine += new Date().toISOString().substring(0,10) + ' ' + new Date().toLocaleTimeString() + ': ';
49
+ }
50
+ }
51
+ logLine += output;
43
52
  //eslint-disable-next-line no-console
44
- console.log(output);
53
+ console.log(logLine);
45
54
  }
46
55
  cache.push(output);
47
56
  if (cache.length > cachelimit) cache.splice(0,cache.length - cachelimit); //prevent it getting too big
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akc42/server-utils",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "type": "module",
5
5
  "description": "A Set of Utilities to use on the Server Side of a Project",
6
6
  "main": "./utils.js",