feat(logging): add database logging support and refactor logging system
- Implement new database logging functionality with separate logs database - Refactor PostLog function to store logs in database while maintaining console output - Add new InitLogsDatabase function and related database operations - Update main.go to support separate database paths for data and logs - Add logging for user creation events
This commit is contained in:
@@ -39,7 +39,8 @@ func main() {
|
||||
}
|
||||
postLog.Info(fmt.Sprintf("%s %s (Build %d.%s) by %s", softwareInfo.Name, softwareInfo.Version, softwareInfo.BuildVer, softwareInfo.BuildType, softwareInfo.Developer))
|
||||
configPath := flag.String("config", "./config.json", "path to config file")
|
||||
dbPath := flag.String("db", "./database.db", "path to database file")
|
||||
dbPath_data := flag.String("db", "./database.db", "path to database file")
|
||||
dbPath_log := flag.String("log", "./logs.db", "path to logs database file")
|
||||
flag.Parse()
|
||||
|
||||
if _, err := os.Stat(*configPath); os.IsNotExist(err) {
|
||||
@@ -63,12 +64,12 @@ func main() {
|
||||
postLog.SetDebugMode(config.Debug)
|
||||
isDebug = config.Debug
|
||||
|
||||
if err := InitDatabase(*dbPath); err != nil {
|
||||
if err := InitDatabase(*dbPath_data, *dbPath_log); err != nil {
|
||||
postLog.Fatal(fmt.Sprintf("Failed to initialize database: %v", err))
|
||||
}
|
||||
postLog.Info("Database initialized successfully")
|
||||
|
||||
if err := InitFrpcDatabase(*dbPath); err != nil {
|
||||
if err := InitFrpcDatabase(*dbPath_data); err != nil {
|
||||
postLog.Warning(fmt.Sprintf("Failed to initialize frpc database: %v", err))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user