diff --git a/APPROBATION.md b/APPROBATION.md
index e962165..b24d574 100644
--- a/APPROBATION.md
+++ b/APPROBATION.md
@@ -1,19 +1,21 @@
-# Approbation Matrix / ConsolePerseusLogger v1.0.0
+# Approbation Matrix / ConsolePerseusLogger v1.0.1
-Approbated feature: Logging to Console on Mac.
+> Approbated feature: Logging to Console on Mac.
+
+> NOTE: To catch all log messages Mac Console should be started first then after a little while the logged app.
## macOS
-| macOS | Version | Result | Details |
-| ----------- | -------- | :-----: | ------- |
-| High Sierra | 10.13.6 | ok | - |
-| Mojave | 10.14.6 | ok | - |
-| Catalina | 10.15.7 | ok | - |
-| Big Sur | 11.7.10 | ok? | First start displayed not all messages, but all next shows all messages |
-| Monterey | 12.7.6 | ok | - |
-| Ventura | 13.6.9 | ok? | First start displayed not all messages, but all next shows all messages |
-| Sonoma | 14.6.1 | ok | - |
-| Sequoia | 15.0 | ok | - |
+| macOS | Version | Result | Details |
+| ----------- | -------- | :----: | ------- |
+| High Sierra | 10.13.6 | ok | - |
+| Mojave | 10.14.6 | ok | - |
+| Catalina | 10.15.7 | ok | - |
+| Big Sur | 11.7.10 | ok | - |
+| Monterey | 12.7.6 | ok | - |
+| Ventura | 13.6.9 | ok | - |
+| Sonoma | 14.6.1 | ok | - |
+| Sequoia | 15.0 | ok | - |
## iOS
@@ -31,14 +33,14 @@ Approbated feature: Logging to Console on Mac.
iOS 12.5.7 |
- |
iPad Air / iOS 12.5.7 |
- ok? |
- First start displayed not all messages, but all next shows all messages |
+ ok |
+ - |
iOS 16.2 |
iPhone SE (3rd gen) |
- |
- ok?? |
- Shows INFO messages not DEBUG |
+ ok |
+ Shows DEBUG messages as INFO |
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f782e20..59c7868 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
Dates in this file meets Gregorian calendar. Date in format YYYY-MM-DD.
+## [1.0.1] - [2024-10-16], Console Output
+
+### Fixed
+
+- Mac Console ignores DEBUG messages if Simulator ([#6](https://github.com/perseusrealdeal/ConsolePerseusLogger/issues/6)).
+
## [1.0.0] - [2024-10-13], Console Output
### Added
diff --git a/Package.swift b/Package.swift
index a95ca5f..765ef1d 100644
--- a/Package.swift
+++ b/Package.swift
@@ -1,7 +1,7 @@
// swift-tools-version:5.7
/* Package.swift
- Version: 1.0.0
+ Version: 1.0.1
Created by Mikhail Zhigulin in 7533.
diff --git a/PerseusLoggerStar.swift b/PerseusLoggerStar.swift
index de4fd5a..8c327d8 100644
--- a/PerseusLoggerStar.swift
+++ b/PerseusLoggerStar.swift
@@ -1,6 +1,6 @@
//
// PerseusLoggerStar.swift
-// Version: 1.0.0
+// Version: 1.0.1
//
// PLATFORMS: macOS 10.12+ | iOS 10.0+
//
@@ -42,6 +42,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
+// swiftlint:disable file_length
+//
import Foundation
import os
@@ -104,7 +106,11 @@ public class PerseusLogger {
public static var short = true
public static var marks = true
- public static var logObject: ConsoleObject? { // Custom Log Object for Console on Mac.
+#if targetEnvironment(simulator)
+ public static var debugIsInfo = true // Shows DEBUG message as INFO in Console on Mac.
+#endif
+
+ public static var logObject: ConsoleObject? {
didSet {
guard let obj = logObject else {
@@ -162,7 +168,15 @@ public class PerseusLogger {
switch type {
case .debug:
+#if targetEnvironment(simulator)
+ if debugIsInfo {
+ logger.info("\(message, privacy: .public)")
+ } else {
+ logger.debug("\(message, privacy: .public)")
+ }
+#else
logger.debug("\(message, privacy: .public)")
+#endif
case .info:
logger.info("\(message, privacy: .public)")
case .notice:
@@ -180,7 +194,15 @@ public class PerseusLogger {
switch type {
case .debug:
+#if targetEnvironment(simulator)
+ if debugIsInfo {
+ os_log("%{public}@", log: consoleLog, type: .info, message)
+ } else {
+ os_log("%{public}@", log: consoleLog, type: .debug, message)
+ }
+#else
os_log("%{public}@", log: consoleLog, type: .debug, message)
+#endif
case .info:
os_log("%{public}@", log: consoleLog, type: .info, message)
case .notice:
diff --git a/README.md b/README.md
index 50de1e4..6822501 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
[![Actions Status](https://github.com/perseusrealdeal/ConsolePerseusLogger/actions/workflows/main.yml/badge.svg)](https://github.com/perseusrealdeal/ConsolePerseusLogger/actions/workflows/main.yml)
[![Style](https://github.com/perseusrealdeal/ConsolePerseusLogger/actions/workflows/swiftlint.yml/badge.svg)](https://github.com/perseusrealdeal/ConsolePerseusLogger/actions/workflows/swiftlint.yml)
-[![Version](https://img.shields.io/badge/Version-1.0.0-green.svg)](/CHANGELOG.md)
+[![Version](https://img.shields.io/badge/Version-1.0.1-green.svg)](/CHANGELOG.md)
[![Platforms](https://img.shields.io/badge/Platforms-macOS%2010.13+_|_iOS%2011.0+-orange.svg)](https://en.wikipedia.org/wiki/List_of_Apple_products)
[![Xcode 14.2](https://img.shields.io/badge/Xcode-14.2+-red.svg)](https://en.wikipedia.org/wiki/Xcode)
[![Swift 5.7](https://img.shields.io/badge/Swift-5.7-red.svg)](https://www.swift.org)
@@ -15,6 +15,10 @@
[![Standalone](https://img.shields.io/badge/Standalone%20-available-informational.svg)](/PerseusLoggerStar.swift)
[![Swift Package Manager compatible](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-4BC51D.svg)](/Package.swift)
+## Approbation Matrix
+
+> [A3 Environment](https://docs.google.com/document/d/1K2jOeIknKRRpTEEIPKhxO2H_1eBTof5uTXxyOm5g6nQ/edit?usp=sharing) / [Approbation Results](/APPROBATION.md) / [CHANGELOG](/CHANGELOG.md) for details.
+
## In brief > Idea to use, the Why
> USE LOGGER LIKE A VARIABLE ANYWHERE YOU WANT.
@@ -29,26 +33,30 @@ log.message("[\(type(of: self))].\(#function)")
```
-| Types | Message default | Level default | Purpose |
-| :------ | :-------------: | :-----------: | :------------------------------------ |
-| DEBUG | Default | | Debugging only |
-| INFO | | | Helpful, but not essential |
-| NOTICE | | Default | Might result in a failure |
-| ERROR | | | Errors seen during the code execution |
-| FAULT | | | Faults and bugs in the code |
+| Level | Message | Default Message | Default Level | Purpose |
+| :---: | :------ | :-------------: | :-----------: | :------------------------------------ |
+| 5 | DEBUG | Default | | Debugging only |
+| 4 | INFO | | | Helpful, but not essential |
+| 3 | NOTICE | | Default | Might result in a failure |
+| 2 | ERROR | | | Errors seen during the code execution |
+| 1 | FAULT | | | Faults and bugs in the code |
# Manual
## Setting the Logger for Work
> Options used by default are different and depends on DEBUG/RELEASE if do not set explicitly.
-| Options | Default in DEBUG | Default in RELEASE | Description |
-| :------ | :--------------: | :----------------: | :----------------------------------------------------- |
-| tuned | .on | .off | If .off no matter what level no message will be passed |
-| output | .xcodedebug | .consoleapp | Message output target |
-| level | .notice | .notice | No messages on any level above |
-| short | true | true | If false a message goes with file name and line number |
-| marks | true | true | [LOG] [DEBUG] Message text |
+| Options | Default in DEBUG | Default in RELEASE | Description |
+| :---------- | :--------------: | :----------------: | :----------------------------------------------------- |
+| tuned | .on | .off | If .off no matter what level no message will be passed |
+| output | .xcodedebug | .consoleapp | Message output target |
+| level | .notice | .notice | No any messages on any level above |
+| short | true | true | FALSE: Message goes with file name and line number |
+| marks | true | true | FALSE: Message text, TRUE: [LOG] [DEBUG] Message text |
+| logObject | nil | nil | Mac Console Subsystem and Category values group |
+| debugIsInfo | true | true | Only if Simulator. TRUE: DEBUG is INFO with DEBUG text |
+
+> NOTE: If logObject is nil Console Perseus Logger uses default values for Subsystem "Perseus" and Category "Logger" accordingly.
```ruby
@@ -58,20 +66,15 @@ log.message("[\(type(of: self))].\(#function)")
import ConsolePerseusLogger
-// MARK: - Logger
-
-log.level = .debug
-log.message("The app's start point...", .info)
-
-```
-
-### Subsystem and Category Logging
+// MARK: - Log to Mac Console
-> By default values for Subsystem and Category are "Perseus" and "Logger".
+log.logObject = ("MyApp", "MyLogger") // Subsystem and Category.
-```ruby
+log.output = .consoleapp
+log.turned = .on
-log.logObject = ("MyApp", "MyLogger")
+log.level = .debug
+log.message("The app's start point...", .info)
```
@@ -103,9 +106,21 @@ log.message("The app's start point...", .info)
```
-## Approbation Matrix
+### Console on Mac and Simulator
-> [A3 Environment](https://docs.google.com/document/d/1K2jOeIknKRRpTEEIPKhxO2H_1eBTof5uTXxyOm5g6nQ/edit?usp=sharing) / [Approbation Results](/APPROBATION.md) / [CHANGELOG](/CHANGELOG.md) for details.
+> Just a matter of fact that Console on Mac doesn't show any DEBUG message from any app running on Simulator ("Include Debug Messages" tapped).
+
+> Console Perseus Logger running on Simulator doesn't pass DEBUG message, instead it passes INFO message with text of DEBUG message, so, a passed message being INFO looks like a DEBUG and it works perfactly well.
+
+> If for some reasons Simulator must pass DEBUG like a DEBUG message there is an option exists (it's true by default if Simulator):
+
+```ruby
+
+#if targetEnvironment(simulator)
+ log.debugIsInfo = false // Use Case: Mac Console in use to redirect logs to file on disk.
+#endif
+
+```
## Build system requirements
diff --git a/Sources/ConsolePerseusLogger/PerseusLogger.swift b/Sources/ConsolePerseusLogger/PerseusLogger.swift
index d72f711..39b6a04 100644
--- a/Sources/ConsolePerseusLogger/PerseusLogger.swift
+++ b/Sources/ConsolePerseusLogger/PerseusLogger.swift
@@ -75,7 +75,11 @@ public class PerseusLogger {
public static var short = true
public static var marks = true
- public static var logObject: ConsoleObject? { // Custom Log Object for Console on Mac.
+#if targetEnvironment(simulator)
+ public static var debugIsInfo = true // Shows DEBUG message as INFO in Console on Mac.
+#endif
+
+ public static var logObject: ConsoleObject? {
didSet {
guard let obj = logObject else {
@@ -133,7 +137,15 @@ public class PerseusLogger {
switch type {
case .debug:
+#if targetEnvironment(simulator)
+ if debugIsInfo {
+ logger.info("\(message, privacy: .public)")
+ } else {
+ logger.debug("\(message, privacy: .public)")
+ }
+#else
logger.debug("\(message, privacy: .public)")
+#endif
case .info:
logger.info("\(message, privacy: .public)")
case .notice:
@@ -151,7 +163,15 @@ public class PerseusLogger {
switch type {
case .debug:
+#if targetEnvironment(simulator)
+ if debugIsInfo {
+ os_log("%{public}@", log: consoleLog, type: .info, message)
+ } else {
+ os_log("%{public}@", log: consoleLog, type: .debug, message)
+ }
+#else
os_log("%{public}@", log: consoleLog, type: .debug, message)
+#endif
case .info:
os_log("%{public}@", log: consoleLog, type: .info, message)
case .notice: