-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add devcontainer config * manifest version updates * general maintenance * refactor to use AHC on linux * use datadog’s Site terminology * add docs
- Loading branch information
1 parent
e47aa09
commit 9bd7987
Showing
25 changed files
with
508 additions
and
233 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{ | ||
"name": "Swift", | ||
"image": "swift:5.9.1", | ||
"features": { | ||
"ghcr.io/devcontainers/features/common-utils:2": { | ||
"installZsh": "false", | ||
"username": "vscode", | ||
"userUid": "1000", | ||
"userGid": "1000", | ||
"upgradePackages": "false" | ||
}, | ||
"ghcr.io/devcontainers/features/git:1": { | ||
"version": "os-provided", | ||
"ppa": "false" | ||
} | ||
}, | ||
"runArgs": [ | ||
"--cap-add=SYS_PTRACE", | ||
"--security-opt", | ||
"seccomp=unconfined" | ||
], | ||
// Configure tool-specific properties. | ||
"customizations": { | ||
// Configure properties specific to VS Code. | ||
"vscode": { | ||
// Set *default* container specific settings.json values on container create. | ||
"settings": { | ||
"lldb.library": "/usr/lib/liblldb.so" | ||
}, | ||
// Add the IDs of extensions you want installed when the container is created. | ||
"extensions": [ | ||
"sswg.swift-lang" | ||
] | ||
} | ||
}, | ||
// Use 'forwardPorts' to make a list of ports inside the container available locally. | ||
// "forwardPorts": [], | ||
|
||
// Use 'postCreateCommand' to run commands after the container is created. | ||
"postCreateCommand": "swift --version", | ||
|
||
// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. | ||
"remoteUser": "vscode" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
xcuserdata/ | ||
/.swiftpm | ||
/Package.resolved | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
version: 1 | ||
builder: | ||
configs: | ||
- documentation_targets: [DataDogLog] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ This package implements a handler for [swift-log](https://github.com/apple/swift | |
Integrate the `DataDogLog` package as a dependency with Swift Package Manager. Add the following to `Package.swift`: | ||
|
||
```swift | ||
.package(url: "[email protected]:jagreenwood/swift-log-datadog.git", from: "0.0.1") | ||
.package(url: "[email protected]:jagreenwood/swift-log-datadog.git", from: "1.0.0") | ||
``` | ||
|
||
Add `DataDogLog` to your target dependencies: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# ``DataDogLog`` | ||
|
||
A Datadog logging backend for Swift | ||
|
||
## Overview | ||
|
||
This package implements a logging backend for [swift-log](https://github.com/apple/swift-log) which will send log messages to the [Datadog's](https://www.datadoghq.com) Log Management service. | ||
|
||
## Topics | ||
|
||
### Getting Started | ||
|
||
- <doc:GettingStarted> | ||
|
||
### Essentials | ||
|
||
- ``DataDogLogHandler`` | ||
- ``Site`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# Getting Started | ||
|
||
## Overview | ||
|
||
### Add Package | ||
Integrate the `DataDogLog` package as a dependency with Swift Package Manager. Add the following to `Package.swift`: | ||
|
||
```swift | ||
.package(url: "[email protected]:jagreenwood/swift-log-datadog.git", from: "1.0.0") | ||
``` | ||
|
||
Add `DataDogLog` to your target dependencies: | ||
|
||
```swift | ||
.product(name: "DataDogLog", package: "swift-log-datadog") | ||
``` | ||
|
||
### Configure | ||
|
||
Configure the logger by bootstrapping a `DataDogLogHandler` instance. | ||
|
||
```swift | ||
import DataDogLog | ||
|
||
// add handler to logging system | ||
LoggingSystem.bootstrap { | ||
// initialize handler instance | ||
var handler = DataDogLogHandler(label: $0, key: "xxx", hostname: "hostname") | ||
// global metadata (optional) | ||
handler.metadata = ["foo":"bar"] | ||
|
||
return handler | ||
} | ||
``` | ||
|
||
### Logging | ||
|
||
To send logs to Datadog, initialize a `Logger` instance and send a message with optional additional metadata: | ||
|
||
```swift | ||
import DataDogLog | ||
|
||
let logger = Logger(label: "com.swift-log.awesome-app") | ||
logger.error("unfortunate error", metadata: ["request-id": "abc-123"], source: "module-name") | ||
``` | ||
|
||
This call will send the following payload to Datadog: | ||
|
||
```json | ||
{ | ||
"message": "2020-05-27T06:37:17-0400 ERROR: unfortunate error", | ||
"hostname": "hostname", | ||
"ddsource": "module-name", | ||
"ddtags": "callsite:testLog():39,foo:bar,request-id:abc-123", | ||
"status": "error" | ||
"service": "com.swift-log.awesome-app" | ||
} | ||
``` | ||
|
||
### Select Site | ||
|
||
The Datadog API runs on multiple regions (e.g. US, EU, US3, US5, US1FED), with different API endpoints. If your account was not created in the default **US** region, you need to set the `region` option when initializing `DataDogLogHandler`: | ||
|
||
```swift | ||
DataDogLogHandler(label: $0, key: "xxx", hostname: "hostname", region: .EU) | ||
``` | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Logging | ||
|
||
extension Logger.Metadata { | ||
var prettified: String? { | ||
!isEmpty ? map { "\($0):\($1)" } | ||
.sorted(by: <) | ||
.joined(separator: ",") : nil | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Foundation | ||
|
||
extension Site { | ||
var url: URL { | ||
switch (self) { | ||
case .AP1: URL(string: "https://http-intake.logs.ap1.datadoghq.com/api/v2/logs")! | ||
case .EU: URL(string: "https://http-intake.logs.datadoghq.eu/api/v2/logs")! | ||
case .US: URL(string: "https://http-intake.logs.datadoghq.com/api/v2/logs")! | ||
case .US3: URL(string: "https://http-intake.logs.us3.datadoghq.com/api/v2/logs")! | ||
case .US5: URL(string: "https://http-intake.logs.us5.datadoghq.com/api/v2/logs")! | ||
case .US1FED: URL(string: "https://http-intake.logs.ddog-gov.com/api/v2/logs")! | ||
} | ||
} | ||
} |
File renamed without changes.
Oops, something went wrong.