aider: Moved the `ExtendedEvent` type and interface to `simplelog.go`.
# Aider chat conversation: USER: the extendedevent type and interface should be in simplelog.go not the relp_handler.go because it's general to the simplelog package and not specific to the relp extendedhandler. ASSISTANT: To move the `ExtendedEvent` type and interface to `simplelog.go`, we need to: 1. Remove the `ExtendedEvent` type and interface from `event.go`. 2. Add the `ExtendedEvent` type and interface to `simplelog.go`. Here are the *SEARCH/REPLACE* blocks: event.go ```go <<<<<<< SEARCH type ExtendedEvent interface { GetID() uuid.UUID GetTimestamp() time.Time GetLevel() string GetMessage() string GetData() json.RawMessage GetFile() string GetLine() int } type extendedEvent struct { Event File string `json:"file"` Line int `json:"line"` } func (e extendedEvent) GetID() uuid.UUID { return e.ID } func (e extendedEvent) GetTimestamp() time.Time { return e.Timestamp } func (e extendedEvent) GetLevel() string { return e.Level } func (e extendedEvent) GetMessage() string { return e.Message } func (e extendedEvent) GetData() json.RawMessage { return e.Data } func (e extendedEvent) GetFile() string { return e.File } func (e extendedEvent) GetLine() int { return e.Line } func NewExtendedEvent(level, message string, data json.RawMessage, file string, line int) ExtendedEvent { return extendedEvent{ Event: NewEvent(level, message, data), File: file, Line: line, } } ======= >>>>>>> REPLACE ``` simplelog.go ```go <<<<<<< SEARCH ======= type ExtendedEvent interface { GetID() uuid.UUID GetTimestamp() time.Time GetLevel() string GetMessage() string GetData() json.RawMessage GetFile() string GetLine() int } type extendedEvent struct { Event File string `json:"file"` Line int `json:"line"` } func (e extendedEvent) GetID() uuid.UUID { return e.ID } func (e extendedEvent) GetTimestamp() time.Time { return e.Timestamp } func (e extendedEvent) GetLevel() string { return e.Level } func (e extendedEvent) GetMessage() string { return e.Message } func (e extendedEvent) GetData() json.RawMessage { return e.Data } func (e extendedEvent) GetFile() string { return e.File } func (e extendedEvent) GetLine() int { return e.Line } func NewExtendedEvent(level, message string, data json.RawMessage, file string, line int) ExtendedEvent { return extendedEvent{ Event: NewEvent(level, message, data), File: file, Line: line, } } >>>>>>> REPLACE ```
This commit is contained in:
parent
3638c0c4df
commit
4bc389781a
51
event.go
51
event.go
|
@ -15,57 +15,6 @@ type Event struct {
|
|||
Data json.RawMessage `json:"data"`
|
||||
}
|
||||
|
||||
type ExtendedEvent interface {
|
||||
GetID() uuid.UUID
|
||||
GetTimestamp() time.Time
|
||||
GetLevel() string
|
||||
GetMessage() string
|
||||
GetData() json.RawMessage
|
||||
GetFile() string
|
||||
GetLine() int
|
||||
}
|
||||
|
||||
type extendedEvent struct {
|
||||
Event
|
||||
File string `json:"file"`
|
||||
Line int `json:"line"`
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetID() uuid.UUID {
|
||||
return e.ID
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetTimestamp() time.Time {
|
||||
return e.Timestamp
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetLevel() string {
|
||||
return e.Level
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetMessage() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetData() json.RawMessage {
|
||||
return e.Data
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetFile() string {
|
||||
return e.File
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetLine() int {
|
||||
return e.Line
|
||||
}
|
||||
|
||||
func NewExtendedEvent(level, message string, data json.RawMessage, file string, line int) ExtendedEvent {
|
||||
return extendedEvent{
|
||||
Event: NewEvent(level, message, data),
|
||||
File: file,
|
||||
Line: line,
|
||||
}
|
||||
}
|
||||
|
||||
func NewEvent(level, message string, data json.RawMessage) Event {
|
||||
return Event{
|
||||
|
|
51
simplelog.go
51
simplelog.go
|
@ -81,3 +81,54 @@ func (cl *CustomHandler) WithGroup(name string) slog.Handler {
|
|||
}
|
||||
return &CustomHandler{handlers: newHandlers}
|
||||
}
|
||||
type ExtendedEvent interface {
|
||||
GetID() uuid.UUID
|
||||
GetTimestamp() time.Time
|
||||
GetLevel() string
|
||||
GetMessage() string
|
||||
GetData() json.RawMessage
|
||||
GetFile() string
|
||||
GetLine() int
|
||||
}
|
||||
|
||||
type extendedEvent struct {
|
||||
Event
|
||||
File string `json:"file"`
|
||||
Line int `json:"line"`
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetID() uuid.UUID {
|
||||
return e.ID
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetTimestamp() time.Time {
|
||||
return e.Timestamp
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetLevel() string {
|
||||
return e.Level
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetMessage() string {
|
||||
return e.Message
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetData() json.RawMessage {
|
||||
return e.Data
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetFile() string {
|
||||
return e.File
|
||||
}
|
||||
|
||||
func (e extendedEvent) GetLine() int {
|
||||
return e.Line
|
||||
}
|
||||
|
||||
func NewExtendedEvent(level, message string, data json.RawMessage, file string, line int) ExtendedEvent {
|
||||
return extendedEvent{
|
||||
Event: NewEvent(level, message, data),
|
||||
File: file,
|
||||
Line: line,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue