Skip to content

Commit

Permalink
feat: add support for additional platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
lovetodream committed Dec 28, 2023
1 parent 917ade0 commit fb800a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 13 deletions.
17 changes: 5 additions & 12 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "swift-log-loki",
platforms: [.macOS(.v11)],
platforms: [.macOS(.v11), .iOS(.v14), .tvOS(.v14), .watchOS(.v7)],
products: [
.library(
name: "LoggingLoki",
targets: ["LoggingLoki"]),
.library(name: "LoggingLoki", targets: ["LoggingLoki"]),
],
dependencies: [
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
Expand All @@ -18,17 +14,14 @@ let package = Package(
.package(url: "https://github.com/lovetodream/swift-snappy", from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "LoggingLoki",
dependencies: [
.product(name: "Logging", package: "swift-log"),
.product(name: "SwiftProtobuf", package: "swift-protobuf"),
.product(name: "Snappy", package: "swift-snappy"),
]),
.testTarget(
name: "LoggingLokiTests",
dependencies: ["LoggingLoki"]),
]
),
.testTarget(name: "LoggingLokiTests", dependencies: ["LoggingLoki"]),
]
)
2 changes: 1 addition & 1 deletion Sources/LoggingLoki/LokiLogHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public struct LokiLogHandler: LogHandler, Sendable {
#if os(Linux) // this needs to be explicitly checked, otherwise the build will fail on linux
self.lokiURL = lokiURL.appendingPathComponent("/loki/api/v1/push")
#else
if #available(macOS 13.0, *) {
if #available(macOS 13.0, iOS 16.0, tvOS 16.0, watchOS 9.0, *) {
self.lokiURL = lokiURL.appending(path: "/loki/api/v1/push")
} else {
self.lokiURL = lokiURL.appendingPathComponent("/loki/api/v1/push")
Expand Down
2 changes: 2 additions & 0 deletions Sources/LoggingLoki/LokiStream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ struct LokiStream: Encodable, Sendable {
let formatter = NumberFormatter()
formatter.numberStyle = .decimal
formatter.groupingSeparator = ""
#if os(macOS) || !canImport(Darwin)
formatter.thousandSeparator = ""
#endif
let timestamp = Int64(log.timestamp.timeIntervalSince1970 * 1_000_000_000) as NSNumber
guard let formattedTimestamp = formatter.string(from: timestamp) else {
return nil
Expand Down

0 comments on commit fb800a4

Please sign in to comment.