Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/denismurphy/oslog-helper
A simple utility library that adds extra metadata to your OSLog logging, such as file name, function name, and line number.
https://github.com/denismurphy/oslog-helper
ios ipados logging macos oslog swift watchos
Last synced: 3 months ago
JSON representation
A simple utility library that adds extra metadata to your OSLog logging, such as file name, function name, and line number.
- Host: GitHub
- URL: https://github.com/denismurphy/oslog-helper
- Owner: denismurphy
- License: mit
- Created: 2023-01-10T14:39:10.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-14T14:05:38.000Z (6 months ago)
- Last Synced: 2024-08-14T15:36:14.435Z (6 months ago)
- Topics: ios, ipados, logging, macos, oslog, swift, watchos
- Language: Swift
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# đ OSLogHelper
The `OSLogHelper` library is a utility for simplifying the use of the `os_log` function in iOS and macOS applications. đ It provides a simple, easy-to-use interface for logging messages with different levels, including `default`, `debug`, `info`, `fault`, and `error`.
## đ Usage
To use `OSLogHelper`, first import the library in your Swift file:
```swift
import OSLogHelper
```You can then use the various logging functions provided by `OSLogHelper` to log messages with different levels. Here's an example of how to use the `info` function to log an informational message:
```swift
let log = OSLog(subsystem: "com.example.myapp", category: "MyCategory")
OSLog.info("This is an informational message", log: log)
```You can also log errors with an error object:
```swift
let log = OSLog(subsystem: "com.example.myapp", category: "MyCategory")
OSLog.exception("This is an error message", error: myError, log: log)
```## đ Logging Levels
You can use the following functions for logging messages with different levels:
- đ `default`
- đ `debug`
- âšī¸ `info`
- â ī¸ `fault`
- â `error`
- đĨ `exception`By default, the logging functions will include the file name, function name, and line number where the log message was called.
## đ§ Compatibility
This library requires Swift 5.0 or later and is compatible with:
- đą iOS 12.0 or later
- đĨī¸ macOS 10.14 or later## đĻ Installation
You can install `OSLogHelper` using the Swift Package Manager by adding it as a dependency in your `Package.swift` file or adding it to your Xcode project.
## đ Conclusion
`OSLogHelper` is a simple and lightweight utility for logging messages in iOS and macOS applications. It provides an easy-to-use interface for logging messages with different levels and includes useful information such as file name, function name, and line number. It can be invaluable for debugging, troubleshooting, and monitoring your app. đ