@stacksjs/logging 0.58.72 → 0.59.1
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/dist/index.d.ts +23 -0
- package/dist/index.js +1801 -11
- package/package.json +4 -1
- package/src/index.ts +17 -6
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/logging",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.59.1",
|
|
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,8 +1,9 @@
|
|
|
1
1
|
import process from 'node:process'
|
|
2
2
|
import { consola, createConsola } from 'consola'
|
|
3
3
|
import { ExitCode } from '@stacksjs/types'
|
|
4
|
-
import {
|
|
4
|
+
import { config } from '@stacksjs/config'
|
|
5
5
|
import { logsPath } from '@stacksjs/path'
|
|
6
|
+
import { handleError } from '@stacksjs/error-handling'
|
|
6
7
|
import type { Prompt } from '@stacksjs/cli'
|
|
7
8
|
import { buddyOptions, prompt as getPrompt } from '@stacksjs/cli'
|
|
8
9
|
|
|
@@ -16,10 +17,14 @@ export function logLevel() {
|
|
|
16
17
|
* .trim() is used on options to ensure any trailing spaces in the entire options string do not affect the regex match.
|
|
17
18
|
*/
|
|
18
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)
|
|
19
23
|
|
|
20
|
-
if (verboseRegex.test(
|
|
24
|
+
if (verboseRegex.test(opts))
|
|
21
25
|
return 4
|
|
22
|
-
|
|
26
|
+
|
|
27
|
+
return config.logger.level
|
|
23
28
|
}
|
|
24
29
|
|
|
25
30
|
export const logger = createConsola({
|
|
@@ -60,7 +65,7 @@ async function writeToLogFile(message: string) {
|
|
|
60
65
|
export interface Log {
|
|
61
66
|
info: (...args: any[]) => void
|
|
62
67
|
success: (msg: string) => void
|
|
63
|
-
error: (err: string | Error, options?: any) => void
|
|
68
|
+
error: (err: string | Error, options?: any | Error) => void
|
|
64
69
|
warn: (arg: string) => void
|
|
65
70
|
debug: (...args: any[]) => void
|
|
66
71
|
// start: logger.Start
|
|
@@ -85,8 +90,14 @@ export const log: Log = {
|
|
|
85
90
|
await writeToLogFile(`SUCCESS: ${msg}`)
|
|
86
91
|
},
|
|
87
92
|
|
|
88
|
-
async error(err: string | Error, options?: any) {
|
|
89
|
-
|
|
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
|
+
|
|
90
101
|
await writeToLogFile(`ERROR: ${err}`)
|
|
91
102
|
},
|
|
92
103
|
|