HeliumLogger alternatives and similar libraries
Based on the "Logging" category.
Alternatively, view HeliumLogger alternatives based on common mentions on social networks and blogs.
-
XCGLogger
A debug log framework for use in Swift projects. Allows you to log details to the console (and optionally a file), just like you would have with NSLog() or print(), but with additional information, such as the date, function name, filename and line number. -
Dotzu
DISCONTINUED. Debbuger tool for iOS developer. Display logs, network request, device informations, crash logs while using the app. -
TinyConsole
📱💬🚦 TinyConsole is a micro-console that can help you log and display information inside an iOS application, where having a connection to a development computer is not possible. -
CleanroomLogger
CleanroomLogger provides an extensible Swift-based logging API that is simple, lightweight and performant -
Puree
DISCONTINUED. [Obsoleted] A log collector for iOS (new version! -> https://github.com/cookpad/Puree-Swift) -
Atlantis
A powerful input-agnostic swift logging framework made to speed up development with maximum readability. -
CleanroomASL
DISCONTINUED. A Swift-based API for reading from & writing to the Apple System Log (more commonly known somewhat inaccurately as "the console") -
TraceLog
TraceLog is a highly configurable, flexible, portable, and simple to use debug logging system for Swift and Objective-C applications running on Linux, macOS, iOS, watchOS, and tvOS. -
CacheAdvance
A performant cache for logging systems. CacheAdvance persists log events 30x faster than SQLite.
CodeRabbit: AI Code Reviews for Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of HeliumLogger or a related project?
README
HeliumLogger
Provides a lightweight logging implementation for Swift which logs to standard output.
Features
- Logs output to stdout by default. You can change the output stream, see example usage forÂ
HeliumStreamLogger.use(_:outputStream:)
. - Different logging levels such as Warning, Verbose, and Error
- Enable/disable color output to terminal
- Support for the Kitura
LoggerAPI
and Swift-logLogging
logging APIs.
Usage
Add dependencies
Add the HeliumLogger
package to the dependencies within your application’s Package.swift
file. Substitute "x.x.x"
with the latest HeliumLogger
release.
.package(url: "https://github.com/Kitura/HeliumLogger.git", from: "x.x.x")
Add HeliumLogger
to your target's dependencies:
.target(name: "example", dependencies: ["HeliumLogger"]),
Import packages
To use with LoggerAPI:
import HeliumLogger
import LoggerAPI
To use with swift-log:
import HeliumLogger
import Logging
Initialize HeliumLogger
To use HeliumLogger as a logging backend for LoggerAPI:
let logger = HeliumLogger()
Log.logger = logger
or, if you don't need to customize HeliumLogger
:
HeliumLogger.use()
To use HeliumLogger as a logging backend for swift-log:
let logger = HeliumLogger()
LoggingSystem.bootstrap(logger.makeLogHandler)
Or, as a convenience:
HeliumLogger.bootstrapSwiftLog()
Logging levels
You can specify the level of output on initialization. You will see output of that level, and all levels below that.
The order is:
- entry (entering a function)
- exit (exiting a function)
- debug
- verbose (default)
- info
- warning
- error
For example, this logger will show messages of type verbose
, info
, warning
, and error
:
let logger = HeliumLogger(.verbose)
Log.logger = logger
In this example, the logger will only show messages of type warning
and error
:
HeliumLogger.use(.warning)
Note that when HeliumLogger is used in conjunction with swift-log, the logging level is determined by the Logger
, and HeliumLogger's own logging level is unused.
Adjust logging levels at runtime (LoggerAPI)
Calling HeliumLogger.use(LoggerMessageType)
will set the LoggerAPI
to use this new HeliumLogger instance. If in a route you detect an error with your application, you could use this to dynamically increase the log level.
This new instance will not have any customization which you applied to other instances (see list item 7).
Logging messages (LoggerAPI)
How to use HeliumLogger to log messages in your application with LoggerAPI:
Log.verbose("This is a verbose log message.")
Log.info("This is an informational log message.")
Log.warning("This is a warning.")
Log.error("This is an error.")
Log.debug("This is a debug message.")
Further customization
/// Whether, if true, or not the logger output should be colorized.
public var colored: Bool = false
/// If true, use the detailed format when a user logging format wasn't specified.
public var details: Bool = true
/// If true, use the full file path, not just the filename.
public var fullFilePath: Bool = false
/// If not nil, specifies the user specified logging format.
/// For example: "[(%date)] [(%type)] [(%file):(%line) (%func)] (%msg)"
public var format: String?
/// If not nil, specifies the format used when adding the date and the time to the logged messages.
public var dateFormat: String?
/// If not nil, specifies the timezone used in the date time format.
public var timeZone: TimeZone?
API documentation
For more information visit our API reference.
Community
We love to talk server-side Swift, and Kitura. Join our Slack to meet the team!
License
This library is licensed under Apache 2.0. Full license text is available in LICENSE.
*Note that all licence references and agreements mentioned in the HeliumLogger README section above
are relevant to that project's source code only.