bajo 2.4.2 → 2.5.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.
package/class/app/log.js CHANGED
@@ -77,16 +77,17 @@ class Log {
77
77
  if (!this.app.bajo.isLogInRange(level)) return
78
78
  const { useUtc, timeTaken, dateFormat, pretty } = this.app.bajo.config.log
79
79
  let [data, msg, ...args] = params
80
+ if (data instanceof Error) {
81
+ msg = 'error%s'
82
+ args = [this.getErrorMessage(data)]
83
+ console.error(data)
84
+ }
80
85
  if (typeof data === 'string') {
81
86
  args.unshift(msg)
82
87
  msg = data
83
88
  data = null
84
89
  }
85
90
  args = without(args, undefined)
86
- if (data instanceof Error) {
87
- msg = 'error%s'
88
- args = [data.message]
89
- }
90
91
  msg = this.app.t(prefix, msg, ...args)
91
92
  let text
92
93
  const dt = dayjs()
@@ -113,13 +114,17 @@ class Log {
113
114
  const tlevel = pretty ? `${chalk[logLevels[level].color](level.toUpperCase())}:` : `[${level.toUpperCase()}]`
114
115
  const tprefix = pretty ? chalk.bgBlue(`${prefix}`) : `[${prefix}]`
115
116
  text = `${tdate} ${tlevel} ${tprefix} ${msg}`
116
- if (!isEmpty(data)) text += '\n' + JSON.stringify(data)
117
+ if (!isEmpty(data) && !(data instanceof Error)) text += '\n' + JSON.stringify(data)
117
118
  }
118
119
  console.log(text)
119
- if (data instanceof Error && level === 'trace') console.error(data)
120
120
  if (this.app.bajo.config.log.save) this.save(text, prefix)
121
121
  }
122
122
 
123
+ getErrorMessage = error => {
124
+ const { isEmpty } = this.app.lib._
125
+ return isEmpty(error.message) ? (error.code ?? error.statusCode) : error.message
126
+ }
127
+
123
128
  /**
124
129
  * Calculate pattern used for log rotation
125
130
  *
@@ -59,9 +59,9 @@ const defConfig = {
59
59
  lookupOrder: [],
60
60
  format: {
61
61
  emptyValue: '',
62
- datetime: { dateStyle: 'medium', timeStyle: 'short' },
63
- date: { dateStyle: 'medium' },
64
- time: { timeStyle: 'short' },
62
+ datetime: { dateStyle: 'medium', timeStyle: 'short', timeZone: 'UTC' },
63
+ date: { dateStyle: 'medium', timeZone: 'UTC' },
64
+ time: { timeStyle: 'short', timeZone: 'UTC' },
65
65
  float: { maximumFractionDigits: 2 },
66
66
  double: { maximumFractionDigits: 5 },
67
67
  smallint: {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bajo",
3
- "version": "2.4.2",
3
+ "version": "2.5.0",
4
4
  "description": "The ultimate framework for whipping up massive apps in no time",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/wiki/CHANGES.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changes
2
2
 
3
+ ## 2026-02-08
4
+
5
+ - [2.5.0] Bug fix on handling log for ```error``` level
6
+ - [2.5.0] Add ```log.getErrorMessage()``` to get the right value of error message
7
+ - [2.5.0] Add ```timeZone``` in config for datetime data type
8
+
3
9
  ## 2026-01-29
4
10
 
5
11
  - [2.4.0] Hooks can now be added through ```config``` object. This is specially usefull if you provide a custom config object on app boot