Skip to content

Commit b112ac5

Browse files
committed
Add readme
1 parent 730e39c commit b112ac5

File tree

1 file changed

+88
-0
lines changed
  • 3rd-party-integrations/SentryCocoaLumberjack

1 file changed

+88
-0
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Sentry CocoaLumberjack Integration
2+
3+
A [CocoaLumberjack](https://github.com/CocoaLumberjack/CocoaLumberjack) logger that forwards log entries to Sentry's structured logging system, automatically capturing application logs with full context including source location, thread information, and log levels.
4+
5+
> [!NOTE]
6+
> This repo is a mirror of [github.com/getsentry/sentry-cocoa](https://github.com/getsentry/sentry-cocoa). The source code lives in `3rd-party-integrations/SentryCocoaLumberjack/`. This allows users to import only what they need via SPM while keeping all integration code in the main repository.
7+
8+
## Installation
9+
10+
### Swift Package Manager
11+
12+
Add the following dependencies to your `Package.swift` or Xcode package dependencies:
13+
14+
```swift
15+
dependencies: [
16+
.package(url: "https://github.com/getsentry/sentry-cocoa-cocoalumberjack", from: "1.0.0")
17+
]
18+
```
19+
20+
## Quick Start
21+
22+
```swift
23+
import Sentry
24+
import SentryCocoaLumberjack
25+
import CocoaLumberjackSwift
26+
27+
SentrySDK.start { options in
28+
options.dsn = "YOUR_DSN"
29+
options.enableLogs = true
30+
}
31+
32+
DDLog.add(SentryCocoaLumberjackLogger())
33+
34+
DDLogInfo("User logged in")
35+
DDLogError("Payment failed")
36+
DDLogWarn("API rate limit approaching")
37+
DDLogDebug("Processing request")
38+
DDLogVerbose("Detailed trace information")
39+
```
40+
41+
## Configuration
42+
43+
### Log Level Threshold
44+
45+
Set the minimum log level for messages to be sent to Sentry:
46+
47+
```swift
48+
DDLog.add(SentryCocoaLumberjackLogger(logLevel: .verbose))
49+
```
50+
51+
Messages below the configured threshold will be filtered out and not sent to Sentry.
52+
53+
## Log Level Mapping
54+
55+
CocoaLumberjack log levels are automatically mapped to Sentry log levels:
56+
57+
| CocoaLumberjack Level | Sentry Log Level |
58+
| --------------------- | ---------------- |
59+
| `.error` | `.error` |
60+
| `.warning` | `.warn` |
61+
| `.info` | `.info` |
62+
| `.debug` | `.debug` |
63+
| `.verbose` | `.trace` |
64+
65+
## Automatic Attributes
66+
67+
The logger automatically includes the following attributes with every log entry:
68+
69+
- `sentry.origin`: `"auto.logging.cocoalumberjack"`
70+
- `cocoalumberjack.level`: The original CocoaLumberjack log level (error, warning, info, debug, verbose)
71+
- `cocoalumberjack.file`: The source file name
72+
- `cocoalumberjack.function`: The function name
73+
- `cocoalumberjack.line`: The line number
74+
- `cocoalumberjack.context`: The log context (integer)
75+
- `cocoalumberjack.timestamp`: The log timestamp
76+
- `cocoalumberjack.threadID`: The thread ID
77+
- `cocoalumberjack.threadName`: The thread name (if available)
78+
- `cocoalumberjack.queueLabel`: The dispatch queue label (if available)
79+
80+
## Documentation
81+
82+
- [Sentry Cocoa SDK Documentation](https://docs.sentry.io/platforms/apple/)
83+
- [Sentry Logs Documentation](https://docs.sentry.io/platforms/apple/logs/)
84+
- [CocoaLumberjack Repo](https://github.com/CocoaLumberjack/CocoaLumberjack)
85+
86+
## License
87+
88+
This integration follows the same license as the Sentry Cocoa SDK. See the [LICENSE](https://github.com/getsentry/sentry-cocoa/blob/main/LICENSE.md) file for details.

0 commit comments

Comments
 (0)