Swiftpack.co - Package - IBM-Swift/HeliumLogger


APIDoc Build Status - Master codecov macOS Linux Apache 2 Slack Status


Provides a lightweight Swift logging framework which supports logging to standard output.


  • 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


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/IBM-Swift/HeliumLogger.git", from: "x.x.x")

Add HeliumLogger to your target's dependencies:

.target(name: "example", dependencies: ["HeliumLogger"]),

Import packages

import HeliumLogger
import LoggerAPI

Initialize HeliumLogger

Initialize an instance of HeliumLogger. Set it as the logger used by LoggerAPI.

let logger = HeliumLogger()
Log.logger = logger

or, if you don't need to customize HeliumLogger:


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:

  1. entry (entering a function)
  2. exit (exiting a function)
  3. debug
  4. verbose (default)
  5. info
  6. warning
  7. 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:


Adjust logging levels at runtime

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

How to use HeliumLogger to log messages in your application:

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.


We love to talk server-side Swift, and Kitura. Join our Slack to meet the team!


This library is licensed under Apache 2.0. Full license text is available in LICENSE.


Stars: 112
Help us keep the lights on



1.8.0 - Nov 27, 2018

  • Add support for building with Swift 5 (#70)
  • Drop support for Swift 3.

Note: if you require Swift 3 support, please continue to use the 1.7 release of HeliumLogger.

1.7.3 - Oct 10, 2018

  • Fix manifest parse error on Swift 4.2

1.7.2 - Aug 8, 2018

  • Ensure that Swift 4 Package.swift is always used on Swift 4

1.7.1 - Aug 31, 2017

What's New

  • Support Swift 4

1.6.1 - Mar 27, 2017

Conditional Swift-3.1 compatibility