From 0ceb6a3503b1b8e0d528f6e82f9942aa0f4490fa Mon Sep 17 00:00:00 2001 From: Sergey Petrov Date: Thu, 30 Mar 2017 17:02:11 +0300 Subject: [PATCH] Enable use of custom or no logging function --- Sources/Utils.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Sources/Utils.swift b/Sources/Utils.swift index 3811e99..1dd1b1a 100644 --- a/Sources/Utils.swift +++ b/Sources/Utils.swift @@ -30,9 +30,15 @@ public enum LogLevel: Int { public var logLevel: LogLevel = .Errors +public typealias LoggingFunctionType = (LogLevel, Any) -> Void + +public var loggingFunction: LoggingFunctionType? = { _, message in + print(message) +} + func log(level logLevel: LogLevel, _ message: Any) { guard logLevel.rawValue <= Dip.logLevel.rawValue else { return } - print(message) + loggingFunction?(logLevel, message) } ///Internal protocol used to unwrap optional values.