Skip to content

Commit

Permalink
v1.0.1 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
perseusrealdeal authored Oct 16, 2024
1 parent 7d4b100 commit 94dca62
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 48 deletions.
34 changes: 18 additions & 16 deletions APPROBATION.md
Original file line number Diff line number Diff line change
@@ -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.<br/>
> 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

Expand All @@ -31,14 +33,14 @@ Approbated feature: Logging to Console on Mac.
<td nowrap>iOS 12.5.7</td>
<td>-</td>
<td nowrap>iPad Air / iOS 12.5.7</td>
<td>ok?</td>
<td>First start displayed not all messages, but all next shows all messages</td>
<td>ok</td>
<td>-</td>
</tr>
<tr>
<td nowrap>iOS 16.2</td>
<td nowrap>iPhone SE (3rd gen)</td>
<td>-</td>
<td>ok??</td>
<td>Shows INFO messages not DEBUG</td>
<td>ok</td>
<td>Shows DEBUG messages as INFO</td>
</tr>
</table>
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
26 changes: 24 additions & 2 deletions PerseusLoggerStar.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// PerseusLoggerStar.swift
// Version: 1.0.0
// Version: 1.0.1
//
// PLATFORMS: macOS 10.12+ | iOS 10.0+
//
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down
71 changes: 43 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.<br/>
Expand All @@ -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

Expand All @@ -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)

```

Expand Down Expand Up @@ -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).<br/>
> 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.<br/>
> 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

Expand Down
22 changes: 21 additions & 1 deletion Sources/ConsolePerseusLogger/PerseusLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 94dca62

Please sign in to comment.