]> git.saurik.com Git - apple/security.git/blob - keychain/ckks/CKKSLogging.m
Security-59754.80.3.tar.gz
[apple/security.git] / keychain / ckks / CKKSLogging.m
1
2 #import <Foundation/Foundation.h>
3 #import "keychain/ckks/CKKS.h"
4
5 os_log_t CKKSLogObject(NSString* scope, NSString* _Nullable zoneName)
6 {
7 __block os_log_t ret = OS_LOG_DISABLED;
8
9 static dispatch_queue_t logQueue = nil;
10 static dispatch_once_t onceToken;
11 dispatch_once(&onceToken, ^{
12 logQueue = dispatch_queue_create("ckks-logger", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
13 });
14
15 static NSMutableDictionary* scopeMap = nil;
16
17 dispatch_sync(logQueue, ^{
18 if(scopeMap == nil) {
19 scopeMap = [NSMutableDictionary dictionary];
20 }
21
22 NSString* key = zoneName ? [scope stringByAppendingFormat:@"-%@", zoneName] : scope;
23
24 ret = scopeMap[key];
25
26 if(!ret) {
27 ret = os_log_create("com.apple.security.ckks", [key cStringUsingEncoding:NSUTF8StringEncoding]);
28 scopeMap[key] = ret;
29 }
30 });
31
32 return ret;
33 }