mirror of
https://github.com/akyaiy/GoSally-mvp.git
synced 2026-01-03 20:52:25 +00:00
Refactor and restructure core components
- Removed obsolete files: `hanle_multi.go`, `logger.go`, `handle_com.go`, `handle_list.go`, `server.go`, and `utils.go` from the `general_server` and `sv1` packages. - Introduced new implementations for the `GeneralServer` and `HandlerV1` in the `core` package, enhancing the overall architecture. - Updated the `go.mod` and `go.sum` files to include new dependencies. - Added a new configuration structure in `config.yaml` and `config.go` for better management of application settings. - Implemented a Lua command handling mechanism in `handle_com.go` and `handle_list.go` for improved command execution. - Enhanced logging capabilities with a new logger setup in `logger.go`. - Added a new Lua script `http.lua` for handling HTTP requests.
This commit is contained in:
25
core/logs/logger.go
Normal file
25
core/logs/logger.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package logs
|
||||
|
||||
import (
|
||||
"log/slog"
|
||||
"os"
|
||||
)
|
||||
|
||||
const (
|
||||
envDev = "dev"
|
||||
envProd = "prod"
|
||||
)
|
||||
|
||||
func SetupLogger(env string) *slog.Logger {
|
||||
var log *slog.Logger
|
||||
switch env {
|
||||
case envDev:
|
||||
log = slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug}))
|
||||
case envProd:
|
||||
log = slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo}))
|
||||
default:
|
||||
log = slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug}))
|
||||
}
|
||||
|
||||
return log
|
||||
}
|
||||
Reference in New Issue
Block a user