Light-weight logger in Swift. Hereinafter
CPL
stands forConsole Perseus Logger
.
A3 Environment / Approbation Results / CHANGELOG for details.
USE LOGGER LIKE A VARIABLE ANYWHERE YOU WANT.
import ConsolePerseusLogger
log.message("[\(type(of: self))].\(#function)")
Level | Message Type | Purpose |
---|---|---|
5 | DEBUG | Debugging only |
4 | INFO | Helpful, but not essential |
3 | NOTICE | Might result in a failure |
2 | ERROR | Errors seen during the code execution |
1 | FAULT | Faults and bugs in the code |
Options used by default are different and depend on DEBUG/RELEASE.
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 | .debug | .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 CPL uses default values for Subsystem "Perseus" and Category "Logger" accordingly.
//
// main.swift
//
import ConsolePerseusLogger
// MARK: - Log to Mac Console
log.logObject = ("MyApp", "MyLogger") // Subsystem and Category.
log.output = .consoleapp
log.turned = .on
log.level = .debug
log.message("The app's start point...", .info)
In case if CPL used as a standalone file in submodule (package).
//
// main.swift
//
import ConsolePerseusLogger
import class SubmoduleA.PerseusLogger
import class SubmoduleB.PerseusLogger
typealias sublogA = SubmoduleA.PerseusLogger
typealias sublogB = SubmoduleB.PerseusLogger
// MARK: - Subloggers
sublogA.turned = .off
sublogB.turned = .off
// MARK: - Logger
log.level = .debug
log.message("The app's start point...", .info)
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):
#if targetEnvironment(simulator)
log.debugIsInfo = false // Use Case: Mac Console in use to redirect logs to file on disk.
#endif
- Style SwiftLint / Shell Script
- Action mxcl/[email protected]
- Action cirruslabs/swiftlint-action@v1
- Preconfigured Swift Package manifest Package.swift
- Preconfigured SwiftLint config .swiftlint.yml
- Preconfigured SwiftLint CI swiftlint.yml
- Preconfigured GitHub config .gitignore
- Preconfigured GitHub CI main.yml
Copyright © 7531 - 7533 Mikhail A. Zhigulin of Novosibirsk
Copyright © 7531 - 7533 PerseusRealDeal
- The year starts from the creation of the world according to a Slavic calendar.
- September, the 1st of Slavic year. It means that "Sep 01, 2024" is the beginning of 7533.
LICENSE for details.
Balance and Control | kept by | Mikhail A. Zhigulin |
Source Code | written by | Mikhail A. Zhigulin |
Documentation | prepared by | Mikhail A. Zhigulin |
Product Approbation | tested by | Mikhail A. Zhigulin |
Mikhail A. Zhigulin of Novosibirsk.