loggit icon indicating copy to clipboard operation
loggit copied to clipboard

Error in rotate_logs if there are less than rotate_lines lines in logfile

Open VZoche-Golob opened this issue 1 year ago • 1 comments

Thank you for this very useful tool! Unfortunately, rotate_logs() will cause an error ("Error in xj[i] : only 0's may be mixed with negative subscripts") if there are less than rotate_lines lines in the logfile.

I suggest the following fix: Replace lines 85-86 of loggit/R/utils.R with

if (nrow(log_df) > rotate_lines) {
  log_df <- log_df[(nrow(log_df) - rotate_lines + 1):nrow(log_df), ]
  write_ndjson(log_df, logfile, echo = FALSE, overwrite = TRUE)
}

VZoche-Golob avatar Apr 05 '24 09:04 VZoche-Golob

Hey @VZoche-Golob , my impression is that the package is no longer being developed. Since I have created a few issues and PRs here myself and have not received any responses, I have published a fork on Cran:

https://cran.r-project.org/package=loggit2

Maybe it will help you. Your bug is also fixed there.

MEO265 avatar May 05 '24 12:05 MEO265