-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bfba62
commit 0f7c916
Showing
3 changed files
with
61 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// | ||
// Napier.swift | ||
// Napier | ||
// | ||
// Created by Phil on 23.10.2021. | ||
// Copyright © 2021 AAkira. All rights reserved. | ||
// | ||
|
||
import mpp_sample | ||
|
||
extension Napier { | ||
static func v(tag: String? = nil, _ items: Any..., separator: String = " ", file: String = #file, function: String = #function) { | ||
log(logLevel: .verbose, tag: tag, items, separator: separator, file: file, function: function) | ||
} | ||
|
||
static func d(tag: String? = nil, _ items: Any..., separator: String = " ", file: String = #file, function: String = #function) { | ||
log(logLevel: .debug, tag: tag, items, separator: separator, file: file, function: function) | ||
} | ||
|
||
static func i(tag: String? = nil, _ items: Any..., separator: String = " ", file: String = #file, function: String = #function) { | ||
log(logLevel: .info, tag: tag, items, separator: separator, file: file, function: function) | ||
} | ||
|
||
static func w(tag: String? = nil, _ items: Any..., separator: String = " ", file: String = #file, function: String = #function) { | ||
log(logLevel: .warning, tag: tag, items, separator: separator, file: file, function: function) | ||
} | ||
|
||
static func e(tag: String? = nil, _ items: Any..., separator: String = " ", file: String = #file, function: String = #function) { | ||
log(logLevel: .error, tag: tag, items, separator: separator, file: file, function: function) | ||
} | ||
|
||
static func a(tag: String? = nil, _ items: Any..., separator: String = " ", file: String = #file, function: String = #function) { | ||
log(logLevel: .assert, tag: tag, items, separator: separator, file: file, function: function) | ||
} | ||
|
||
static private func log(logLevel: LogLevel, tag: String?, _ items: [Any], separator: String, file: String, function: String) { | ||
let message = items.map { "\($0)" }.joined(separator: separator) | ||
shared.log( | ||
priority: logLevel, | ||
tag: tag ?? { | ||
let fileName = URL(fileURLWithPath: file).lastPathComponent | ||
let functionName: String | ||
if let firstBraceIndex = function.firstIndex(of: "(") { | ||
functionName = String(function[..<firstBraceIndex]) | ||
} else { | ||
functionName = function | ||
} | ||
return "\(fileName):\(functionName)" | ||
}(), | ||
throwable: nil, | ||
message_: message | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters