Skip to content

Commit

Permalink
Using StaticString since that's more correct
Browse files Browse the repository at this point in the history
  • Loading branch information
AvdLee committed Dec 3, 2021
1 parent cd84cf7 commit e3ae5d2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Sources/Logging/DiagnosticsLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public final class DiagnosticsLogger {
/// - file: The file from which the log is send. Defaults to `#file`.
/// - function: The functino from which the log is send. Defaults to `#function`.
/// - line: The line from which the log is send. Defaults to `#line`.
public static func log(message: String, file: String = #file, function: String = #function, line: UInt = #line) {
public static func log(message: String, file: StaticString = #file, function: StaticString = #function, line: UInt = #line) {
standard.log(LogItem(.debug(message: message), file: file, function: function, line: line))
}

Expand All @@ -72,7 +72,7 @@ public final class DiagnosticsLogger {
/// - file: The file from which the log is send. Defaults to `#file`.
/// - function: The functino from which the log is send. Defaults to `#function`.
/// - line: The line from which the log is send. Defaults to `#line`.
public static func log(error: Error, description: String? = nil, file: String = #file, function: String = #function, line: UInt = #line) {
public static func log(error: Error, description: String? = nil, file: StaticString = #file, function: StaticString = #function, line: UInt = #line) {
standard.log(LogItem(.error(error: error, description: description), file: file, function: function, line: line))
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Logging/Loggable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ struct LogItem: Loggable {
let message: String
let cssClass: String?

init(_ type: LogType, file: String, function: String, line: UInt) {
init(_ type: LogType, file: StaticString, function: StaticString, line: UInt) {
let date = DateFormatter.current.string(from: Date())
let file = file.split(separator: "/").last.map(String.init) ?? file
let file = String(describing: file).split(separator: "/").last.map(String.init) ?? String(describing: file)
self.message = String(format: "%@ | %@:L%@ | %@", date, file, String(line), type.message)
self.cssClass = type.cssClass
}
Expand Down

0 comments on commit e3ae5d2

Please sign in to comment.