https://github.com/ngtk/loggerkit
🤖Simple logging framework
https://github.com/ngtk/loggerkit
ios logger logging swift
Last synced: 8 months ago
JSON representation
🤖Simple logging framework
- Host: GitHub
- URL: https://github.com/ngtk/loggerkit
- Owner: ngtk
- License: mit
- Created: 2018-05-18T06:12:23.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-08-19T11:17:35.000Z (almost 8 years ago)
- Last Synced: 2025-10-21T07:52:32.324Z (8 months ago)
- Topics: ios, logger, logging, swift
- Language: Swift
- Homepage:
- Size: 34.2 KB
- Stars: 7
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# LoggerKit [](https://badge.fury.io/co/LoggerKit) [](https://travis-ci.com/ngtk/LoggerKit) [](https://codeclimate.com/github/ngtk/LoggerKit/maintainability) [](https://codeclimate.com/github/ngtk/LoggerKit/test_coverage)
🤖 LoggerKit is logging framework that provides a format, log levels and multiple output destinations.
## Usage
Using pre bundled logger class `Logger`, you can send log with log level like:
```swift
// Global context
let logger = Logger()
let stdout = StandardOut()
logger.register(destination: stdout)
// In some code
logger.debug("For debug")
logger.verbose("Something verbose")
logger.info("Something want to know")
logger.warning("Not expected, but not error")
logger.error("Something went wrong, fix this")
```
## Customize
You can register custom destinations and log format.
Log format belongs to destination. So you can set format by each destination.
```swift
// Create your log formatter
final class CustomLogFormatter: LogFormatterProtocol {
func format(message: Any, level: LogLevel, context: LogContextProtocol) -> String {
// Format message here
}
}
// Create you log destination
final class CustomLogDestination: LogDestinationProtocol {
var formatter: LogFormatterProtocol
init(formatter: LogFormatterProtocol = CustomLogFormatter()) {
self.formatter = formatter
}
func write(_ message: Any, level: LogLevel, context: LogContextProtocol) {
let formatted = formatter.format(message, level: level, context: context)
// You can write here how you want
}
}
```
## Installation
Using [CocoaPods](https://cocoapods.org/):
```
pod 'LoggerKit'
```
## Development
In order to create Xcode project, run:
```
$ swift package generate-xcodeproj
```
### Release
```
$ bundle exec podspec_bump minor
$ pod lib lint
$ git push --tags
$ pod trunk push LoggerKit.podspec
```
[CocoaPods Guides](https://guides.cocoapods.org/making/making-a-cocoapod.html#release)