Skip to content

Commit

Permalink
Merge branch 'release/1.5.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
rakuyoMo committed Sep 9, 2021
2 parents 3a124ff + 0613bc1 commit f09c1fc
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 44 deletions.
12 changes: 6 additions & 6 deletions RaLog.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 202011231319;
CURRENT_PROJECT_VERSION = 202109091121;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = AP85W7ZKHS;
DEVELOPMENT_TEAM = 5C9JW4S9DE;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -402,7 +402,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.5.1;
MARKETING_VERSION = 1.5.2;
PRODUCT_BUNDLE_IDENTIFIER = com.rakuyo.RaLog;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand All @@ -415,9 +415,9 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 202011231319;
CURRENT_PROJECT_VERSION = 202109091121;
DEFINES_MODULE = YES;
DEVELOPMENT_TEAM = AP85W7ZKHS;
DEVELOPMENT_TEAM = 5C9JW4S9DE;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
Expand All @@ -429,7 +429,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 1.5.1;
MARKETING_VERSION = 1.5.2;
PRODUCT_BUNDLE_IDENTIFIER = com.rakuyo.RaLog;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down
28 changes: 24 additions & 4 deletions Sources/RaLog/Filterable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,20 @@ public extension Filterable {

// MARK: Flag

private let flagLock = NSLock()

public extension Filterable {
static var filteredFlags: Set<Log.Flag> {
get { Wrapper.shared.filteredFlags }
set { Wrapper.shared.filteredFlags = newValue }
get {
flagLock.lock()
defer { flagLock.unlock() }
return Wrapper.shared.filteredFlags
}
set {
flagLock.lock()
defer { flagLock.unlock() }
Wrapper.shared.filteredFlags = newValue
}
}

static func addFilter(flag: Log.Flag ...) {
Expand All @@ -87,10 +97,20 @@ public extension Filterable {

// MARK: File

private let fileLock = NSLock()

public extension Filterable {
static var filteredFiles: Set<String> {
get { Wrapper.shared.filteredFiles }
set { Wrapper.shared.filteredFiles = newValue }
get {
fileLock.lock()
defer { fileLock.unlock() }
return Wrapper.shared.filteredFiles
}
set {
fileLock.lock()
defer { fileLock.unlock() }
Wrapper.shared.filteredFiles = newValue
}
}

static func fileterCurrentFileLogs(_ file: String = #file) {
Expand Down
17 changes: 13 additions & 4 deletions Sources/RaLog/Storable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,20 @@ public extension Storable {

// MARK: - Default

private let logsLock = NSLock()

public extension Storable {

static var logs: [LogModelProtocol] {
get { Wrapper.shared.logs }
set { Wrapper.shared.logs = newValue }
static var logs: [LogModelProtocol] {
get {
logsLock.lock()
defer { logsLock.unlock() }
return Wrapper.shared.logs
}
set {
logsLock.lock()
defer { logsLock.unlock() }
Wrapper.shared.logs = newValue
}
}

static var storageMode: StorageMode { .all }
Expand Down
30 changes: 0 additions & 30 deletions Sources/RaLog/Wrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ class Wrapper {
/// Singleton object
static let shared = Wrapper()

@Atomic
var logs: [LogModelProtocol] = []

@Atomic
var filteredFlags = Set<Log.Flag>()

@Atomic
var filteredFiles = Set<String>()

let cacheDateFormatter = DateFormatter()
Expand All @@ -28,30 +25,3 @@ class Wrapper {
cacheDateFormatter.dateFormat = "yyyy_MM_dd"
}
}

@propertyWrapper
struct Atomic<Value> {
private var value: Value
private let lock = NSLock()

init(wrappedValue value: Value) {
self.value = value
}

var wrappedValue: Value {
get { return load() }
set { store(newValue: newValue) }
}

func load() -> Value {
lock.lock()
defer { lock.unlock() }
return value
}

mutating func store(newValue: Value) {
lock.lock()
defer { lock.unlock() }
value = newValue
}
}

0 comments on commit f09c1fc

Please sign in to comment.