Note this is prerelease software subject to robust changes.
The goal of this package is to provide an easy to use and universal method to log information to the Console via OSLog and using SwiftLog via Pulse.
Add Stenographer to your project through Xcode by adding a project with the repository's url.
In order to use the prebuilt Pulse Logging view there are 2 steps.
- Import Pulse UI by adding the following to the
Viewthat will display the Pulse UI.
import PulseUI- Add the
MainViewto yourView. This can be done however you prefer. For this example we will use aNavigationLink.
NavigationLink("Logs", destination: MainView())Adding custom log categories is easy and can be managed via an extension to Logging.Logger.
-
Create a
.swiftfile to handle your extension code. -
Import Stenographer and Logging by adding the following to your extension file.
import Stenographer
import Logging- Extend
Logging.Logger.
extension Logging.Logger {
// This is were your category code will go
}- Add your custom categories inside your extension.
extension Logging.Logger {
static let analytics = Log(category: "📈 analytics")
static let bootstrap = Log(category: "🥾 bootstrapping")
static let keychain = Log(category: "🔐 keychain")
static let lifecycle = Log(category: "🚴♀️ lifecycle")
}- Import
Loggingto the file where you want to log.
import Logging- Then log with the according log level.
Logger.bootstrap.info("App initialized")
Logger.analytics.error("Analytics server returned error \(error)")
// etcStenographer is free software distributed under the terms of the MIT license, reproduced below. Stenographer may be used for any purpose, including commercial purposes, at absolutely no cost. No paperwork, no royalties, no GNU-like "copyleft" restrictions. Just download and enjoy.
Copyright (c) 2022 Small Planet Digital, LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Small Planet is a mobile agency in Brooklyn, NY that creates lovely experiences for smartphones and tablets. Stenographer has made our lives a lot easier and we hope it does the same for you. You can find us at smallplanet.com.