https://github.com/jollyjinx/jlog
Swift logging to Stderr as well as to rotated log file. works on apple and linux platforms.
https://github.com/jollyjinx/jlog
Last synced: 2 months ago
JSON representation
Swift logging to Stderr as well as to rotated log file. works on apple and linux platforms.
- Host: GitHub
- URL: https://github.com/jollyjinx/jlog
- Owner: jollyjinx
- License: mit
- Created: 2021-08-07T17:19:32.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-07-01T09:38:32.000Z (almost 2 years ago)
- Last Synced: 2025-02-08T23:32:55.774Z (3 months ago)
- Language: Swift
- Size: 12.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# JLog - Jollys simple logger for swift
- Logs to __both__ ~/Library/Logs/*programname*/*programname.log* as well as to *stderr*
- Logrotation
- Loglevel can be changedIt uses [swift-log](https://github.com/apple/swift-log) as well as [swift-log-format-and-pipe](https://github.com/Adorkable/swift-log-format-and-pipe)
Example progam in Sources/JLogExample uses [ArgumentParser](https://github.com/apple/swift-argument-parser):
```
import Foundation
import ArgumentParser
import JLogstruct JLogExample: ParsableCommand
{
@Flag(name: .shortAndLong, help: "optional debug output")
var debug: Intmutating func run() throws
{
if debug > 0
{
JLog.loglevel = debug > 1 ? .trace : .debug
}JLog.notice("notice")
JLog.info("info")
JLog.warning("warning")
JLog.error("error")
JLog.debug("debug")
JLog.trace("tracing")
}
}
JLogExample.main()
```For commandline utilities output looks like:
```
tin>swift 'build' -c release [0/0] Build complete!tin>./.build/release/JLogExample
2021-08-07T19:59:11+02:00 ▶ warning ▶ /Users/jolly/Documents/GitHub/JLog/Sources/JLogExample/main.swift:19 ▶ run() ▶ warning
2021-08-07T19:59:11+02:00 ▶ error ▶ /Users/jolly/Documents/GitHub/JLog/Sources/JLogExample/main.swift:20 ▶ run() ▶ errortin>./.build/release/JLogExample -d
2021-08-07T19:59:23+02:00 ▶ notice ▶ /Users/jolly/Documents/GitHub/JLog/Sources/JLogExample/main.swift:17 ▶ run() ▶ notice
2021-08-07T19:59:23+02:00 ▶ info ▶ /Users/jolly/Documents/GitHub/JLog/Sources/JLogExample/main.swift:18 ▶ run() ▶ info
2021-08-07T19:59:23+02:00 ▶ warning ▶ /Users/jolly/Documents/GitHub/JLog/Sources/JLogExample/main.swift:19 ▶ run() ▶ warning
2021-08-07T19:59:23+02:00 ▶ error ▶ /Users/jolly/Documents/GitHub/JLog/Sources/JLogExample/main.swift:20 ▶ run() ▶ error
2021-08-07T19:59:23+02:00 ▶ debug ▶ /Users/jolly/Documents/GitHub/JLog/Sources/JLogExample/main.swift:21 ▶ run() ▶ debugtin>./.build/release/JLogExample -dd
2021-08-07T19:59:36+02:00 ▶ notice ▶ /Users/jolly/Documents/GitHub/JLog/Sources/JLogExample/main.swift:17 ▶ run() ▶ notice
2021-08-07T19:59:36+02:00 ▶ info ▶ /Users/jolly/Documents/GitHub/JLog/Sources/JLogExample/main.swift:18 ▶ run() ▶ info
2021-08-07T19:59:36+02:00 ▶ warning ▶ /Users/jolly/Documents/GitHub/JLog/Sources/JLogExample/main.swift:19 ▶ run() ▶ warning
2021-08-07T19:59:36+02:00 ▶ error ▶ /Users/jolly/Documents/GitHub/JLog/Sources/JLogExample/main.swift:20 ▶ run() ▶ error
2021-08-07T19:59:36+02:00 ▶ debug ▶ /Users/jolly/Documents/GitHub/JLog/Sources/JLogExample/main.swift:21 ▶ run() ▶ debug
2021-08-07T19:59:36+02:00 ▶ trace ▶ /Users/jolly/Documents/GitHub/JLog/Sources/JLogExample/main.swift:22 ▶ run() ▶ tracing
```