Giter VIP home page Giter VIP logo

snlog's Introduction

About

SNLog is a lightweight Swift logger with support for Issue Navigator flagging.

What is Issue Navigator flagging?

With Objective-C, I was able to insert pragma flags (messages) into the Issue Navigator. I used this to allow me to find FIXME markers in my code as well as temporary log messages. This was implemented with a set of macros that I maintained in a common header file.

Unfortunately Swift does not support general preprocessing of the code, so pragma flags and macros are not an option in Swift.

SNLog provides an alternative by making use of a benign warning: "Treating a forced downcast to '<custom class>' as optional will never produce 'nil'"

Screenshot

example1 img

Features

  • Easily insert log messages that include the file, function and line number where invoked.
  • Calls to SNLog can optionally appear in the Issue Navigator for temporary log messages (allows you to find them easily).
  • Insert one line Fixme statements that appear in the Issue Navigator (without log).

Installation

Download and add SNLog.swift to your project (CocoaPods does not currently provide support for Swift).

If your code currently uses any of the following global variables then you will need to rename them in SNLog.swift

g_log
g_fixme
g_anyFixme

Usage

Simple logging

SNLog.log("<message>")
SNLog.info("<message>")
SNLog.error("<message>")

Log with Issue Navigator flag

g_log = SNLog.log("<message>") as SNLog
g_log = SNLog.info("<message>") as SNLog
g_log = SNLog.error("<message>") as SNLog

Need to return Void from a closure after logging?

SNLog.info("<message>")
Void()

Insert a Fixme line with Issue Navigator flag

g_fixme = g_anyFixme as SNLog.Fixme

Author

Scott Carter

License

SNLog is available under the MIT license. See the LICENSE file for more info.

snlog's People

Stargazers

Bob Edmonston avatar

Watchers

James Cloos avatar Scott Carter avatar

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.