Skip to content

Commit bf1d1ad

Browse files
committed
chore: wip
1 parent d52e1fb commit bf1d1ad

File tree

6 files changed

+11
-116
lines changed

6 files changed

+11
-116
lines changed

config/logger.ts

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { path as p } from '@stacksjs/path'
12
import type { LoggerConfig } from '@stacksjs/types'
23

34
/**
@@ -8,42 +9,13 @@ import type { LoggerConfig } from '@stacksjs/types'
89
* have any questions, feel free to reach out via Discord or GitHub Discussions.
910
*/
1011
export default {
11-
/**
12-
* **Log Level**
13-
*
14-
* The log level is a number that represents the verbosity of the logs. The higher the number,
15-
* the more verbose the logs will be. The log levels are as follows:
16-
*
17-
* - 0: Error
18-
* - 1: Warning
19-
* - 2: Normal
20-
* - 3: Info
21-
* - 4: Debug
22-
* - 5: Trace
23-
* - -999: Silent
24-
* - +999: Verbose
25-
*
26-
* @default 3
27-
*/
28-
level: 3,
29-
3012
/**
3113
* **Log File Path**
3214
*
3315
* The path to the log file. This will be used to write logs to a file. If you do not want to
3416
* write logs to a file, you may set this to `null`.
3517
*
36-
* @default 'storage/logs/console.log'
37-
*/
38-
logFilePath: 'storage/logs/console.log',
39-
40-
/**
41-
* **Errors Log Path**
42-
*
43-
* The path to the errors log file. This will be used to write error logs to a file. If you do
44-
* not want to write error logs to a file, you may set this to `null`.
45-
*
46-
* @default 'storage/logs/errors.log'
18+
* @default 'storage/logs/stacks.log'
4719
*/
48-
errorsPath: 'storage/logs/errors.log',
20+
logsPath: p.storagePath('logs/stacks.log'),
4921
} satisfies LoggerConfig

routes/api.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,17 @@ import { route } from '@stacksjs/router'
88
* @see https://stacksjs.org/docs/routing
99
*/
1010

11-
route.get('/foo/bar/{id}', () => 'hello world, foo bar') // stacksjs.org/api/hello/world
11+
route.get('/foo/bar/{id}', () => 'hello world, foo bar') // $APP_URL/api/hello/world
1212
route.get('/', () => 'hello world') // $APP_URL/api
13-
route.get('/hello/world', () => 'hello world, buddy') // stacksjs.org/api/hello/world
13+
route.get('/hello/world', () => 'hello world, buddy') // $APP_URL/api/hello/world
1414

1515
route.post('/email/subscribe', 'Actions/SubscriberEmailAction')
16-
1716
route.post('/login', 'Actions/LoginAction')
18-
1917
route.email('/welcome')
2018
route.health() // adds a GET `/api/health` route
2119

2220
// route.group('/some-path', async () => {...})
2321
// route.action('/example') // equivalent to `route.get('/example', 'ExampleAction')`
24-
2522
// route.action('Dashboard/GetProjects')
2623
// route.action('Dashboard/Settings/UpdateAiConfig')
27-
2824
// route.job('/example-two') // equivalent to `route.get('/example-two', 'ExampleTwoJob')`

routes/buddy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ import { route } from '@stacksjs/router'
88
* @see https://stacksjs.org/docs/routing
99
*/
1010

11-
await route.get('/versions', 'Actions/Buddy/VersionsAction') // your-domain.com/api/buddy/versions
12-
await route.get('/commands', 'Actions/Buddy/CommandsAction') // your-domain.com/api/buddy/commands
11+
route.get('/versions', 'Actions/Buddy/VersionsAction') // your-domain.com/api/buddy/versions
12+
route.get('/commands', 'Actions/Buddy/CommandsAction') // your-domain.com/api/buddy/commands

storage/framework/core/logging/src/index.ts

