change logging format

This commit is contained in:
2026-01-03 09:53:07 -05:00
parent 5192919645
commit 19752a0c89
5 changed files with 32 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ var Port *int
var Color *bool
var Static *bool
var Docker *bool
var Verbose *bool
type AppConfig struct {
App struct {

View File

@@ -424,6 +424,8 @@ func Start(dir string) error {
return ui.Error(fmt.Sprintf("failed to change directory to %s", dir), err)
}
ui.Log("Running root=%s, port=%d.", filepath.Clean(dir), *config.Port)
cfg := parseConfig()
notFoundData := generateNotFoundData(&cfg)
routes := loadDirs()
@@ -475,7 +477,8 @@ func Start(dir string) error {
w.Write(data)
})
ui.Log("Server initialized")
ui.Log("Ready to accept connections on http://localhost:%d", *config.Port)
ui.Log("Ready to accept connections tcp")
return http.ListenAndServe(fmt.Sprintf("0.0.0.0:%d", *config.Port), nil)
}

View File

@@ -45,6 +45,12 @@ func WARN(msg string, args ...any) {
color.Magenta("%s # %s\n", formatTimestamp(), formatted)
}
// Warning message (magenta)
func WARNING(msg string, args ...any) {
formatted := fmt.Sprintf(msg, args...)
color.Magenta("%s # WARNING %s\n", formatTimestamp(), formatted)
}
// Error message (red)
func ERROR(msg string, args ...any) {
formatted := fmt.Sprintf(msg, args...)
@@ -102,3 +108,10 @@ func Fatal(msg string, err error) error {
FATAL("%s: %v", msg, err)
return err
}
// Log on Verbose
func LogVerbose(msg string, args ...any) {
if *config.Verbose {
Log(msg, args...)
}
}

View File

@@ -9,7 +9,7 @@ var gitCommit string = "devel"
const PROGRAM_NAME string = "fes"
const PROGRAM_NAME_LONG string = "fes/fSD"
const VERSION string = "0.1.0"
const VERSION string = "0.2.0"
func Version() {
fmt.Printf("%s version %s\n", PROGRAM_NAME_LONG, VERSION)