bajo 2.4.1 → 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
  *
package/class/app.js CHANGED
@@ -6,7 +6,7 @@ import Tools from './plugin/tools.js'
6
6
 
7
7
  import { outmatchNs, parseObject, lib } from './helper/app.js'
8
8
 
9
- const { camelCase, isPlainObject, get, reverse, map, last, without } = lib._
9
+ const { camelCase, isPlainObject, get, reverse, map, last, without, set } = lib._
10
10
  const { pascalCase } = lib.aneka
11
11
  let unknownLangWarning = false
12
12
 
@@ -274,6 +274,7 @@ class App {
274
274
  this.args = args
275
275
  this.argv = parseObject(argv, { parseValue: true })
276
276
  this.envVars = parseObject(parseEnv(), { parseValue: true })
277
+ if (get(this, 'envVars._.env') === '[object Object]') set(this, 'envVars._.env', 'dev')
277
278
  this.applet = this.envVars._.applet ?? this.argv._.applet
278
279
  await this.bajo.runHook('bajo:beforeBoot')
279
280
  await this.bajo.init()
@@ -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.1",
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,9 +1,16 @@
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
6
12
  - [2.4.1] Bug fix on ```runHook()``` resolver. Source defaults to ```main``` if not provided. Scope defaults to ```bajo``` if not found/initialized yet
13
+ - [2.4.2] Bug fix on getting wrongly parsed ```env``` value
7
14
 
8
15
  ## 2026-01-24
9
16