restructure project, add claudemd
This commit is contained in:
71
go/l4g/terminal.go
Normal file
71
go/l4g/terminal.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package l4g
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
type TerminalLogger struct{}
|
||||
|
||||
func NewTerminalLogger() *TerminalLogger {
|
||||
return &TerminalLogger{}
|
||||
}
|
||||
|
||||
func (t *TerminalLogger) Write(entry Entry) error {
|
||||
timestamp := entry.Timestamp.Format(time.RFC3339)
|
||||
|
||||
var category string
|
||||
switch entry.Category {
|
||||
case CATEGORY_SYSTEM:
|
||||
category = "SYSTEM"
|
||||
case CATEGORY_ADMIN:
|
||||
category = "ADMIN"
|
||||
case CATEGORY_USER:
|
||||
category = "USER"
|
||||
case CATEGORY_ORG:
|
||||
category = "ORG"
|
||||
case CATEGORY_AUDIT:
|
||||
category = "AUDIT"
|
||||
case CATEGORY_AUTH:
|
||||
category = "AUTH"
|
||||
default:
|
||||
category = "UNKNOWN"
|
||||
}
|
||||
|
||||
var logType string
|
||||
switch entry.LogType {
|
||||
case TYPE_DEBUG:
|
||||
logType = "DEBUG"
|
||||
case TYPE_INFO:
|
||||
logType = "INFO"
|
||||
case TYPE_WARN:
|
||||
logType = "WARN"
|
||||
case TYPE_ERROR:
|
||||
logType = "ERROR"
|
||||
default:
|
||||
logType = "UNKNOWN"
|
||||
}
|
||||
|
||||
content := ""
|
||||
if entry.Content != nil {
|
||||
content = *entry.Content
|
||||
}
|
||||
|
||||
fmt.Printf("[%s] %s/%s: %s\n", timestamp, category, logType, content)
|
||||
|
||||
if entry.StructuredContent != nil {
|
||||
fmt.Printf("Details: %s\n", *entry.StructuredContent)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (t *TerminalLogger) Fatal(entry Entry) error {
|
||||
err := t.Write(entry)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
os.Exit(1)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user