Skip to content

loggit2 v2.3.0

Choose a tag to compare

@MEO265 MEO265 released this 08 Jun 10:43
· 23 commits to main since this release
4b600d9

Breaking Changes

  • Custom sanitizers and unsanitizers are no longer supported. This decision was made because no active user is known,
    and this functionality severely limits further development. If custom sanitizers were previously used,
    they can simply be executed before or after loggit() or read_logs().
    If custom sanitizers were used to circumvent bugs, please report them, so they can be fixed.
  • Special characters are no longer escaped by replacement, but rather by "\".

New Features

  • Added convert_to_csv() to convert log files to CSV format.
  • Added with_loggit() to log third-party code or to easily use different loggit() parameters for a chunk of code.
  • NAs are now stored as null in the JSON log, and read_logs() also restores these as NA. This was previously (unintentionally) guaranteed by replacing the NA with "__NA__".
  • read_logs() now allows reading the logs in reverse order using the last_first argument.
  • A global log level can now be set using set_log_level(), which is used by all functions unless otherwise stated. The log levels are: "DEBUG", "INFO", "WARN", "ERROR", and "NONE".
  • Added set_echo() to control globally whether log messages are echoed to the console.
  • All condition log handlers (e.g., warning()) allow NA for the parameter .loggit. If NA, the log level set by set_log_level() is used
    to determine if the condition should be logged. This is the new default behavior, but since the default log level is "DEBUG", this should not change the behavior of existing code.
  • All set_* functions now return the previous value of the setting.
  • The default settings can now be controlled by the system environment variables FILE_LOGGIT2, TIMESTAMP_LOGGIT2, ECHO_LOGGIT2 and LEVEL_LOGGIT2.

Bugfixes

  • read_logs() now correctly reads empty character values "", as in {"key": ""}.
    Previously, empty fields were read as NA. This meant that when rotate_logs() was used,
    these entries could completely disappear from the respective JSON object.
  • loggit() now does not unintentionally “repair” argument names of log entries.
    Previously, the names were replaced by check.names of data.frame(), which could lead to unexpected behavior.
    Names that are not valid JSON keys are now escaped according to the JSON standard.

Minor Changes

  • read_logs() now returns a data.frame with the empty character columns "timestamp", "log_lvl", and "log_msg" instead of an empty (0x0) data.frame if the log file has no entries.
  • The JSON reading functions are more tolerant of manual changes to the log.
  • The parameter exprs was added to stopifnot() and included in the documentation. This has no impact on functionality due to the specific way base::stopifnot() is called internally.
  • loggit() now throws an error if there are unnamed ... arguments. Previously, these were silently named by fix.empty.names of data.frame, which could lead to unexpected behavior.
  • loggit() now also checks the length of the log_lvl and log_msg arguments and only uses the first element.
    Previously, the log entry had been multiplied, leading to unintended consequences regarding custom_log_lvl.

Internals

  • write_ndjson no longer warns if the log contains unsanitized line breaks. This warning could only be generated by package-internal errors
    (therefore nonsensical in the CRAN package) or by a custom sanitizer, but in this case only this one character was specifically tested and thus provides a false sense of security.
  • The package now requires compilation. This is necessary because the JSON parser was written in C++ for faster reading.
  • loggit2 now requires at least R 4.0.0.