Logging utility for Swift and Objective C

Related tags

Logging Swell
Overview

Swell - Swift Logging

A logging utility for Swift and Objective C.

##Features

  • Turn on logging during development, turn them off when building for the App Store
  • Enable or disable logging for specific classes
  • Different log levels allow for finer-grained control of logging within a class
  • Log to the console, text file, or a custom location
  • Log message isn't computed when logging is disabled (thanks to the @auto_closure feature)

##Maintenance Note

I actively use this for my own projects, and every new project I create includes this. It works well for my needs. However, I develop iOS apps only in my spare time, which is not a lot. This can affect my response time to pull requests.

##Basic Usage

###Using the shared logger

The shared logger is the simplest, quickest way to get started using Swell.

class ContactService {

    func getContact(name: String) {
        Swell.info("Retrieving contact for \(name)")
        ...
    }

}
INFO: Retrieving contact for Steve

###Using a named logger

Using a named logger allows for better control over which logs of which classes you want to see during development. A typical name would match the class using it, making it easy to see which class is logging which statement.

class ContactService {

    let logger = Swell.getLogger("ContactService")

    func getContact(name: String) {
        logger.debug("Retrieving contact for \(name)")
        ...
    }

}
DEBUG ContactService: Retrieving contact for Steve

###Logging complex statements Sometimes you need extra code in order to generate the information you need to log, but you don't need to execute the same code when you build for the App Store. Using Swell's closure functions is the answer to this scenario.

class ContactService {

    let logger = Swell.getLogger("ContactService")

    func getContact(name: String) {
        ...
        logger.trace { 
        	let city = getCityFor(name)
            return "Retrieving contact for \(name) of \(city)"
        }
        ...
    }

}

The code in the closure will only execute if the statement will be logged according to how the Logger is configured.

###Disable all loggers

Are you building for the App Store? Don't forget to disable your loggers.

Swell.disableLogging()

See also the next section, which uses an optional .plist file to configure Swell.

##Configuration

For more control over how Swell loggers behave, add a Swell.plist resource file. You can then configure which log levels to enable, where to send the log output, and what information to include for each log.

###Root configuration The root configuration specifies the behavior for all Swell loggers.

Swell.plist example

All keys are optional. However, if you specify "file" for the log location, you should provide a filename for the log file. Any unspecified values will revert to built-in defaults.

###Named logger configurations

You can specify a different configuration for named loggers. As with the root configuration, the configuration details are optional, and any unspecified values will use what the root configuration has for it.

In the plist file, create a Dictionary type, and use the logger name as the Key. The configuration in this Dictionary will be used for that logger.

Swell.plist with configuration for a named logger

In the example above, MyStableClass is configured to only produce logs that are error level or higher, and will use a different log output format than other loggers. Since a log location wasn't provided, it will use the same location specified in the root configuration.

To use this logger, specify its name when you create your Logger instance.

let logger = Swell.getLogger("MyStableClass")

##Roadmap

Let's be honest - we have a long list of features for anything we write, long before we're done writing them.

However, my goal is to keep Swell as simple as possible, while allowing the configurability I've been looking for since I started iOS development.

So here's list of To Do for Swell:

  • More documentation
  • Improved Date format in FlexFormatter

That said, the Swell library is alpha software. Things may change (drastically). However, I'm already using it extensively for my projects, so I have plenty of incentives to keep the public API stable.

