Package {writeLog}


Title: Write Printed Output of R Objects to Log Files
Version: 0.1.0
Description: Provides writeLog(), a small helper that writes the printed output of a named list of R objects to a text file in a log directory, one element after another, each preceded by its list name as a heading. Supports versioned file names and appending to an existing log file.
License: MIT + file LICENSE
Encoding: UTF-8
RoxygenNote: 7.3.3
Suggests: testthat (≥ 3.0.0), withr
Config/testthat/edition: 3
URL: https://github.com/jeffzifanwu/writeLog
BugReports: https://github.com/jeffzifanwu/writeLog/issues
NeedsCompilation: no
Packaged: 2026-10-03 13:02:47 UTC; jzw121
Author: Jeffzifan Wu [aut, cre]
Maintainer: Jeffzifan Wu <zifan.jeffwu@gmail.com>
Repository: CRAN
Date/Publication: 2026-10-15 16:10:02 UTC

Write the printed output of each element of a named list to a .txt file in logDir, one after another, each preceded by its list name as a heading.

Description

Write the printed output of each element of a named list to a .txt file in logDir, one after another, each preceded by its list name as a heading.

Usage

writeLog(
  x,
  fileName = "log",
  version = NULL,
  desc = NULL,
  logDir,
  append = FALSE
)

Arguments

x

Named list of objects to print/log, e.g. list(int.orig = summary(int), int.hp = halvorsenPalmquist(int)).

fileName

Name of the log file, without extension (e.g. "aq_bdr").

version

Version label prepended to fileName (e.g. "v1"). The file is written as logDir/version_fileName.txt; if NULL, the version prefix and its separator are dropped.

desc

Description to print at the top of the log file.

logDir

Directory to write the log file to, e.g. tempdir(). Created if missing. There is no default, so the package never writes to the working directory or home filespace unless you ask it to.

append

If TRUE, add to the log file when it already exists rather than overwriting it; if it does not exist, a new file is created. If FALSE (the default), any existing file is overwritten.

Value

x, invisibly (so this can be used inline without breaking a pipe).

Examples

tmp <- tempfile()
writeLog(list(one = 1:3, summary = summary(1:10)),
         fileName = "example", logDir = tmp)
readLines(file.path(tmp, "example.txt"))