From f69550d0db172497160347d1121ed7a5fca9a015 Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Wed, 23 Aug 2017 22:33:45 -0400 Subject: [PATCH] Allow logging function to be customized --- src/duplicacy_log.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/duplicacy_log.go b/src/duplicacy_log.go index 0cde121..2d8e25b 100644 --- a/src/duplicacy_log.go +++ b/src/duplicacy_log.go @@ -23,6 +23,7 @@ const ( ASSERT = 4 ) +var LogFunction func(level int, logID string, message string) var printLogHeader = false @@ -117,6 +118,11 @@ func logf(level int, logID string, format string, v ...interface{}) { message := fmt.Sprintf(format, v...) + if LogFunction != nil { + LogFunction(level, logID, message) + return + } + now := time.Now() // Uncomment this line to enable unbufferred logging for tests