|
|
@ -9,7 +9,8 @@ import SignalCoreKit
|
|
|
|
public enum LibSession {
|
|
|
|
public enum LibSession {
|
|
|
|
private static let logLevels: [LogCategory: LOG_LEVEL] = [
|
|
|
|
private static let logLevels: [LogCategory: LOG_LEVEL] = [
|
|
|
|
.config: LOG_LEVEL_INFO,
|
|
|
|
.config: LOG_LEVEL_INFO,
|
|
|
|
.network: LOG_LEVEL_INFO
|
|
|
|
.network: LOG_LEVEL_INFO,
|
|
|
|
|
|
|
|
.manual: LOG_LEVEL_INFO,
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
public static var version: String { String(cString: LIBSESSION_UTIL_VERSION_STR) }
|
|
|
|
public static var version: String { String(cString: LIBSESSION_UTIL_VERSION_STR) }
|
|
|
@ -19,15 +20,15 @@ public enum LibSession {
|
|
|
|
|
|
|
|
|
|
|
|
extension LibSession {
|
|
|
|
extension LibSession {
|
|
|
|
public static func addLogger() {
|
|
|
|
public static func addLogger() {
|
|
|
|
// Set the default log level first (in case something has a warning or error)
|
|
|
|
/// Set the default log level first (unless specified we only care about semi-dangerous logs)
|
|
|
|
session_logger_set_level_default(LOG_LEVEL_WARN)
|
|
|
|
session_logger_set_level_default(LOG_LEVEL_WARN)
|
|
|
|
|
|
|
|
|
|
|
|
// Then set any explicit category log levels we have
|
|
|
|
/// Then set any explicit category log levels we have
|
|
|
|
logLevels.forEach { cat, level in
|
|
|
|
logLevels.forEach { cat, level in
|
|
|
|
session_logger_set_level(cat.rawValue.cArray, level)
|
|
|
|
session_logger_set_level(cat.rawValue.cArray, level)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Finally register the actual logger callback
|
|
|
|
/// Finally register the actual logger callback
|
|
|
|
session_add_logger_full({ msgPtr, msgLen, _, _, lvl in
|
|
|
|
session_add_logger_full({ msgPtr, msgLen, _, _, lvl in
|
|
|
|
guard let msg: String = String(pointer: msgPtr, length: msgLen, encoding: .utf8) else { return }
|
|
|
|
guard let msg: String = String(pointer: msgPtr, length: msgLen, encoding: .utf8) else { return }
|
|
|
|
|
|
|
|
|
|
|
@ -56,6 +57,7 @@ extension LibSession {
|
|
|
|
case config
|
|
|
|
case config
|
|
|
|
case network
|
|
|
|
case network
|
|
|
|
case quic
|
|
|
|
case quic
|
|
|
|
|
|
|
|
case manual
|
|
|
|
|
|
|
|
|
|
|
|
init?(_ catPtr: UnsafePointer<CChar>?, _ catLen: Int) {
|
|
|
|
init?(_ catPtr: UnsafePointer<CChar>?, _ catLen: Int) {
|
|
|
|
switch String(pointer: catPtr, length: catLen, encoding: .utf8).map({ LogCategory(rawValue: $0) }) {
|
|
|
|
switch String(pointer: catPtr, length: catLen, encoding: .utf8).map({ LogCategory(rawValue: $0) }) {
|
|
|
|