-
Notifications
You must be signed in to change notification settings - Fork 122
/
logs.go
63 lines (46 loc) · 1.57 KB
/
logs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package repository
import (
"context"
"time"
"github.com/hatchet-dev/hatchet/internal/repository/prisma/dbsqlc"
)
type CreateLogLineOpts struct {
// The step run id
StepRunId string `validate:"required,uuid"`
// (optional) The time when the log line was created.
CreatedAt *time.Time
// (required) The message of the log line.
Message string `validate:"required,min=1,max=10000"`
// (optional) The level of the log line.
Level *string `validate:"omitnil,oneof=INFO ERROR WARN DEBUG"`
// (optional) The metadata of the log line.
Metadata []byte
}
type ListLogsOpts struct {
// (optional) number of logs to skip
Offset *int
// (optional) number of logs to return
Limit *int `validate:"omitnil,min=1,max=1000"`
// (optional) a list of log levels to filter by
Levels []string `validate:"omitnil,dive,oneof=INFO ERROR WARN DEBUG"`
// (optional) a step run id to filter by
StepRunId *string `validate:"omitempty,uuid"`
// (optional) a search query
Search *string
// (optional) the order by field
OrderBy *string `validate:"omitempty,oneof=createdAt"`
// (optional) the order direction
OrderDirection *string `validate:"omitempty,oneof=ASC DESC"`
}
type ListLogsResult struct {
Rows []*dbsqlc.LogLine
Count int
}
type LogsAPIRepository interface {
// ListLogLines returns a list of log lines for a given step run.
ListLogLines(tenantId string, opts *ListLogsOpts) (*ListLogsResult, error)
}
type LogsEngineRepository interface {
// PutLog creates a new log line.
PutLog(ctx context.Context, tenantId string, opts *CreateLogLineOpts) (*dbsqlc.LogLine, error)
}