EXPLogger 1.0.3

EXPLogger 1.0.3

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2017
SwiftSwift Version 3.1
SPMSupports SPM

Maintained by Alexander Tereshkov.



EXPLogger 1.0.3

  • By
  • Alexander Tereshkov

A lightweight and simple logger for Swift projects

Colorful, flexible, lightweight logging for Swift 4.


Navigation


Example

Example of output in Xcode Console:

Example of output

  • Now there are some problems with displaying colors from the Xcode 8, so they are temporarily replaced by Emoji.

Installation

Swift Package Manager

Will be available soon.


Usage

This quick start method is intended just to get you up and running with the EXPLogger. You should however use the advanced usage below to get the most out of this library.

Add this code at the top of your AppDelegate.swift to be able to use EXPLogger in your whole project.
Or just use it in your individual classes. It's up to you.

  1. Import
import EXPLogger
  1. Declare an instance of the logger
let log = EXPLogger.self

In the AppDelegate method didFinishLaunchingWithOptions() add the EXPLogger log targets (console, file, etc.). And it's ready to use.

  1. Set up logger
// add log targets (important! at least one is needed)
let console = ConsoleTarget() // xcode console

// add the targets to log
log.addTarget(console)

// log anything you want in your whole project!
log.verbose("Some non important information that can be easily skipped")
log.debug("Some useful information just to debugging")
log.info("Useful information, etc")
log.warning("Not a good information")
log.error("Some error")
log.critical("Something went so wrong with critical prior")

The different methods set the log level of the message. EXPLogger will only print messages with a log level that is greater to or equal to it's current log level setting. So a logger with a level of .error will only output log messages with a level of .error, or .critical.


Advanced Usage

EXPLogger allows for much greater control and flexibility.

EXPlogger can be configured to deliver log messages to a variety of destinations. Using the basic setup above, the logger will output log messages to the standard Xcode debug console just in a few lines of setup.

  • Here's an example of configuring the logger with some additional settings.
// add log targets
let console = ConsoleTarget() // xcode console

console.showDate = false // (default is true)
console.showLogTag = true // (default is true)
console.showFileName = true // (default is true)
console.showFunctionName = false // (default is true)
console.showThreadName = true // (default is false) *will be available soon
console.showLineNumber = true // (default is true)
console.showLevel = false // (default is true)
console.showFileSuffix = true // (default is true)
console.enableColors = false // (default is false) *not working for now in Xcode 8
console.defaultDateFormat = "HH:mm:ss" // (default is "HH:mm:ss.SSS")
console.defaultTimeZone = "UTC" // (default will be TimeZone.Current)

// add the targets to log
log.addTarget(console)

// log anything you want in your whole project!
...

If you don't configure these functions, EXPLogger will work based on default values.

  • Here's an example of configuring the logger with some additional destinations.

Will be filled soon.


Documentation

Will be filled soon.


Communication and Help


Changelog

See CHANGELOG.


License

EXPLogger Library is released under the MIT License.