SWS-Methodology / faoswsTrade

World trade data processing for the FAO Statistical Working System
http://www.fao.org/economic/ess/ess-home/en/
5 stars 2 forks source link

Create custom futile.logger layout for table output in reports #69

Open malexan opened 7 years ago

malexan commented 7 years ago

See ? flog.layout

malexan commented 7 years ago

Use capture.output() with paste(... collapse = "\n")

Like:

f <- function(msg, tbl) {

  paste(c(msg, capture.output(glimpse(tbl))), collapse = "\n")

}
malexan commented 7 years ago

Now in 9a2e8bf92bea5dec3d986ffad9510d0aaae48dc4 glimpse0() function produces the following with NULL as last line:

> flog.info("HS->FCL mapping table preview:",
+           glimpse0(hsfclmap3), capture = TRUE)
INFO [2017-02-09 16:22:38] HS->FCL mapping table preview:

Observations: 862,329
Variables: 8
$ area       <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
$ flow       <int> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1...
$ fromcode   <chr> "01011010", "01011100", "01011900", "01012010", "010...
$ tocode     <chr> "01011010", "01011199", "01011999", "01012010", "010...
$ fcl        <int> 1096, 1096, 1096, 1107, 1110, 1096, 866, 866, 1034, ...
$ startyear  <int> 2005, 2000, 2000, 2000, 2000, 2011, 2000, 2000, 2000...
$ endyear    <int> 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050, 2050...
$ recordnumb <dbl> 5783312, 5794641, 5794640, 5794632, 5794631, 5766377...
NULL
>