Display logs from XCGlogger
Opened this issue · 3 comments
Deleted user commented
XCGlogger is a popular logging tool.
It should be great to connect Dotzu to XCGlogger. And other log tool by extension.
remirobert commented
@Domsware That's an awesome idea 💡
Thank you 😊, I will add this suggestion in my list.
DanielAsher commented
Below's the XCGLogger DotzuLogDestination
I use. I also have a fork that comments out this line. A configuration option would be better :)
// http://www.wtfpl.net/
import XCGLogger
import Dotzu
open class DotzuLogDestination: BaseDestination {
// MARK: - Properties
/// The dispatch queue to process the log on
open var logQueue: DispatchQueue? = nil
/// Option: whether or not to output the date the log was created (Always false for this destination)
open override var showDate: Bool {
get {
return false
}
set {
// ignored, NSLog adds the date, so we always want showDate to be false in this subclass
}
}
// MARK: - Overridden Methods
/// Print the log to the Apple System Log facility (using NSLog).
///
/// - Parameters:
/// - logDetails: The log details.
/// - message: Formatted/processed message ready for output.
///
/// - Returns: Nothing
///
open override func output(logDetails: LogDetails, message: String) {
let outputClosure = {
var logDetails = logDetails
var message = message
// Apply filters, if any indicate we should drop the message, we abort before doing the actual logging
if self.shouldExclude(logDetails: &logDetails, message: &message) {
return
}
self.applyFormatters(logDetails: &logDetails, message: &message)
switch logDetails.level {
case .error:
Logger.error(message, file: "", function: "", line: 0)
case .warning:
Logger.warning(message, file: "", function: "", line: 0)
case .info:
Logger.info(message, file: "", function: "", line: 0)
case .debug, .verbose:
Logger.verbose(message, file: "", function: "", line: 0)
default: return
}
}
if let logQueue = logQueue {
logQueue.async(execute: outputClosure)
}
else {
outputClosure()
}
}
}
remirobert commented
@DanielAsher Hey, that's very good. I am working on a very modulable way to display logs from any sources. Using protocols. The direction I want to take with dotzu, is like a generic debug tools, than you can improve, and use with your datas.