Lines changed: 3 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,19 @@ import { access, appendFile, mkdir } from 'node:fs/promises'
22
import { dirname } from 'node:path'
33
import process from 'node:process'
44
import type { Prompt } from '@stacksjs/cli'
5-
import { buddyOptions, prompt as getPrompt } from '@stacksjs/cli'
5+
import { prompt as getPrompt } from '@stacksjs/cli'
6+
import { config } from '@stacksjs/config'
67
import { handleError } from '@stacksjs/error-handling'
7-
import { logsPath } from '@stacksjs/path'
88
import { ExitCode } from '@stacksjs/types'
99
import { isString } from '@stacksjs/validation'
10-
import { consola, createConsola } from 'consola'
1110
import isUnicodeSupported from 'is-unicode-supported'
1211
import color from 'picocolors'
1312

14-
export async function logLevel() {
15-
/**
16-
* This regex checks for:
17-
* - --verbose true or --verbose=true exactly at the end of the string ($ denotes the end of the string).
18-
* - --verbose - followed by optional spaces at the end.
19-
* - --verbose followed by optional spaces at the end.
20-
*
21-
* .trim() is used on options to ensure any trailing spaces in the entire options string do not affect the regex match.
22-
*/
23-
const verboseRegex = /--verbose(?!(\s*=\s*false|\s+false))(\s+|=true)?($|\s)/
24-
const opts = buddyOptions()
25-
26-
if (verboseRegex.test(opts)) return 4
27-
28-
// const config = await import('@stacksjs/config')
29-
// console.log('config', config)
30-
31-
return 3
32-
// return config.logger.level
33-
}
34-
35-
export const logger = createConsola({
36-
level: 3,
37-
// fancy: true,
38-
// formatOptions: {
39-
// columns: 80,
40-
// colors: false,
41-
// compact: false,
42-
// date: false,
43-
// },
44-
})
45-
46-
export { consola }
47-
4813
export async function writeToLogFile(message: string) {
4914
const formattedMessage = `[${new Date().toISOString()}] ${message}\n`
5015

5116
try {
52-
const logFilePath = logsPath('console.log')
17+
const logFilePath = config.logger.logsPath ?? 'storage/logs/stacks.log'
5318

5419
try {
5520
// Check if the file exists
@@ -164,9 +129,6 @@ export const log: Log = {
164129
process.exit(ExitCode.FatalError)
165130
},
166131
echo: (...args: any[]) => console.log(...args),
167-
168-
start: consola.start,
169-
box: consola.box,
170132
}
171133

172134
export function dump(...args: any[]) {
Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import type { LogLevel } from 'consola'
2-
import { LogLevels, LogTypes } from 'consola'
3-
41
/**
52
* **Logger Options**
63
*
@@ -9,25 +6,6 @@ import { LogLevels, LogTypes } from 'consola'
96
* have any questions, feel free to reach out via Discord or GitHub Discussions.
107
*/
118
export interface LoggerOptions {
12-
/**
13-
* **Log Level**
14-
*
15-
* The log level is a number that represents the verbosity of the logs. The higher the number,
16-
* the more verbose the logs will be. The log levels are as follows:
17-
*
18-
* - 0: Error
19-
* - 1: Warning
20-
* - 2: Normal
21-
* - 3: Info
22-
* - 4: Debug
23-
* - 5: Trace
24-
* - -999: Silent
25-
* - +999: Verbose
26-
*
27-
* @default 3
28-
*/
29-
level: LogLevel
30-
319
/**
3210
* **Log File Path**
3311
*
@@ -36,19 +14,7 @@ export interface LoggerOptions {
3614
*
3715
* @default 'storage/logs/console.log'
3816
*/
39-
logFilePath: string
40-
41-
/**
42-
* **Errors Log Path**
43-
*
44-
* The path to the errors log file. This will be used to write error logs to a file. If you do
45-
* not want to write error logs to a file, you may set this to `null`.
46-
*
47-
* @default 'storage/logs/errors.log'
48-
*/
49-
errorsPath: string
17+
logsPath: string
5018
}
5119

5220
export type LoggerConfig = Partial<LoggerOptions>
53-
54-
export { LogLevels, LogTypes }

storage/framework/core/x-ray/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"dump",
2323
"logs",
2424
"console",
25-
"consola",
2625
"type safe",
2726
"stacks"
2827
],

0 commit comments

Comments
 (0)