|
1 | 1 | import Foundation |
2 | 2 |
|
3 | | -@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) |
4 | | -public func fatal(_ message: String, category: String? = nil, privacy: PrettyLoggerPrivacy = .auto) { |
5 | | - PrettyLogger.shared.fatal(message, category: category, privacy: privacy) |
| 3 | +// MARK: - Primary OSLog-based API |
| 4 | + |
| 5 | +public func logFatal(_ message: String, category: String? = nil, privacy: PrettyLoggerPrivacy = .auto) { |
| 6 | + PrettyLogger.shared.logFatal(message, category: category, privacy: privacy) |
6 | 7 | } |
7 | 8 |
|
8 | | -@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) |
9 | | -public func error(_ message: String, category: String? = nil, privacy: PrettyLoggerPrivacy = .auto) { |
10 | | - PrettyLogger.shared.error(message, category: category, privacy: privacy) |
| 9 | +public func logError(_ message: String, category: String? = nil, privacy: PrettyLoggerPrivacy = .auto) { |
| 10 | + PrettyLogger.shared.logError(message, category: category, privacy: privacy) |
11 | 11 | } |
12 | 12 |
|
13 | | -@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) |
14 | | -public func warning(_ message: String, category: String? = nil, privacy: PrettyLoggerPrivacy = .auto) { |
15 | | - PrettyLogger.shared.warning(message, category: category, privacy: privacy) |
| 13 | +public func logWarning(_ message: String, category: String? = nil, privacy: PrettyLoggerPrivacy = .auto) { |
| 14 | + PrettyLogger.shared.logWarning(message, category: category, privacy: privacy) |
16 | 15 | } |
17 | 16 |
|
18 | | -@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) |
19 | | -public func info(_ message: String, category: String? = nil, privacy: PrettyLoggerPrivacy = .auto) { |
20 | | - PrettyLogger.shared.info(message, category: category, privacy: privacy) |
| 17 | +public func logInfo(_ message: String, category: String? = nil, privacy: PrettyLoggerPrivacy = .auto) { |
| 18 | + PrettyLogger.shared.logInfo(message, category: category, privacy: privacy) |
21 | 19 | } |
22 | 20 |
|
23 | | -@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) |
24 | | -public func debug(_ message: String, category: String? = nil, privacy: PrettyLoggerPrivacy = .auto) { |
25 | | - PrettyLogger.shared.debug(message, category: category, privacy: privacy) |
| 21 | +public func logDebug(_ message: String, category: String? = nil, privacy: PrettyLoggerPrivacy = .auto) { |
| 22 | + PrettyLogger.shared.logDebug(message, category: category, privacy: privacy) |
26 | 23 | } |
27 | 24 |
|
28 | | -@available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) |
29 | | -public func trace(_ message: String, category: String? = nil, privacy: PrettyLoggerPrivacy = .auto) { |
30 | | - PrettyLogger.shared.trace(message, category: category, privacy: privacy) |
| 25 | +public func logTrace(_ message: String, category: String? = nil, privacy: PrettyLoggerPrivacy = .auto) { |
| 26 | + PrettyLogger.shared.logTrace(message, category: category, privacy: privacy) |
31 | 27 | } |
32 | 28 |
|
33 | | -// MARK: - Deprecations |
| 29 | +// MARK: - Legacy print-based API (deprecated) |
34 | 30 |
|
35 | | -@available(*, deprecated, renamed: "fatal", message: "Use `fatal` to use the unified OS logger") |
| 31 | +@available(*, deprecated, message: "Use logFatal(_ message: String, category: String?, privacy: PrettyLoggerPrivacy) instead") |
36 | 32 | @discardableResult |
37 | | -public func logFatal(_ items: Any..., separator: String? = nil, terminator: String? = nil, file: String = #file, line: Int = #line, column: Int = #column, function: String = #function) -> String? { |
38 | | - return PrettyLogger.shared.logFatal(items, separator: separator, terminator: terminator, file: file, line: line, column: column, function: function) |
| 33 | +public func logFatal( |
| 34 | + _ items: Any..., separator: String? = nil, terminator: String? = nil, file: String = #file, |
| 35 | + line: Int = #line, column: Int = #column, function: String = #function |
| 36 | +) -> String? { |
| 37 | + return PrettyLogger.shared.logFatalLegacy( |
| 38 | + items, separator: separator, terminator: terminator, file: file, line: line, column: column, |
| 39 | + function: function) |
39 | 40 | } |
40 | 41 |
|
41 | | -@available(*, deprecated, renamed: "error", message: "Use `error` to use the unified OS logger") |
| 42 | +@available(*, deprecated, message: "Use logError(_ message: String, category: String?, privacy: PrettyLoggerPrivacy) instead") |
42 | 43 | @discardableResult |
43 | | -public func logError(_ items: Any..., separator: String? = nil, terminator: String? = nil, file: String = #file, line: Int = #line, column: Int = #column, function: String = #function) -> String? { |
44 | | - return PrettyLogger.shared.logError(items, separator: separator, terminator: terminator, file: file, line: line, column: column, function: function) |
| 44 | +public func logError( |
| 45 | + _ items: Any..., separator: String? = nil, terminator: String? = nil, file: String = #file, |
| 46 | + line: Int = #line, column: Int = #column, function: String = #function |
| 47 | +) -> String? { |
| 48 | + return PrettyLogger.shared.logErrorLegacy( |
| 49 | + items, separator: separator, terminator: terminator, file: file, line: line, column: column, |
| 50 | + function: function) |
45 | 51 | } |
46 | 52 |
|
47 | | -@available(*, deprecated, renamed: "warning", message: "Use `warning` to use the unified OS logger") |
| 53 | +@available(*, deprecated, message: "Use logWarning(_ message: String, category: String?, privacy: PrettyLoggerPrivacy) instead") |
48 | 54 | @discardableResult |
49 | | -public func logWarning(_ items: Any..., separator: String? = nil, terminator: String? = nil, file: String = #file, line: Int = #line, column: Int = #column, function: String = #function) -> String? { |
50 | | - return PrettyLogger.shared.logWarning(items, separator: separator, terminator: terminator, file: file, line: line, column: column, function: function) |
| 55 | +public func logWarning( |
| 56 | + _ items: Any..., separator: String? = nil, terminator: String? = nil, file: String = #file, |
| 57 | + line: Int = #line, column: Int = #column, function: String = #function |
| 58 | +) -> String? { |
| 59 | + return PrettyLogger.shared.logWarningLegacy( |
| 60 | + items, separator: separator, terminator: terminator, file: file, line: line, column: column, |
| 61 | + function: function) |
51 | 62 | } |
52 | 63 |
|
53 | | -@available(*, deprecated, renamed: "info", message: "Use `info` to use the unified OS logger") |
| 64 | +@available(*, deprecated, message: "Use logInfo(_ message: String, category: String?, privacy: PrettyLoggerPrivacy) instead") |
54 | 65 | @discardableResult |
55 | | -public func logInfo(_ items: Any..., separator: String? = nil, terminator: String? = nil, file: String = #file, line: Int = #line, column: Int = #column, function: String = #function) -> String? { |
56 | | - return PrettyLogger.shared.logInfo(items, separator: separator, terminator: terminator, file: file, line: line, column: column, function: function) |
| 66 | +public func logInfo( |
| 67 | + _ items: Any..., separator: String? = nil, terminator: String? = nil, file: String = #file, |
| 68 | + line: Int = #line, column: Int = #column, function: String = #function |
| 69 | +) -> String? { |
| 70 | + return PrettyLogger.shared.logInfoLegacy( |
| 71 | + items, separator: separator, terminator: terminator, file: file, line: line, column: column, |
| 72 | + function: function) |
57 | 73 | } |
58 | 74 |
|
59 | | -@available(*, deprecated, renamed: "debug", message: "Use `debug` to use the unified OS logger") |
| 75 | +@available(*, deprecated, message: "Use logDebug(_ message: String, category: String?, privacy: PrettyLoggerPrivacy) instead") |
60 | 76 | @discardableResult |
61 | | -public func logDebug(_ items: Any..., separator: String? = nil, terminator: String? = nil, file: String = #file, line: Int = #line, column: Int = #column, function: String = #function) -> String? { |
62 | | - return PrettyLogger.shared.logDebug(items, separator: separator, terminator: terminator, file: file, line: line, column: column, function: function) |
| 77 | +public func logDebug( |
| 78 | + _ items: Any..., separator: String? = nil, terminator: String? = nil, file: String = #file, |
| 79 | + line: Int = #line, column: Int = #column, function: String = #function |
| 80 | +) -> String? { |
| 81 | + return PrettyLogger.shared.logDebugLegacy( |
| 82 | + items, separator: separator, terminator: terminator, file: file, line: line, column: column, |
| 83 | + function: function) |
63 | 84 | } |
64 | 85 |
|
65 | | -@available(*, deprecated, renamed: "trace", message: "Use `trace` to use the unified OS logger") |
| 86 | +@available(*, deprecated, message: "Use logTrace(_ message: String, category: String?, privacy: PrettyLoggerPrivacy) instead") |
66 | 87 | @discardableResult |
67 | | -public func logTrace(_ items: Any..., separator: String? = nil, terminator: String? = nil, file: String = #file, line: Int = #line, column: Int = #column, function: String = #function) -> String? { |
68 | | - return PrettyLogger.shared.logTrace(items, separator: separator, terminator: terminator, file: file, line: line, column: column, function: function) |
| 88 | +public func logTrace( |
| 89 | + _ items: Any..., separator: String? = nil, terminator: String? = nil, file: String = #file, |
| 90 | + line: Int = #line, column: Int = #column, function: String = #function |
| 91 | +) -> String? { |
| 92 | + return PrettyLogger.shared.logTraceLegacy( |
| 93 | + items, separator: separator, terminator: terminator, file: file, line: line, column: column, |
| 94 | + function: function) |
69 | 95 | } |
0 commit comments