Package loggit. April 9, 2018

Similar documents
Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package repec. August 31, 2018

Package messaging. May 27, 2018

Package robotstxt. November 12, 2017

Package lumberjack. R topics documented: July 20, 2018

Package fastdummies. January 8, 2018

Package fitbitscraper

Package githubinstall

Package goodpractice

Package crossword.r. January 19, 2018

Package ECctmc. May 1, 2018

Package dkanr. July 12, 2018

Package clipr. June 23, 2018

Package SNPediaR. April 9, 2019

Package canvasxpress

Package jdx. R topics documented: January 9, Type Package Title 'Java' Data Exchange for 'R' and 'rjava'

Package datasets.load

Package GetoptLong. June 10, 2018

Package calpassapi. August 25, 2018

Package opencage. January 16, 2018

Package oec. R topics documented: May 11, Type Package

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package dbx. July 5, 2018

Package rbraries. April 18, 2018

Package ezknitr. September 16, 2016

Package pdfsearch. July 10, 2018

Package facerec. May 14, 2018

Package modules. July 22, 2017

Package rwars. January 14, 2017

Package ezsummary. August 29, 2016

Package reval. May 26, 2015

Package postgistools

Package htmlwidgets. July 10, 2017

Package datapasta. January 24, 2018

Package d3plus. September 25, 2017

Package censusr. R topics documented: June 14, Type Package Title Collect Data from the Census API Version 0.0.

Package RODBCext. July 31, 2017

Package rprojroot. January 3, Title Finding Files in Project Subdirectories Version 1.3-2

Package wikitaxa. December 21, 2017

Package tibble. August 22, 2017

Package splithalf. March 17, 2018

Package internetarchive

Package slickr. March 6, 2018

Package virustotal. May 1, 2017

Package spelling. December 18, 2017

Package eply. April 6, 2018

Package rcmdcheck. R topics documented: November 10, 2018

Package rgho. R topics documented: January 18, 2017

Package validara. October 19, 2017

Package knitrprogressbar

Package htmlwidgets. February 25, 2016

Package gtrendsr. August 4, 2018

Package guardianapi. February 3, 2019

Package docxtools. July 6, 2018

Package tfruns. February 18, 2018

Package bisect. April 16, 2018

Package climber. R topics documented:

Package rtext. January 23, 2019

Package fastqcr. April 11, 2017

Package rsppfp. November 20, 2018

Package vinereg. August 10, 2018

Package profvis. R topics documented:

Package gtrendsr. October 19, 2017

Package jug. April 13, 2017

Package darksky. September 20, 2017

Package jstree. October 24, 2017

Package semver. January 6, 2017

Package processanimater

Package haven. April 9, 2015

Package jpmesh. December 4, 2017

Package io. January 15, 2018

Package cloudml. June 12, 2018

Package available. November 17, 2017

Package redux. May 31, 2018

Package widyr. August 14, 2017

Package nodbi. August 1, 2018

Package postal. July 27, 2018

Package tabulizer. June 7, 2018

Package mdftracks. February 6, 2017

Package smapr. October 20, 2017

Package projector. February 27, 2018

Package reconstructr

Package spark. July 21, 2017

Package rgdax. January 7, 2019

Package bigreadr. R topics documented: August 13, Version Date Title Read Large Text Files

Package kirby21.base

Package barcoder. October 26, 2018

Package humanize. R topics documented: April 4, Version Title Create Values for Human Consumption

Package cancensus. February 4, 2018

Package patentsview. July 12, 2017

Package geoops. March 19, 2018

Package rcv. August 11, 2017

Package sqlscore. April 29, 2018

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Package edfreader. R topics documented: May 21, 2017

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package deductive. June 2, 2017

Package IsoCorrectoR. R topics documented:

Package nngeo. September 29, 2018

Package keyholder. May 19, 2018

Transcription:

Title Effortless Exception Logging Package loggit April 9, 2018 A very simple and easy-to-use set of suspiciously-familiar functions. 'loggit' provides a set of wrappings for base R's message(), warning(), and stop() functions that maintain identical functionality, but also log the handler message to a 'JSON' log file. While mostly automatic, powerful custom logging is available via these handlers' logging function, loggit(), which is also exported for use. No change in existing code is necessary to use this package. Version 1.1.1 Date 2018-04-08 License MIT + file LICENSE Depends R (>= 3.4.0) Imports dplyr (>= 0.7.4), jsonlite (>= 1.5) Suggests knitr (>= 1.19), rmarkdown (>= 1.8), testthat (>= 2.0.0) URL https://github.com/ryapric/loggit BugReports https://github.com/ryapric/loggit/issues RoxygenNote 6.0.1 NeedsCompilation no Author Ryan Price [cre, aut] Maintainer Ryan Price <ryapric@gmail.com> Repository CRAN Date/Publication 2018-04-09 07:36:59 UTC R topics documented: getlogfile.......................................... 2 gettimestampformat.................................... 2 get_logs........................................... 3 handlers........................................... 3 loggit............................................ 4 setlogfile.......................................... 5 settimestampformat.................................... 6 1

