changed tree

This commit is contained in:
Acid
2026-06-06 04:05:48 -04:00
parent 9b59c36974
commit f45a94622e
5 changed files with 16 additions and 3 deletions
-47
View File
@@ -1,47 +0,0 @@
package main
import (
"database/sql"
_ "embed"
"time"
_ "github.com/mattn/go-sqlite3"
)
//go:embed seed.sql
var seedSQL string
// logs level=('debug', 'info', 'warning', 'error')
type logs struct {
level string
ip string
traceback string
date time.Time
}
type dbStruct struct {
db *sql.DB
}
// Seed runs the schema in seed.sql. Idempotent via CREATE TABLE IF NOT EXISTS,
// so it's safe to call on every startup.
func (app *dbStruct) Seed() error {
_, err := app.db.Exec(seedSQL)
return err
}
// InsertLog() : database method, only inserts level + traceback
func (app *dbStruct) InsertLog(lg logs) error {
query := `INSERT INTO logs (level, traceback) VALUES (?, ?)`
_, err := app.db.Exec(query, lg.level, lg.traceback)
return err
}
// LogIp() : database method, logs level + Ip
func (app *dbStruct) LogIp(lg logs) error {
query := `INSERT INTO logs (level, ip) VALUES (?, ?)`
_, err := app.db.Exec(query, lg.level, lg.ip)
return err
}