Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanAccessLogs ¶ added in v0.2.0
func CanAccessLogs() bool
CanAccessLogs checks if the current process has permission to access system logs. It returns true if the process is running as root or can successfully open the systemd journal.
func CreateListLogsSchema ¶ added in v0.2.0
func CreateListLogsSchema() *jsonschema.Schema
Types ¶
type HostLog ¶
type HostLog struct {
// contains filtered or unexported fields
}
func NewLog ¶
func NewLog(auth *auth.AuthKeeper) (*HostLog, error)
NewLog instance creates a new HostLog instance
func (*HostLog) ListLog ¶
func (sj *HostLog) ListLog(ctx context.Context, req *mcp.CallToolRequest, params *ListLogParams) (*mcp.CallToolResult, any, error)
func (sj *HostLog) ListLogTimeout(ctx context.Context, req *mcp.CallToolRequest, params *ListLogParams) (*mcp.CallToolResult, any, error) {
slog.Debug("ListLogTimeout called", "params", params)
timeoutCtx, cancel := context.WithTimeout(ctx, 1*time.Second)
defer cancel()
resultChan := make(chan struct {
res *mcp.CallToolResult
out any
err error
}, 1)
go func() {
res, out, err := sj.ListLog(timeoutCtx, req, params)
resultChan <- struct {
res *mcp.CallToolResult
out any
err error
}{res: res, out: out, err: err}
}()
select {
case <-timeoutCtx.Done():
// The timeout context was cancelled, meaning the timeout occurred.
return nil, nil, fmt.Errorf("timed out: %w", timeoutCtx.Err())
case result := <-resultChan:
// ListLog completed within the timeout.
return result.res, result.out, result.err
}
}
get the lat log entries for a given unit, else just the last messages
type ListLogParams ¶
type ListLogParams struct {
Count int `json:"count,omitempty" jsonschema:"Number of log lines to output"`
Offset int `json:"offset,omitempty" jsonschema:"Number of newest log entries to skip for pagination"`
From time.Time `json:"from,omitempty" jsonschema:"Start time for filtering logs"`
To time.Time `json:"to,omitempty" jsonschema:"End time for filtering logs "`
Pattern string `json:"pattern,omitempty" jsonschema:"Regular expression pattern to filter log messages."`
Unit string `` /* 181-byte string literal not displayed */
AllBoots bool `json:"allboots,omitempty" jsonschema:"Get the log entries from all boots, not just the active one"`
}
type ListLogResult ¶ added in v0.2.0
type ListLogResult struct {
Host string `json:"host"`
NrMessages int `json:"nr_messages"`
Hint string `json:"hint,omitempty"`
Documentation []ManPage `json:"documentation,omitempty"`
Messages []LogOutput `json:"messages"`
Identifier string `json:"identifier,omitempty"`
UnitName string `json:"unit_name,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.