2 gettimestampformat Index 7 getlogfile Get Log File Get the log file that loggit will write to. getlogfile() getlogfile() gettimestampformat Get Timestamp Format Get timestamp format for use in output logs. gettimestampformat() gettimestampformat()

get_logs 3 get_logs Return Log File as an R Object This function returns a data.frame (by default) containing all the logs in the provided JSON log file. If no explicit log fie is provided, calling this function will return a data frame of the log file currently pointed to by the loggit functions. Users can request that the logs be returned as a list, though this is not recommended. get_logs(logfile, as_df = TRUE) logfile as_df JSON-format log file to return. Should logfile be returned in a data.frame vs. a list? Defaults to TRUE, and will return a data.frame. Value A data.frame. setlogfile(file.path(tempdir(), "loggit.json"), confirm = FALSE) message("test log message") get_logs(getlogfile()) handlers Loggit s Exception Handlers These exception handlers are identical to base R s message, warning, and stop, but with included logging of the exception messages.

4 loggit message(..., domain = NULL, appendlf = TRUE,.loggit = TRUE, log_detail = "", echo = FALSE) warning(..., call. = TRUE, immediate. = FALSE, nobreaks. = FALSE, domain = NULL,.loggit = TRUE, log_detail = "", echo = FALSE) stop(..., call. = TRUE, domain = NULL,.loggit = TRUE, log_detail = "", echo = FALSE)... zero or more objects which can be coerced to character (and which are pasted together with no separator) or (for message only) a single condition object. domain appendlf.loggit log_detail echo call. see gettext. If NA, messages will not be translated, see also the note in stop. logical: should messages given as a character string have a newline appended? Should loggit function execute? Defaults to TRUE. Additional information to accompany log message. Must be a string. Should loggit s log be echoed to the console, as well? Defaults to FALSE. logical, indicating if the call should become part of the warning message. immediate. logical, indicating if the call should be output immediately, even if getoption("warn") <= 0. nobreaks. logical, indicating as far as possible the message should be output as a single line when options(warn = 1). if (2 < 1) message("don't say such silly things!") if (2 < 1) warning("you may want to review that math, and so this is your warning") if (2 < 1) stop("this is a completely false condition, which throws an error") loggit Log Message to Output File This function executes immediately before the function definitions for the base handler functions (message, warning, and stop, and logs their timestamped output (a bit more verbosely) to a log file. The log file defaults to a JSON file, which is a portable file format that is easily parsed by many systems, but will eventually have a.txt option as well. loggit(log_lvl, log_msg, log_detail = "",..., echo = TRUE)

setlogfile 5 log_lvl log_msg log_detail Level of log output. In actual practice, one of "INFO", "WARN", and "ER- ROR" are common, but any string may be supplied. Will be coerced to class character. Main log message. Will be coerced to class character. Additional detail recorded along with a log message.... A named list or named vector (each element of length one) of other custom fields you wish to log. You do not need to explicitly provide these fields as a formal list or vector, as shown in the example; R handles the coercion. echo Details Should a message be printed to the console as well? Defaults to TRUE, and is truncated to just the level & message of the log. This argument is passed as FALSE when called from loggit s handlers, since they still call base R s handlers at the end of execution, all of which print to the console as well. While this function has an intended use of logging handler messages without any direct user interaction, it is flexible enough to be used as you see fit. loggit("info", "This is a message", but_maybe = "you want more fields?", sure = "why not?", like = 2, or = 10, what = "ever") setlogfile Set Log File Set the log file that loggit will write to. No logs will be written until this is set, as per CRAN policy. The suggested use of this function would be to call it early, to log to the current working directory, as follows: setlogfile(paste0(getwd(), "/loggit.json")). If you are using loggit in your package, you can wrap this function in.onload() so that the logfile is set when your package loads. setlogfile(logfile = NULL, confirm = TRUE) logfile confirm Full path to log file. Until other output formats are introduced, the file name must end in ".json". Print confirmation of log file setting? Defaults to TRUE.

6 settimestampformat setlogfile(file.path(tempdir(), "loggit.json")) settimestampformat Set Timestamp Format Set timestamp format for use in output logs. settimestampformat(ts_format = "%Y-%m-%d %H:%M:%S", confirm = TRUE) ts_format confirm ISO date format. Print confirmation of timestamp format setting? Defaults to TRUE. settimestampformat("%y-%m-%d %H:%M:%S")

Index get_logs, 3 getlogfile, 2 getoption, 4 gettext, 4 gettimestampformat, 2 handlers, 3 loggit, 4 message, 3, 4 message (handlers), 3 setlogfile, 5 settimestampformat, 6 stop, 3, 4 stop (handlers), 3 warning, 3, 4 warning (handlers), 3 7