Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: logs lines support '-' sign means starting log file lines #365

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/kubevpn/cmds/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ func CmdLogs(f cmdutil.Factory) *cobra.Command {
},
}
cmd.Flags().BoolVarP(&req.Follow, "follow", "f", false, "Specify if the logs should be streamed.")
cmd.Flags().Int32VarP(&req.Lines, "number", "N", 10, "The location is number lines.")
cmd.Flags().Int32VarP(&req.Lines, "number", "N", 10, "Lines of recent log file to display.")
return cmd
}
6 changes: 5 additions & 1 deletion pkg/daemon/action/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ func (svr *Server) Logs(req *rpc.LogRequest, resp rpc.Daemon_LogsServer) error {
}

// only show latest N lines
lines -= req.Lines
if req.Lines < 0 {
lines = -req.Lines
} else {
lines -= req.Lines
}

config := tail.Config{Follow: req.Follow, ReOpen: false, MustExist: true, Logger: log.New(io.Discard, "", log.LstdFlags)}
if !req.Follow {
Expand Down
Loading