https://hal.archives-ouvertes.fr/hal-02180177
Tip revision: 51caf31e4d5744daf59d53d73f66ff2263a705bf authored by Software Heritage on 01 January 2015, 00:00:00 UTC
hal: Deposit 324 in collection hal
hal: Deposit 324 in collection hal
Tip revision: 51caf31
define-functions.R
#############################################################################################
# Defines common functions for all scripts.
#
# 05/2016 Vincent Labatut
#############################################################################################
#############################################################################################
# Logs the specified message on screen, adding current date and time, and possible some
# offset (to represent the hierarchy of function calls).
#
# offset: number of "." used to represent the hierarchical level of the message.
# ...: parameters fetched to the cat function.
#############################################################################################
tlog <- function(offset=NA, ...)
{ prefix <- paste0("[",format(Sys.time(),"%a %d %b %Y %X"),"] ")
if(!is.na(offset))
{ if(is.numeric(offset))
{ os <- paste(rep(".",offset), sep="", collapse="")
prefix <- paste0(prefix, os)
}
else
prefix <- paste0(prefix, offset)
}
cat(prefix, ..., "\n", sep="")
}