Skip to content

Commit b9dbff4

Browse files
committed
CoreModule 2.7.
1 parent a8f9514 commit b9dbff4

3 files changed

Lines changed: 36 additions & 25 deletions

File tree

Source/Logger/Logger+Extension.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ extension Logger {
5151
guard isDevelopment() else { return }
5252
let text = "Sending \(type(of: object)) = \(object) to the \(modelStreamName) model stream."
5353

54-
log(text, level: .info, file: file, function: function, line: line)
54+
log(text, level: .info)
5555
}
5656

5757
public func logReceiving<T>(_ object: T,
@@ -62,7 +62,7 @@ extension Logger {
6262
guard isDevelopment() else { return }
6363
let text = "Received \(type(of: object)) = \(object) from the \(modelStreamName) model stream."
6464

65-
log(text, level: .info, file: file, function: function, line: line)
65+
log(text, level: .info)
6666
}
6767

6868
public func log(installedFeatureName: String) {

Source/Logger/LoggerImpl.swift

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,27 @@
55
// Created by Maxim Ivanov on 24.03.2023.
66
//
77

8-
import os
8+
import Foundation
99

1010
public final class LoggerImpl: CoreModule.Logger {
1111

12-
private let logger: os.Logger
12+
private let category: String
13+
14+
private lazy var dateformat = {
15+
let dateformat = DateFormatter()
16+
17+
dateformat.dateFormat = "yyyy-MM-dd HH:mm:ss.SSS"
18+
19+
return dateformat
20+
}()
1321

1422
public init(category: String) {
15-
logger = os.Logger(subsystem: "General", category: category)
23+
self.category = category
1624
}
1725

1826
public func log(_ message: String, level: LogLevel) {
1927
guard isDevelopment() else { return }
2028

21-
logger.log(level: level.getOsLogLevel(), "[\(level.rawValue)] \(message)")
22-
}
23-
}
24-
25-
extension LogLevel {
26-
27-
func getOsLogLevel() -> OSLogType {
28-
switch self {
29-
case .debug:
30-
return .debug
31-
32-
case .info:
33-
return .default
34-
35-
case .warn:
36-
return .error
37-
38-
case .error:
39-
return .fault
40-
}
29+
print("\(dateformat.string(from: Date())) [\(level.rawValue)] [\(category)] \(message)")
4130
}
4231
}

Source/WrappedOptional.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// WrappedOptional.swift
3+
// CoreModule
4+
//
5+
// Created by Maxim Ivanov on 27.06.2024.
6+
//
7+
8+
/// Generic wrapper for optional value.
9+
public struct WrappedOptional<T: Equatable>: Equatable, CustomStringConvertible {
10+
11+
public var value: T?
12+
13+
public init(value: T? = nil) {
14+
self.value = value
15+
}
16+
17+
public var description: String {
18+
guard let value else { return "nil" }
19+
20+
return "\(value)"
21+
}
22+
}

0 commit comments

Comments
 (0)