https://github.com/frazer-rbsn/log.swift
A simple logging class in Swift, with an API based on Android's Log.
https://github.com/frazer-rbsn/log.swift
console ios logger logging macos swift
Last synced: about 1 month ago
JSON representation
A simple logging class in Swift, with an API based on Android's Log.
- Host: GitHub
- URL: https://github.com/frazer-rbsn/log.swift
- Owner: frazer-rbsn
- License: gpl-3.0
- Created: 2018-06-16T12:20:46.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-03-14T18:33:49.000Z (over 5 years ago)
- Last Synced: 2023-09-01T15:29:03.136Z (almost 3 years ago)
- Topics: console, ios, logger, logging, macos, swift
- Language: Swift
- Homepage:
- Size: 56.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Log.swift
[](https://travis-ci.org/frazer-rbsn/Log.swift)
`Log.swift` is a simple logging class with an API based on Android's `Log`. It is not a fully-featured logging framework, instead it is intended as a basic, useful replacement for `print()` statements to use when debugging your projects.
* easy configuration
* prints file name, line number, function name
* prints current thread (optional)
* simple timestamps (optional)
* symbol (optional)
* output to log file -- please set `logFileLocation` and `shouldLogToFile` to `true`
* can output using `print()` or `os_log()` (macOS 10.12 or newer only)
#### How to use:
Log has static log functions that use a private static instance, so you don't need to instantiate a `Log` object to use it, but you can if you wish.
```swift
Log.e("A really bad thing happened!")
```
outputs:
```
14:19:30 [ERROR] Foo.swift 67 buggyFunction(): A really bad thing happened!
```
Likewise:
```swift
let eventLogger = Log(identifier: "system")
eventLogger.e("A really bad thing happened!")
```
outputs:
```
14:19:30 [ERROR] Foo.swift 67 buggyFunction(): A really bad thing happened!
```
#### Log levels:
```swift
Log.v() // [VERBOSE]
Log.d() // [DEBUG]
Log.i() // [INFO]
Log.w() // [WARNING]
Log.e() // [ERROR]
Log.f() // [FATAL] (Calls fatalError() to crash the application/service.)
```