Comments
  • Allow Swell to be used as a Cocoapod

    Allow Swell to be used as a Cocoapod

    Added a podspec file so that people can use Swell as a Cocoapod. I have not added the spec file to the central Cocoapod repo. You add Swell to a Podfile like this:

    pod  'Swell', :git => '[email protected]:hubertr/Swell.git'
    
    opened by ordovician 5
  • Create a release using the semantic versioning

    Create a release using the semantic versioning

    I'm trying to reference your project using Carthage and it won't resolve since you have no releases. Would you mind creating a release, even if it's something like 0.0.1?

    Carthage apparently will not resolve anything that doesn't have a release. See https://github.com/Carthage/Carthage for more info.

    opened by JeffBNimble 3
  • Function in Formatter contains Optional()

    Function in Formatter contains Optional()

    When using the function name in the flex formatter, the resulting string contains "Optional("..")" text. Based on the code at https://developer.apple.com/swift/blog/?id=15 it looks like that the method signature of https://github.com/hubertr/Swell/blob/master/Swell/Logger.swift#L37 could be changed to use the non optional types.

    Or is there a specific reason why you used the optional? Another solution would be to fix the flex formatter to first try to unwrap optionals before printing them.

    opened by broglep-work 3
  • Swift 1.2 is not supported (Xcode 6.3)

    Swift 1.2 is not supported (Xcode 6.3)

    'autoclosure' attribute is now an attribute of the parameter declaration, not its type.

    Every occurence of message: @autoclosure() has to become @autoclosure message: instead.

    opened by juliensaad 2
  • Make compatible with Carthage and Bitrise/CI building

    Make compatible with Carthage and Bitrise/CI building

    Hey, I shared the build scheme to make it built with Carthage. Also changed the code signing identify of the release build to distribution, otherwise CI systems with only distribution profile installed fail. And finally changed deployment target to 8.0 since that's the earliest supporting dynamic frameworks and silenced the linker warning.

    opened by akolov 0
  • Perform Xcode recommended changes

    Perform Xcode recommended changes

    We did let Xcode Update to recommended settings. A warning was shown during compilation

    Project 'Swell' - Automatically Select Architectures
    
    Project 'Swell' overrides the Architectures setting. This will remove the settings and allow Xcode to automatically select Architectures based on hardware available for the active platform and deployment target.
    
    opened by broglep-work 0
  • Problem with Cent with installing via Carthage

    Problem with Cent with installing via Carthage

    *** Building scheme "Cent" in Dollar.xcworkspace
    fatal error: SDK count 3 in scheme Cent is not supported: file /Users/mdiep/Repositories/Carthage/Carthage/Source/CarthageKit/Xcode.swift, line 959
    
    Caught signal triggered by the Swift runtime!
    Illegal instruction: 4
    
    Unfortunately, this is probably a bug in Swift and not Carthage. If
    this is preventing you from doing work, please file an issue and we'll
    do our best to work around it:
    https://github.com/Carthage/Carthage/issues/new
    
    Please also consider filing a radar with Apple, containing the version
    of Carthage and any crash report found in Console.app.
    
    
    Caught signal triggered by the Swift runtime!
    Illegal instruction: 4
    
    opened by alec-c4 0
  • Swift 2.0

    Swift 2.0

    Hello there! I have made the necessary changes to Swell for Swift 2.0 compatibility (as of Xcode7b6). I would like to initiate a PR into a swift-2.0 branch but no such branch exists. If you would like to accept my PR would it go into a new branch, or into master? Thanks -Scott

    opened by scottdelly 4
  • formatKey println in Swell.swift

    formatKey println in Swell.swift

    There's a debug(?) println in the Swell.swift which prints the formatKey if Swell.plist is used. Is it really needed? Defeats the purpose of disabling all logging for the AppStore builds.

    opened by akolov 0
  • Adds OSX-Target

    Adds OSX-Target

    I wanted to use Swell with OSX and Carthage. There was only a scheme for iOS so i had to add a new target and it works.

    I added the existing tests to the OSX test target to assure that they are also executed. The last thing i changed was the use of Foundation instead of UIKit.

    carthage update *** Fetching Swell *** Checking out Swell at "9dceb9487d8455b919db81e255ffae9e99d8e070" *** xcodebuild output can be found in ... *** Building scheme "Swell-iOS" in Swell.xcodeproj *** Building scheme "Swell-OSX" in Swell.xcodeproj

    opened by ricobeck 0
Releases(0.5.0)
  • 0.5.0(May 5, 2015)

    This release includes updates to conform to Swift 1.2.

    BE WARNED: Due to a change in handling of closure parameters, some parameters have been reordered, specifically with Logger.log(), trace(), debug(), etc methods.

    However, if you're merely using Swell (and not extending it), then you shouldn't be affected.

    I would like to thank everyone who raised issues and submitted patches. I apologize for not responding in a timely manner. I really wanted Swell to be useful to as many people as possible, however time constraints prevent me from being an effective open source package lead.

    Source code(tar.gz)
    Source code(zip)
Owner
Hubert Rabago
Hubert Rabago
Twitter Logging Service is a robust and performant logging framework for iOS clients

