sanitizers {loggit}R Documentation

Default sanitization for ndJSON.

Description

This is the default ndJSON sanitizer function for log data being read into the R session by read_logs(). This type of function is needed because since loggit reimplements its own string-based JSON parser, and not a fancy one built from an AST or something, it's very easy to have bad patterns break your logs. You may also specify your own sanitizer function to pass to loggit(), which takes a single string and returns an (optionally-transformed) string, where each string is an individual element of the log data.

Usage

default_ndjson_sanitizer(string, sanitize = TRUE)

default_ndjson_unsanitizer(string)

Arguments

string

Each element of the log data to operate on. Note that this is each element, not each line in the logs. For example, each entry in the log_msg field across all logs will be sanitized/unsanitized individually. This is important because if writing your own sanitizer function, it must take and return a single string as its argument.

sanitize

Whether the operation will sanitize, or unsanitize the log data. Defaults to TRUE, for sanitization on write.

Details

The default string patterns and their replacements are currently mapped as follows:

Character Replacement in log file
⁠{⁠ ⁠__LEFTBRACE__⁠
⁠}⁠ ⁠__RIGHTBRACE__⁠
⁠"⁠ ⁠__DBLQUOTE__⁠
⁠,⁠ ⁠__COMMA__⁠
⁠\r⁠ ⁠__CR__⁠
⁠\n⁠ ⁠__LF__⁠

Value

A single string.


[Package loggit version 2.1.1 Index]