feat: add logging and collector implementations
- Introduced `hertzx` package with `NewHertz` function for server initialization. - Implemented `logx` package with various log collectors: Console, Loki, Elasticsearch, and Prometheus. - Added `Logger` struct to manage logging levels and collectors. - Created environment variable loading functionality in `osx` package to support configuration. - Enhanced logging capabilities with structured log entries and asynchronous collection.
This commit is contained in:
22
dbx/sqlite.go
Normal file
22
dbx/sqlite.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package dbx
|
||||
|
||||
import (
|
||||
"github.com/glebarez/sqlite"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func GetSQLiteDB(cfg *DBConfig, dbName string) *gorm.DB {
|
||||
db, err := getSQLiteInstance(cfg, dbName)
|
||||
if err != nil {
|
||||
panic("failed to connect to SQLite database: " + err.Error())
|
||||
}
|
||||
return db
|
||||
}
|
||||
|
||||
func getSQLiteInstance(cfg *DBConfig, dbName string) (*gorm.DB, error) {
|
||||
// 对 sqlite, dbName 可以是文件路径或 ':memory:'
|
||||
return gorm.Open(
|
||||
sqlite.Open(dbName),
|
||||
&gorm.Config{},
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user