Latest 0.1.0
Homepage https://github.com/messeb/MSSentryCocoaLumberjack
License MIT
Platforms ios 8.0
Dependencies CocoaLumberjack/Swift, RavenSwift

CI Status
Version
License
Platform

MSSentryLogger is a custom logger for CocoaLumberjack that logs to Sentry.

It contains a mapping from the CocoaLumberJack DDLogFlag to the RavenLogEvent. You can call the CocoaLumberjack logging function and it will produce a corresponding event in Sentry.

Mapping

CocoaLumberjack Sentry
DDLogDebug Debug
DDLogInfo Info
DDLogWarn Warning
DDLogError Error

Installation

Using CocoaPods:

pod "MSSentryCocoaLumberjack"

Usage

You need a Sentry account.

Import the pod and create a new MSSentryLogger instance with your credentials (DSN)

import MSSentryCocoaLumberjack

// ... 

let sentryLogger = MSSentryLogger(dsn: <YOUR DSN>)

Than add the new logger to the CocoaLumberjack loggers

DDLog.addLogger(sentryLogger)

Now you can call the CocoaLumberjack logging functions (DDLogDebug, DDLogInfo, DDLogWarn, DDLogError) and a Sentry log event will be created.

Sentry properties

On the MSSentryLogger instance you can modify values for user, tags and extra. These are [String: AnyObject] dictionaries and the set values will be send in the next requests.

// user has predefined keys by Sentry
sentryLogger?.user = ["id": "4711", "username": "John Doe", "email": "[email protected]", "ip_address": 
"127.0.0.1"]

sentryLogger?.tags = ["tag1": "value1", "tag2": "value2"]

sentryLogger?.extra = ["extra1": ""valueXYZ"]

You can always set new values to user, tags and extra. For more information take a look at the Sentry documentation: https://docs.getsentry.com/hosted/learn/context/

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

In the example app you can add your credentials and trigger logs to Sentry:

Sentry Example App

You will see the event instantly in your Sentry account

Author

messeb

License

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

Latest podspec

{
    "name": "MSSentryCocoaLumberjack",
    "version": "0.1.0",
    "summary": "Custom CocoaLumberjack logger for Sentry",
    "description": "MSSentryLogger is a custom logger for CocoaLumberjack that logs to Sentry.nIt contains a mapping from the CocoaLumberJack DDLogFlag to the Sentry RavenLogEvent.nYou can call the CocoaLumberjack logging function and it will produce a corresponding event in Sentry.",
    "homepage": "https://github.com/messeb/MSSentryCocoaLumberjack",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": "messeb",
    "source": {
        "git": "https://github.com/messeb/MSSentryCocoaLumberjack.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "MSSentryCocoaLumberjack/Classes/**/*",
    "dependencies": {
        "CocoaLumberjack/Swift": [],
        "RavenSwift": []
    }
}

Pin It on Pinterest

Share This