Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nakkht/logr
Dead simple logging library for iOS
https://github.com/nakkht/logr
ios ioslogging log logging macos spm swift swift-5-1 swift-5-3 swift-framework swift5 tvos watchos
Last synced: 5 days ago
JSON representation
Dead simple logging library for iOS
- Host: GitHub
- URL: https://github.com/nakkht/logr
- Owner: nakkht
- License: apache-2.0
- Created: 2019-06-28T19:53:21.000Z (over 5 years ago)
- Default Branch: develop
- Last Pushed: 2022-07-09T19:05:37.000Z (over 2 years ago)
- Last Synced: 2024-11-30T21:22:14.714Z (24 days ago)
- Topics: ios, ioslogging, log, logging, macos, spm, swift, swift-5-1, swift-5-3, swift-framework, swift5, tvos, watchos
- Language: Swift
- Homepage: https://nakkht.github.io/logr/
- Size: 1.54 MB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Logr
[![build](https://github.com/nakkht/logr/actions/workflows/build.yml/badge.svg)](https://github.com/nakkht/logr/actions/workflows/build.yml)
[![unit test](https://github.com/nakkht/logr/actions/workflows/unit-test.yml/badge.svg)](https://github.com/nakkht/logr/actions/workflows/unit-test.yml)
![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS-brightgreen)
[![codecov](https://codecov.io/gh/nakkht/logr/branch/develop/graph/badge.svg)](https://codecov.io/gh/nakkht/logr)
![code size](https://img.shields.io/github/languages/code-size/nakkht/logr?color=brightgreen)
[![documentation](https://img.shields.io/badge/doc-reference-brightgreen)](https://nakkht.github.io/logr/)Simple logging library for iOS written in Swift
## Features
- [x] Inferred log message tags
- [x] Swift Package Manager/Carthage/CocoaPods integration
- [x] Highly extensible
- [x] Logging to multiple targets/destination at the same time
- [x] Console logging out of the box via ConsoleTarget
- [x] File logging out of the box via FileTarget
- [x] Pure Swift 5
- [x] Optional file header for each file
- [x] Automatic file archive based on size or time span## Integration
### Swift Package Manager
Once Swift package set up, add the following to your `Package.swift`:
```
dependencies: [
.package(url: "https://github.com/nakkht/logr.git", exact: "0.11.0")
]
```## Usage
In your `AppDelegate.swift` file add:
```swift
import Logr
```At the beginning of `func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool` configure logr service with wanted targets:
```swift
LogrService.init(with: Config(ConsoleTarget(), FileTarget()))
```For more serious configuration in production, it is recommended to ommit `ConsoleTarget`. For example:
```swift
#if DEBUG
static let targets: [Target] = [ConsoleTarget(), FileTarget()]
#else
static let targets: [Target] = [FileTarget()]
#endifstatic let config = Config(targets: targets)
LogrService.init(with: config)
```The set targets will be used across the whole application.
To log messages, simply create `Logr` instance in class initializer and start logging. For example:
```swift
import Logrclass ViewController: UIViewController {
private let logr = Logr()
func logDebug() {
logr.debug("debug message to be logged")
}
}
```## Demo
Demo project can be access by opening Demo.workspace in Demo sub-folder.
## Documentation
- [Documentation](https://nakkht.github.io/logr/) generated with [jazzy](https://github.com/realm/jazzy). Hosted by [GitHub Pages](https://pages.github.com).
- [Architecture document](https://github.com/nakkht/logr/wiki/Architecture) available in project wiki## Author
* [Paulius Gudonis](https://pgu.dev)## Licence
This repository is under the **Apache v2.0** license. [Find it here](https://github.com/nakkht/logr/blob/main/LICENSE).Copyright 2021 Paulius Gudonis
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.