Skip to content

Commit

Permalink
feat: logs lines support '-' sign means starting log file lines (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
wencaiwulue authored Oct 30, 2024
1 parent f966cd2 commit 6e052a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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

0 comments on commit 6e052a5

Please sign in to comment.