Skip to content

Commit

Permalink
Merge pull request #2 from ianpartridge/locking
Browse files Browse the repository at this point in the history
fix: remove locking
  • Loading branch information
ianpartridge authored May 1, 2019
2 parents 93e9cb6 + 50e4980 commit 654ea6e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 219 deletions.
193 changes: 0 additions & 193 deletions Sources/LoggingSyslog/Locks.swift

This file was deleted.

31 changes: 5 additions & 26 deletions Sources/LoggingSyslog/SyslogLogHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import Logging

/// A `LogHandler` which logs to `syslog(3)`.
public struct SyslogLogHandler: LogHandler {
private let lock = Lock()

/// Create a `SyslogLogHandler`.
public init(label: String) {
Expand All @@ -12,17 +11,7 @@ public struct SyslogLogHandler: LogHandler {

public let label: String

private var _logLevel: Logger.Level = .info
public var logLevel: Logger.Level {
get {
return self.lock.withLock { self._logLevel }
}
set {
self.lock.withLock {
self._logLevel = newValue
}
}
}
public var logLevel: Logger.Level = .info

public func log(level: Logger.Level,
message: Logger.Message,
Expand All @@ -39,28 +28,18 @@ public struct SyslogLogHandler: LogHandler {
}

private var prettyMetadata: String?
private var _metadata = Logger.Metadata() {
public var metadata = Logger.Metadata() {
didSet {
self.prettyMetadata = self.prettify(self._metadata)
}
}
public var metadata: Logger.Metadata {
get {
return self.lock.withLock { self._metadata }
}
set {
self.lock.withLock { self._metadata = newValue }
self.prettyMetadata = self.prettify(self.metadata)
}
}

public subscript(metadataKey metadataKey: String) -> Logger.Metadata.Value? {
get {
return self.lock.withLock { self._metadata[metadataKey] }
return self.metadata[metadataKey]
}
set {
self.lock.withLock {
self._metadata[metadataKey] = newValue
}
self.metadata[metadataKey] = newValue
}
}

Expand Down

0 comments on commit 654ea6e

Please sign in to comment.