Skip to content

Commit c306e27

Browse files
authored
Update to v2.9.0 (#22)
### 2.9.0 (08/06/2020) - Drop support for iOS 7, 8 & 9 ### 2.8.5 (07/21/2020) - Improved Swift interface ### 2.8.1 (07/01/2020) - Convert private static C functions (that take `self` as an argument) to Objective-C `direct` methods - Same low overhead, better calling syntax ### 2.8.0 (06/08/2020) - Update `initWithOutError:` to `initAndReturnError:` for `TLSRollingFileOutputStream` - More idiomatic
1 parent 76f11ad commit c306e27

31 files changed

+293
-320
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
language: objective-c
2-
osx_image: xcode11.4
2+
osx_image: xcode11.5
33
script:
44
./build.sh

CHANGELOG.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,32 @@
22

33
## Info
44

5-
**Document version:** 2.7.1
5+
**Document version:** 2.9.0
66

7-
**Last updated:** 04/12/2020
7+
**Last updated:** 08/06/2020
88

99
**Author:** Nolan O'Brien
1010

1111
## History
1212

13+
### 2.9.0 (08/06/2020)
14+
15+
- Drop support for iOS 7, 8 & 9
16+
17+
### 2.8.5 (07/21/2020)
18+
19+
- Improved Swift interface
20+
21+
### 2.8.1 (07/01/2020)
22+
23+
- Convert private static C functions (that take `self` as an argument) to Objective-C `direct` methods
24+
- Same low overhead, better calling syntax
25+
26+
### 2.8.0 (06/08/2020)
27+
28+
- Update `initWithOutError:` to `initAndReturnError:` for `TLSRollingFileOutputStream`
29+
- More idiomatic
30+
1331
### 2.7.1 (04/12/2020)
1432

1533
- Increase use of `@autoreleasepool` to keep memory management tighter

Classes/TLSConsoleOutputStreams.m

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,10 @@
2020
#import "TLSConsoleOutputStreams.h"
2121
#import "TLSLog.h"
2222

23-
#if TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000
23+
#if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_MAC
2424
#define OS_LOG_AVAILABLE 1
25-
#elif TARGET_OS_TV && __TV_OS_VERSION_MAX_ALLOWED >= 100000
26-
#define OS_LOG_AVAILABLE 1
27-
#elif TARGET_OS_WATCH && __WATCH_OS_VERSION_MAX_ALLOWED >= 30000
25+
#elif TARGET_OS_WATCH
2826
#define OS_LOG_AVAILABLE 0 // not on watch
29-
#elif TARGET_OS_MAC && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200
30-
#define OS_LOG_AVAILABLE 1
3127
#else
3228
#define OS_LOG_AVAILABLE 0
3329
#endif
@@ -77,9 +73,7 @@ + (BOOL)supported
7773
#if OS_LOG_AVAILABLE
7874

7975
#if !TARGET_OS_WATCH
80-
if (@available(iOS 10, tvOS 10, macOS 10.12, *)) {
81-
return YES;
82-
}
76+
return YES;
8377
#endif
8478

8579
#endif // OS_LOG_AVAILABLE

Classes/TLSDeclarations.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#pragma mark - Constants
2323

2424
/** Domain for errors stemming from TwitterLoggingService APIs */
25-
FOUNDATION_EXTERN NSString * __nonnull const TLSErrorDomain;
25+
FOUNDATION_EXTERN NSErrorDomain __nonnull const TLSErrorDomain;
2626

2727
/** Pull out an name for the current thread or `nil` if no name was identified */
2828
FOUNDATION_EXTERN NSString * __nullable TLSCurrentThreadName(void);
@@ -40,7 +40,7 @@ FOUNDATION_EXTERN NSString * __nullable TLSCurrentThreadName(void);
4040
FOUNDATION_EXTERN NSString *TLSLogLevelToString(TLSLogLevel level);
4141
4242
*/
43-
typedef NS_ENUM(NSUInteger, TLSLogLevel)
43+
typedef NS_ENUM(NSInteger, TLSLogLevel)
4444
{
4545
/** Present for syslog compatability */
4646
TLSLogLevelEmergency = 0,
@@ -61,7 +61,7 @@ typedef NS_ENUM(NSUInteger, TLSLogLevel)
6161
};
6262

6363
//! Number of log levels
64-
static const NSUInteger TLSLogLevelCount = TLSLogLevelDebug + 1;
64+
static const NSInteger TLSLogLevelCount = TLSLogLevelDebug + 1;
6565

6666
/**
6767
A set of flags that can be used to identify specific log levels in one mask.
@@ -112,9 +112,9 @@ typedef NS_OPTIONS(NSInteger, TLSLogLevelMask)
112112
/** Advanced options for logging a message */
113113
typedef NS_OPTIONS(NSInteger, TLSLogMessageOptions) {
114114
/** no options (default behavior) */
115-
TLSLogMessageNoOptions = 0,
115+
TLSLogMessageOptionsNone = 0,
116116
/** ignore the `[TLSLoggingService maximumSafeMessageLength]` capping of the message */
117-
TLSLogMessageIgnoringMaximumSafeMessageLength = 1 << 0,
117+
TLSLogMessageOptionsIgnoringMaximumSafeMessageLength = 1 << 0,
118118
};
119119

120120
/**

Classes/TLSDeclarations.m

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#import <TwitterLoggingService/TLSDeclarations.h>
2424
#import <TwitterLoggingService/TLSLog.h>
2525

26-
NSString * const TLSErrorDomain = @"TLSErrorDomain";
26+
NSErrorDomain const TLSErrorDomain = @"TLSErrorDomain";
2727

2828
@implementation TLSLogMessageInfo
2929
{
@@ -87,7 +87,7 @@ - (NSString *)composeFormattedMessageWithOptions:(TLSComposeLogMessageInfoOption
8787
// TIMESTAMP
8888
{
8989
NSString *logTimestamp = nil;
90-
if (options & TLSComposeLogMessageInfoLogTimestampAsTimeSinceLoggingStarted) {
90+
if (TLS_BITMASK_INTERSECTS_FLAGS(options, TLSComposeLogMessageInfoLogTimestampAsTimeSinceLoggingStarted)) {
9191
NSTimeInterval logLifespan = self.logLifespan;
9292
const BOOL negative = logLifespan < 0.0;
9393
if (negative) {
@@ -108,7 +108,7 @@ - (NSString *)composeFormattedMessageWithOptions:(TLSComposeLogMessageInfoOption
108108
minutes,
109109
seconds,
110110
msecs];
111-
} else if (options & TLSComposeLogMessageInfoLogTimestampAsLocalTime) {
111+
} else if (TLS_BITMASK_INTERSECTS_FLAGS(options, TLSComposeLogMessageInfoLogTimestampAsLocalTime)) {
112112
static NSDateFormatter *sFormatter = nil;
113113
static dispatch_once_t onceToken;
114114
dispatch_once(&onceToken, ^{
@@ -117,7 +117,7 @@ - (NSString *)composeFormattedMessageWithOptions:(TLSComposeLogMessageInfoOption
117117
sFormatter.timeZone = [NSTimeZone localTimeZone];
118118
});
119119
logTimestamp = [sFormatter stringFromDate:self.timestamp];
120-
} else if (options & TLSComposeLogMessageInfoLogTimestampAsUTCTime) {
120+
} else if (TLS_BITMASK_INTERSECTS_FLAGS(options, TLSComposeLogMessageInfoLogTimestampAsUTCTime)) {
121121
static NSDateFormatter *sFormatter = nil;
122122
static dispatch_once_t onceToken;
123123
dispatch_once(&onceToken, ^{
@@ -134,38 +134,39 @@ - (NSString *)composeFormattedMessageWithOptions:(TLSComposeLogMessageInfoOption
134134
}
135135

136136
// THREAD
137-
if (options & TLSComposeLogMessageInfoLogThreadId || options & TLSComposeLogMessageInfoLogThreadName) {
137+
if (TLS_BITMASK_INTERSECTS_FLAGS(options, TLSComposeLogMessageInfoLogThreadId | TLSComposeLogMessageInfoLogThreadName)) {
138138
[mComposedMessage appendString:@"["];
139139
NSString *threadName = self.threadName;
140-
const BOOL hasName = (options & TLSComposeLogMessageInfoLogThreadName && threadName != nil);
140+
const BOOL hasName = TLS_BITMASK_INTERSECTS_FLAGS(options, TLSComposeLogMessageInfoLogThreadName)
141+
&& (threadName != nil);
141142
if (hasName) {
142143
[mComposedMessage appendString:threadName];
143144
}
144-
if (options & TLSComposeLogMessageInfoLogThreadId) {
145+
if (TLS_BITMASK_INTERSECTS_FLAGS(options, TLSComposeLogMessageInfoLogThreadId)) {
145146
[mComposedMessage appendFormat:(hasName) ? @"(0x%x)" : @"0x%x", self.threadId];
146147
}
147148
[mComposedMessage appendString:@"]"];
148149
}
149150

150151
// CHANNEL
151-
if (options & TLSComposeLogMessageInfoLogChannel) {
152+
if (TLS_BITMASK_INTERSECTS_FLAGS(options, TLSComposeLogMessageInfoLogChannel)) {
152153
[mComposedMessage appendFormat:@"[%@]", self.channel];
153154
}
154155

155156
// LEVEL
156-
if (options & TLSComposeLogMessageInfoLogLevel) {
157+
if (TLS_BITMASK_INTERSECTS_FLAGS(options, TLSComposeLogMessageInfoLogLevel)) {
157158
[mComposedMessage appendFormat:@"[%@]", TLSLogLevelToString(level)];
158159
}
159160

160161
// Call Site Info
161-
if ((options & TLSComposeLogMessageInfoLogCallsiteInfoAlways) || ((options & TLSComposeLogMessageInfoLogCallsiteInfoForWarnings) && level <= TLSLogLevelWarning)) {
162+
if (TLS_BITMASK_INTERSECTS_FLAGS(options, TLSComposeLogMessageInfoLogCallsiteInfoAlways | TLSComposeLogMessageInfoLogCallsiteInfoForWarnings) && level <= TLSLogLevelWarning) {
162163
[mComposedMessage appendString:[self composeFileFunctionLineString]];
163164
}
164165

165166
[mComposedMessage appendFormat:@" : %@", self.message];
166167

167168
composedMessage = [mComposedMessage copy];
168-
if (0 == (options & TLSComposeLogMessageInfoDoNotCache)) {
169+
if (TLS_BITMASK_EXCLUDES_FLAGS(options, TLSComposeLogMessageInfoDoNotCache)) {
169170
if (!_formattedMessages) {
170171
_formattedMessages = @{ optionsKey : composedMessage };
171172
} else {

Classes/TLSFileOutputStream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ NS_ASSUME_NONNULL_BEGIN
132132
/**
133133
Reset the log and clear it
134134
*/
135-
- (BOOL)resetAndReturnError:(out NSError * __nullable * __nullable)error;
135+
- (BOOL)resetAndReturnError:(out NSError * __nullable __autoreleasing * __nullable)error;
136136

137137
#pragma mark TLSOutputStream
138138

Classes/TLSLog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ NS_ASSUME_NONNULL_BEGIN
5151
//! Root Macro. Provide the _level_, _channel_ and format string.
5252
#define TLSLog(level, channel, ...) \
5353
if (TLSCanLog(nil, level, channel, nil)) { \
54-
TLSLogEx(nil, level, channel, @(__FILE__), @(__PRETTY_FUNCTION__), __LINE__, nil, TLSLogMessageNoOptions, __VA_ARGS__); \
54+
TLSLogEx(nil, level, channel, @(__FILE__), @(__PRETTY_FUNCTION__), __LINE__, nil, TLSLogMessageOptionsNone, __VA_ARGS__); \
5555
}
5656

5757
//! Log to Error level

Classes/TLSLog.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ public class TLSLog {
3131

3232
See also: `TLSLogError`, `TLSLogWarning`, `TLSLogInformation` and `TLSLogDebug`
3333
*/
34-
public final class func log(_ level: TLSLogLevel,
34+
public final class func log(service: TLSLoggingService? = nil,
35+
_ level: TLSLogLevel,
3536
_ channel: String,
3637
_ context: Any?,
3738
_ message: @autoclosure () -> String,
@@ -40,11 +41,11 @@ public class TLSLog {
4041
function: StaticString = #function,
4142
line: Int = #line)
4243
{
43-
if (!TLSCanLog(nil, level, channel, context)) {
44+
if (!TLSCanLog(service, level, channel, context)) {
4445
return
4546
}
4647

47-
TLSLogString(nil,
48+
TLSLogString(service,
4849
level,
4950
channel,
5051
String(describing: file),

Classes/TLSLoggingService+Advanced.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ NS_ASSUME_NONNULL_BEGIN
6767
synchronously execute the given block on the `TLSLoggingService` instance's transaction queue.
6868
Don't muck with `TLSLoggingService` or other queues/threads from within the _block_.
6969
*/
70-
- (void)dispatchSynchronousTransaction:(dispatch_block_t)block;
70+
- (void)dispatchSynchronousTransaction:(dispatch_block_t NS_NOESCAPE)block;
7171
/**
7272
asynchronously execute the given block on the `TLSLoggingService` intances's transaction queue.
7373
Don't muck with `TLSLoggingService` or other queues/threads from within the _block_.

0 commit comments

Comments
 (0)