Twitter Logging Service Background Twitter created a framework for logging in order to fulfill the following requirements: fast (no blocking the main

Twitter 290 Nov 15, 2022
A logging backend for swift-log that sends logging messages to Logstash (eg. the ELK stack)

LoggingELK LoggingELK is a logging backend library for Apple's swift-log The LoggingELK library provides a logging backend for Apple's apple/swift-log

null 17 Nov 15, 2022
Swift Logging Utility for Xcode & Google Docs

QorumLogs Swift Logging Utility in Xcode & Google Docs

Goktug Yilmaz 777 Jul 15, 2022
Spy is a flexible, lightweight, multiplatform logging utility written in pure Swift.

Spy is a flexible, lightweight, multiplatform logging utility written in pure Swift. It allows to log with different levels and on different channels. You can define what levels and channels actually are.

AppUnite Sp. z o.o. Spk. 12 Jul 28, 2021
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.

Please star this github repository to stay up to date. TraceLog Introduction TraceLog is a highly configurable, flexible, portable, and simple to use

Tony Stone 52 Oct 28, 2022
Elegant and extensive logging facility for OS X & iOS (includes database, Telnet and HTTP servers)

Overview XLFacility, which stands for Extensive Logging Facility, is an elegant and powerful logging facility for OS X & iOS. It was written from scra

Pierre-Olivier Latour 315 Sep 7, 2022
CleanroomLogger provides an extensible Swift-based logging API that is simple, lightweight and performant

CleanroomLogger CleanroomLogger provides an extensible Swift-based logging API that is simple, lightweight and performant. The API provided by Cleanro

null 1.3k Dec 8, 2022
Simple, lightweight and flexible debug logging framework written in Swift

AELog Simple, lightweight and flexible debug logging minion written in Swift If you find yourself in upcoming statements, then you probably want to us

Marko Tadić 28 Jul 6, 2022
In-App iOS Debugging Tool With Enhanced Logging, Networking Info, Crash reporting And More.

The debugger tool for iOS developer. Display logs, network request, device informations, crash logs while using the app. Easy accessible with its bubble head button ?? . Easy to integrate in any apps, to handle development or testing apps easier. First version, there is plenty of room for improvement.

Remi ROBERT 1.8k Dec 29, 2022
A fast & simple, yet powerful & flexible logging framework for Mac and iOS

CocoaLumberjack CocoaLumberjack is a fast & simple, yet powerful & flexible logging framework for macOS, iOS, tvOS and watchOS. How to get started Fir

null 12.9k Jan 9, 2023
Convenient & secure logging during development & release in Swift 3, 4 & 5

Colorful, flexible, lightweight logging for Swift 3, Swift 4 & Swift 5. Great for development & release with support for Console, File & cloud platfor

SwiftyBeaver 5.6k Jan 4, 2023
Willow is a powerful, yet lightweight logging library written in Swift.

Willow Willow is a powerful, yet lightweight logging library written in Swift. Features Requirements Migration Guides Communication Installation Cocoa

Nike Inc. 1.3k Nov 16, 2022
A lightweight logging framework for Swift

HeliumLogger Provides a lightweight logging implementation for Swift which logs to standard output. Features Logs output to stdout by default. You can

Kitura 174 Nov 30, 2022
A lightweight logging framework for Swift

HeliumLogger Provides a lightweight logging implementation for Swift which logs to standard output. Features Logs output to stdout by default. You can

Kitura 174 Nov 30, 2022
A flexible logging library written in Swift

Puppy Puppy is a flexible logging library written in Swift ?? It supports multiple transports(console, file, syslog, and oslog) as loggers. It not onl

Koichi Yokota 92 Dec 29, 2022
An extensible logging framework for Swift

Log is a powerful logging framework that provides built-in themes and formatters, and a nice API to define your owns. Get the most out of Log by insta

Damien 825 Nov 6, 2022
A powerful input-agnostic swift logging framework made to speed up development with maximum readability.

The Swift logging framework. Atlantis is an extremely powerful logging framework that I've created for everyday use, including enterprise development

Andrew Aquino 199 Jan 2, 2023
Most natural Swift logging

Evergreen Most natural Swift logging Evergreen is a logging framework written in Swift. It is designed to work just as you would expect, yet so versat

Nils Leif Fischer 72 Aug 12, 2022
A simple logging package for Swift

OhMyLog OhMyLog is a simple logging package for Swift. It supports the following features: Six logging levels ( ?? , ?? , ?? , ⚠️ , ?? , ?? ) Display

Junhao Wang 1 Jan 10, 2022