ryapric / loggit

Modern Logging for the R Ecosystem
Other
37 stars 2 forks source link

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

Open VZoche-Golob opened 6 months ago

VZoche-Golob commented 6 months ago

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)
}
MEO265 commented 5 months ago

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.