@stacksjs/logging 0.58.73 → 0.59.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/logging",
3
3
  "type": "module",
4
- "version": "0.58.73",
4
+ "version": "0.59.2",
5
5
  "description": "The Stacks logging system.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -25,6 +25,7 @@
25
25
  "exports": {
26
26
  ".": {
27
27
  "bun": "./src/index.ts",
28
+ "types": "./dist/index.d.ts",
28
29
  "import": "./dist/index.js"
29
30
  },
30
31
  "./*": {
@@ -49,10 +50,12 @@
49
50
  },
50
51
  "peerDependencies": {
51
52
  "@stacksjs/cli": "latest",
53
+ "@stacksjs/config": "latest",
52
54
  "@stacksjs/error-handling": "latest"
53
55
  },
54
56
  "dependencies": {
55
57
  "@stacksjs/cli": "latest",
58
+ "@stacksjs/config": "latest",
56
59
  "@stacksjs/error-handling": "latest",
57
60
  "consola": "^3.2.3"
58
61
  },
package/src/index.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import process from 'node:process'
2
2
  import { consola, createConsola } from 'consola'
3
3
  import { ExitCode } from '@stacksjs/types'
4
- import { logger as logConfig } from '@stacksjs/config'
4
+ import { config } from '@stacksjs/config'
5
5
  import { logsPath } from '@stacksjs/path'
6
6
  import { handleError } from '@stacksjs/error-handling'
7
7
  import type { Prompt } from '@stacksjs/cli'
@@ -17,10 +17,14 @@ export function logLevel() {
17
17
  * .trim() is used on options to ensure any trailing spaces in the entire options string do not affect the regex match.
18
18
  */
19
19
  const verboseRegex = /--verbose(?!(\s*=\s*false|\s+false))(\s+|=true)?($|\s)/
20
+ const opts = buddyOptions()
21
+ // console.log('opts:', opts)
22
+ // console.log('config:::', config)
20
23
 
21
- if (verboseRegex.test(buddyOptions().trim()))
24
+ if (verboseRegex.test(opts))
22
25
  return 4
23
- return logConfig.level
26
+
27
+ return config.logger.level
24
28
  }
25
29
 
26
30
  export const logger = createConsola({
@@ -61,7 +65,7 @@ async function writeToLogFile(message: string) {
61
65
  export interface Log {
62
66
  info: (...args: any[]) => void
63
67
  success: (msg: string) => void
64
- error: (err: string | Error, options?: any) => void
68
+ error: (err: string | Error, options?: any | Error) => void
65
69
  warn: (arg: string) => void
66
70
  debug: (...args: any[]) => void
67
71
  // start: logger.Start
@@ -86,8 +90,14 @@ export const log: Log = {
86
90
  await writeToLogFile(`SUCCESS: ${msg}`)
87
91
  },
88
92
 
89
- async error(err: string | Error, options?: any) {
90
- handleError(err, options) // Assuming handleError logs the error
93
+ async error(err: string | Error, options?: any | Error) {
94
+ if (err instanceof Error)
95
+ handleError(err, options)
96
+ else if (options instanceof Error)
97
+ handleError(options)
98
+ else
99
+ handleError(err, options)
100
+
91
101
  await writeToLogFile(`ERROR: ${err}`)
92
102
  },
93
103