Skip to content

Conversation

@psolymos
Copy link

This PR addresses #20 and fixes an issue when nrow(log_df) - rotate_lines + 1 leads to negative row index.

This can happen when rotate_lines > nrow(log_df)

Signed-off-by: Peter Solymos <psolymos@gmail.com>
Signed-off-by: Peter Solymos <psolymos@gmail.com>
Signed-off-by: Peter Solymos <psolymos@gmail.com>
Signed-off-by: Peter Solymos <psolymos@gmail.com>
Signed-off-by: Peter Solymos <psolymos@gmail.com>
#' set_rotate_lines(NULL) # turn off auto-truncation
#'
#' @export
set_rotate_lines <- function(rotate_lines = 100000, confirm = TRUE) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think given the naming convention of the function itself (set_rotate_lines() vs. e.g. set_rotation_on()), this should default to NULL instead of an integer, since it expects an integer. Might need a check in rotate_logs() as well if NULL is passed in, so it doesn't crash.

@ryapric
Copy link
Owner

ryapric commented Apr 12, 2022

Thank you, looks pretty good! Could you also add some tests to confirm functionality?

@psolymos
Copy link
Author

@ryapric I addressed the comments. Let me know what you think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add rotate_lines to .config and rotate logs automatically

2 participants