Coder Social home page Coder Social logo

sp0cket / swiftybeaver Goto Github PK

View Code? Open in Web Editor NEW

This project forked from swiftybeaver/swiftybeaver

0.0 2.0 0.0 1.97 MB

Convenient logging during development & release in Swift 2 & 3

Home Page: https://swiftybeaver.com

License: MIT License

Swift 99.22% Ruby 0.61% Shell 0.18%

swiftybeaver's Introduction

SwiftyBeaver
Colorful, flexible, lightweight logging for Swift 2 & Swift 3.
Great for development & release with support for Console, File & cloud platforms.
NEW: Log during release to the conveniently built-in SwiftyBeaver Platform and Mac App!

Docs | Website | Slack | Twitter | License

[![Language Swift 3](https://img.shields.io/badge/Language-Swift%202%20&%203-orange.svg)](https://swift.org) [![CircleCI](https://circleci.com/gh/SwiftyBeaver/SwiftyBeaver/tree/master.svg?style=shield)](https://circleci.com/gh/SwiftyBeaver/SwiftyBeaver) [![Slack Status](https://slack.swiftybeaver.com/badge.svg)](https://slack.swiftybeaver.com)

----

During Development: Colored Logging to Xcode Console

Learn more about colored logging to Xcode 8 Console with Swift 3. For Swift 2.3 use this Gist. No need to hack Xcode 8 anymore to get color. You can even customize the log level word (ATTENTION instead of ERROR maybe?), the general amount of displayed data and if you want to use the 💜s or replace them with something else 😉


During Development: Colored Logging to File

Learn more about logging to file which is great for Terminal.app fans or to store logs on disk.


On Release: Encrypted Logging to SwiftyBeaver Platform

Learn more about logging to the SwiftyBeaver Platform during release!


Browse, Search & Filter via Mac App

swiftybeaver-demo1

Conveniently access your logs during development & release with our free Mac App.



Installation

  • For Swift 3 install the latest SwiftyBeaver version
  • For Swift 2 install SwiftyBeaver 0.7.0

### Carthage

You can use Carthage to install SwiftyBeaver by adding that to your Cartfile:

Swift 3:

github "SwiftyBeaver/SwiftyBeaver"

Swift 2:

github "SwiftyBeaver/SwiftyBeaver" ~> 0.7

### CocoaPods

To use CocoaPods just add this to your Podfile:

Swift 3:

pod 'SwiftyBeaver'

Swift 2:

target 'MyProject' do
  use_frameworks!

  # Pods for MyProject
  pod 'SwiftyBeaver', '~> 0.7'
end

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    # Configure Pod targets for Xcode 8 with Swift 2.3
    config.build_settings['SWIFT_VERSION'] = '2.3'
  end
end

### Swift Package Manager

For Swift Package Manager add the following package to your Package.swift file. Just Swift 3 is supported:

.Package(url: "https://github.com/SwiftyBeaver/SwiftyBeaver.git", majorVersion: 1)


Usage

Add that near the top of your AppDelegate.swift to be able to use SwiftyBeaver in your whole project.

import SwiftyBeaver
let log = SwiftyBeaver.self

At the the beginning of your AppDelegate:didFinishLaunchingWithOptions() add the SwiftyBeaver log destinations (console, file, etc.), optionally adjust the log format and then you can already do the following log level calls globally:

// add log destinations. at least one is needed!
let console = ConsoleDestination()  // log to Xcode Console
let file = FileDestination()  // log to default swiftybeaver.log file
let cloud = SBPlatformDestination(appID: "foo", appSecret: "bar", encryptionKey: "123") // to cloud

// use custom format and set console output to short time, log level & message
console.format = "$DHH:mm:ss$d $L $M"

// add the destinations to SwiftyBeaver
log.addDestination(console)
log.addDestination(file)
log.addDestination(cloud)

// Now let’s log!
log.verbose("not so important")  // prio 1, VERBOSE in silver
log.debug("something to debug")  // prio 2, DEBUG in green
log.info("a nice information")   // prio 3, INFO in blue
log.warning("oh no, that won’t be good")  // prio 4, WARNING in yellow
log.error("ouch, an error did occur!")  // prio 5, ERROR in red

// log anything!
log.verbose(123)
log.info(-123.45678)
log.warning(Date())
log.error(["I", "like", "logs!"])
log.error(["name": "Mr Beaver", "address": "7 Beaver Lodge"])


Server-side Swift

We ❤️ server-side Swift 3 and SwiftyBeaver supports it out-of-the-box! Try for yourself and run SwiftyBeaver inside a Ubuntu Docker container. Just install Docker and then go to your the project folder on macOS or Ubuntu and type:

# create docker image, build SwiftyBeaver and run unit tests
swift build --clean && docker build --rm -t swiftybeaver .

# optionally log into container to run Swift CLI and do more stuff
docker run --rm -it --privileged=true -v $PWD:/app swiftybeaver

Best: for the popular server-side Swift web framework Vapor you can use our Vapor logging provider which makes server logging awesome again 🙌



Documentation

Getting Started:

Logging Destinations:

Advanced Topics:

Stay Informed:

More destination & system documentation is coming soon!
Get support via Github Issues, email and public Slack channel.



## License

SwiftyBeaver Framework is released under the MIT License.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.