-
Notifications
You must be signed in to change notification settings - Fork 79
Open
Labels
Description
Line 147 in 816ff01
open func error(_ message: @autoclosure @escaping () -> LogMessage) { |
I don't see a way to attach the file name and line number to the logs, which would be useful for errors especially. Is this something you've considered and discarded or just something you haven't needed? I'm going to add it to my project, if it's something you're interested in, I'd be happy to make a PR at add this. This is basically the code:
// function
open func error(_ message: @autoclosure @escaping () -> LogMessage, _ file: String = #file, _ line: Int = #line) {
print("file = \(file)\nline = \(line)")
logMessage(message, with: LogLevel.error)
}
// function call (unchanged)
log.error(Message.requestFailed(request: request, response: fakeResponse, error: nil))
// resulting output
file = /Users/.../Desktop/Willow-5.1.0 2/Example/Frameworks/Database/Connection.swift
line = 63
2019-07-31 12:27:57.744 💣💥💣💥 [Database] => SQL Error: ["error_description": "The database file is locked", "framework_name": "Database", "result": "failure", "framework_version": "1.0", "sql": "CREATE TABLE cars(make TEXT NOT NULL, model TEXT NOT NULL)", "error_code": 5]
This would be especially helpful when creating a LogWriter to post logs to a server. That way you can determine error locations based on logs.