summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLLogFileModule.h
blob: aaad78470398ca1189cef7976dc59e1769e2f318 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
//  SDLLogFileModule.h
//  SmartDeviceLink-iOS
//
//  Created by Joel Fischer on 2/27/17.
//  Copyright © 2017 smartdevicelink. All rights reserved.
//

#import <Foundation/Foundation.h>

#import "SDLLogConstants.h"


NS_ASSUME_NONNULL_BEGIN

@interface SDLLogFileModule : NSObject

/**
 The name of the this module, e.g. "Transport"
 */
@property (copy, nonatomic, readonly) NSString *name;

/**
 All of the files contained within this module. When a log is logged, the `__FILE__` (in Obj-C) or `#file` (in Swift) is automatically captured and checked to see if any module has a file in this set that matches. If it does, it will be logged using the module's log level and the module's name will be printed in the formatted log.
 */
@property (copy, nonatomic, readonly) NSSet<NSString *> *files;

/**
 The custom level of the log. This is `SDLLogLevelDefault` (whatever the current global log level is) by default.
 */
@property (assign, nonatomic) SDLLogLevel logLevel;

/**
 This method is unavailable and may not be used.

 @return Always returns nil
 */
- (instancetype)init NS_UNAVAILABLE;

/**
 Returns an initialized `SDLLogFileModule` that contains a custom name, set of files, and associated log level.

 @param name The name of this module. This will be used when printing a formatted log for a file within this module e.g. "Transport".
 @param files The files this module covers. This should correspond to a `__FILE__` or `#file` call for use when comparing a log to this module. Any log originating in a file contained in this set will then use this module's log level and print the module name.
 @param level The custom logging level logs originating in files contained in this log module will use. For example, if the global level is `SDLLogLevelError` and this module is configured to `SDLLogLevelVerbose`, all logs originating from files within this module will be logged, not merely error logs.
 @return An initialized `SDLLogFileModule`
 */
- (instancetype)initWithName:(NSString *)name files:(NSSet<NSString *> *)files level:(SDLLogLevel)level NS_DESIGNATED_INITIALIZER;

/**
 Returns an initialized `SDLLogFileModule` that contains a custom name and set of files. The logging level is the same as the current global logging file by using `SDLLogLevelDefault`.

 @param name The name of this module. This will be used when printing a formatted log for a file within this module e.g. "Transport".
 @param files The files this module covers. This should correspond to a `__FILE__` or `#file` call for use when comparing a log to this module. Any log originating in a file contained in this set will then use this module's log level and print the module name.
 @return An initialized `SDLLogFileModule`
 */
- (instancetype)initWithName:(NSString *)name files:(NSSet<NSString *> *)files;

/**
 Returns an initialized `SDLLogFileModule` that contains a custom name and set of files. The logging level is the same as the current global logging file by using `SDLLogLevelDefault`.

 @param name The name of this module. This will be used when printing a formatted log for a file within this module e.g. "Transport".
 @param files The files this module covers. This should correspond to a `__FILE__` or `#file` call for use when comparing a log to this module. Any log originating in a file contained in this set will then use this module's log level and print the module name.
 @return An initialized `SDLLogFileModule`
 */
+ (instancetype)moduleWithName:(NSString *)name files:(NSSet<NSString *> *)files;

/**
 Returns whether or not this module contains a given file.

 @param fileName The file name to check
 @return A BOOL, YES if this module contains the given file.
 */
- (BOOL)containsFile:(NSString *)fileName;

@end

NS_ASSUME_NONNULL_END