Skip to content

Commit

Permalink
Merge pull request #26 from orchetect/dev
Browse files Browse the repository at this point in the history
Renamed `Logger` to `OSLogger`
  • Loading branch information
orchetect authored Dec 2, 2021
2 parents b4b2fcc + bc8612f commit 45eb077
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Log.swift
// OSLogger.swift
// OTCore • https://github.com/orchetect/OTCore
//

Expand All @@ -24,13 +24,13 @@ import os.log
//
// Then you can log to it easily:
//
// Log("test", log: .log2)
// logger.debug("test", log: .log2)
//
// ------------------------------------------------------------------------
// Suggestion:
// It's possible to emit emoji in log messages only for debug builds easily, to make errors stand out more.
//
// let log = Logger()
// let log = OSLogger()
//
// #if RELEASE
// log.useEmoji = .disabled
Expand All @@ -40,12 +40,12 @@ import os.log
//
// ------------------------------------------------------------------------

// MARK: - Logger
// MARK: - OSLogger

/// **OTCore:**
/// Centralized logging via os_log.
@available(macOS 10.12, iOS 10.0, watchOS 3.0, tvOS 10.0, *)
open class Logger {
open class OSLogger {

/// **OTCore:**
/// Set to `false` to suppress all logging.
Expand Down Expand Up @@ -89,7 +89,7 @@ open class Logger {
public var levelFaultEmoji: Character = "🛑"

/// **OTCore:**
/// Initialize a new Logger instance.
/// Initialize a new `OSLogger` instance.
public init(enabled: Bool = true,
defaultLog: OSLog = .default,
useEmoji: EmojiType = .disabled) {
Expand Down Expand Up @@ -292,7 +292,7 @@ open class Logger {
/// **OTCore:**
/// Log an error using the passed log message type.
///
/// - note: Where possible, use direct `Logger` instance methods instead (ie: `.debug(...)`, `.error(...), etc.`), as it will typically be more performant.
/// - note: Where possible, use direct `OSLogger` instance methods instead (ie: `.debug(...)`, `.error(...), etc.`), as it will typically be more performant.
@inline(__always)
open func log(_ items: Any?...,
level: OSLogType,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Log Tests.swift
// OSLogger Tests.swift
// OTCore • https://github.com/orchetect/OTCore
//

Expand All @@ -21,8 +21,8 @@ class Logging_Log_Tests: XCTestCase {

print("---------- default log, no emojis ----------")

let logger = Logger(enabled: true,
useEmoji: .disabled)
let logger = OSLogger(enabled: true,
useEmoji: .disabled)

logger.debug ("Test log.debug()" , 123)
logger.info ("Test log.info()" , 123)
Expand All @@ -38,8 +38,8 @@ class Logging_Log_Tests: XCTestCase {

print("---------- default log, only error emojis ----------")

let logger = Logger(enabled: true,
useEmoji: .errorsOnly)
let logger = OSLogger(enabled: true,
useEmoji: .errorsOnly)

logger.debug ("Test log.debug()" , 123)
logger.info ("Test log.info()" , 123)
Expand All @@ -55,8 +55,8 @@ class Logging_Log_Tests: XCTestCase {

print("---------- default log, all emojis ----------")

let logger = Logger(enabled: true,
useEmoji: .all)
let logger = OSLogger(enabled: true,
useEmoji: .all)

logger.debug ("Test log.debug()" , 123)
logger.info ("Test log.info()" , 123)
Expand All @@ -72,9 +72,9 @@ class Logging_Log_Tests: XCTestCase {

print("---------- custom log, all emojis ----------")

let logger = Logger(enabled: true,
defaultLog: .loggerTestLog, // <-- custom log
useEmoji: .all)
let logger = OSLogger(enabled: true,
defaultLog: .loggerTestLog, // <-- custom log
useEmoji: .all)

logger.debug ("Test log.debug()" , 123)
logger.info ("Test log.info()" , 123)
Expand All @@ -93,8 +93,8 @@ class Logging_Log_Tests: XCTestCase {

print("---------- default log, OSLogType.x.log(), all emojis ----------")

let logger = Logger(enabled: true,
useEmoji: .all)
let logger = OSLogger(enabled: true,
useEmoji: .all)

logger.log("Test log(... , level: .debug)" , 123, level: .debug)
logger.log("Test log(... , level: .info)" , 123, level: .info)
Expand Down

0 comments on commit 45eb077

Please sign in to comment.