Swiftpack.co - Package - IBM-Swift/HeliumLogger


Build Status codecov

Provides a lightweight Swift Logging framework.


  • Different logging levels such as Warning, Verbose, and Error
  • Color output to terminal


  1. Import HeliumLogger and LoggerAPI:
import HeliumLogger
import LoggerAPI
  1. 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:

  1. You can specify the level of output on initialization. You will see output of that level, and all levels below that. The order goes:

    1. entry (entering a function)
    2. exit (exiting a function)
    3. debug
    4. verbose (default)
    5. info
    6. warning
    7. error

So for example,

let logger = HeliumLogger(.verbose)
Log.logger = logger

Will show messages of verbose, info, warning, and error type.



will only show messages of warning and error type.

  1. Adjust logging levels at runtime:

Calling HeliumLogger.use(LoggerMessageType) will set the LoggerAPI to use this new HeliumLogger instance. This allows you to, for example, if in a route you detect an error with your application, dynamically increase the log level.

This new instance will not have any customization you did to other instances. (see list item 6).

  1. Logging messages:
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.")
  1. 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?