refactor: move models to their own package to use the same as in the importer
This commit is contained in:
parent
553a85562b
commit
9aa1b7384d
14 changed files with 170 additions and 152 deletions
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"tixel_watch/models"
|
||||
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
|
@ -53,7 +54,7 @@ func (s *StorageService) Close() error {
|
|||
return s.db.Close()
|
||||
}
|
||||
|
||||
func (s *StorageService) SaveLogEntry(ctx context.Context, entry *LogEntry) error {
|
||||
func (s *StorageService) SaveLogEntry(ctx context.Context, entry *models.LogMessage) error {
|
||||
fieldsJSON := ""
|
||||
if entry.Fields != nil {
|
||||
b, err := json.Marshal(entry.Fields)
|
||||
|
|
@ -118,10 +119,10 @@ func (s *StorageService) SaveLogEntry(ctx context.Context, entry *LogEntry) erro
|
|||
return err
|
||||
}
|
||||
|
||||
func (s *StorageService) LoadLogEntry(ctx context.Context, id int64) (*LogEntry, error) {
|
||||
func (s *StorageService) LoadLogEntry(ctx context.Context, id int64) (*models.LogMessage, error) {
|
||||
row := s.db.QueryRowContext(ctx, "SELECT service, timestamp, type, host, tool, log_level, log_message, raw, priority, priority_name, unit, pid, boot_id, machine_id, fields, service_information, system_metrics, tool_information FROM log_entries WHERE id = ?", id)
|
||||
|
||||
var entry LogEntry
|
||||
var entry models.LogMessage
|
||||
var fieldsJSON, serviceInfoJSON, systemMetricsJSON, toolInfoJSON string
|
||||
|
||||
err := row.Scan(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue