VLCKit
VLCLogging.h
1 /*****************************************************************************
2  * VLCLogging.h: [Mobile/TV]VLCKit.framework VLCLogging header
3  *****************************************************************************
4  * Copyright (C) 2022 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Authors: Maxime Chapelet <umxprime # videolabs.io>
8  *
9  * This program is free software; you can redistribute it and/or modify it
10  * under the terms of the GNU Lesser General Public License as published by
11  * the Free Software Foundation; either version 2.1 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23 
24 #ifndef VLCLogging_h
25 #define VLCLogging_h
26 
27 NS_ASSUME_NONNULL_BEGIN
28 
33 typedef NS_ENUM(int, VLCLogLevel) {
34  kVLCLogLevelError = 0,
35  kVLCLogLevelWarning,
36  kVLCLogLevelInfo,
37  kVLCLogLevelDebug
38 };
39 
43 @interface VLCLogContext: NSObject
47 @property (nonatomic, readonly) uintptr_t objectId;
48 
52 @property (nonatomic, readonly) NSString *objectType;
53 
57 @property (nonatomic, readonly) NSString *module;
58 
62 @property (nonatomic, readonly, nullable) NSString *header;
63 
67 @property (nonatomic, readonly, nullable) NSString *file;
68 
72 @property (nonatomic, readonly) int line;
73 
77 @property (nonatomic, readonly, nullable) NSString *function;
78 
82 @property (nonatomic, readonly) unsigned long threadId;
83 
84 @end
85 
89 typedef NS_OPTIONS(int, VLCLogContextFlag) {
90  kVLCLogLevelContextNone = 0,
91  kVLCLogLevelContextModule = 1<<0,
92  kVLCLogLevelContextFileLocation = 1<<1,
93  kVLCLogLevelContextCallingFunction = 1<<2,
94  kVLCLogLevelContextCustom = 1<<3,
95  kVLCLogLevelContextAll = 0xF
96 };
97 
103 @protocol VLCLogMessageFormatting <NSObject>
104 
109 @property (readwrite, nonatomic) VLCLogContextFlag contextFlags;
110 
117 @property (readwrite, nonatomic, nullable) id customContext;
118 
119 @required
124 - (NSString *)formatWithMessage:(NSString *)message
125  logLevel:(VLCLogLevel)level
126  context:(nullable VLCLogContext *)context;
127 
128 @end
129 
134 @protocol VLCLogging <NSObject>
135 @required
140 @property (readwrite, nonatomic) VLCLogLevel level;
141 
148 - (void)handleMessage:(NSString *)message
149  logLevel:(VLCLogLevel)level
150  context:(nullable VLCLogContext *)context;
151 @end
152 
161 @required
162 
163 @property (nonatomic, readwrite) id<VLCLogMessageFormatting> formatter;
164 
165 @end
166 
167 NS_ASSUME_NONNULL_END
168 
169 #endif /* VLCLogHandler_h */
VLCLogContext::module
NSString * module
Definition: VLCLogging.h:57
VLCLogMessageFormatting-p::customContext
id customContext
Custom infos that might be appended to log messages. \discussion Ideally the customContext object sho...
Definition: VLCLogging.h:117
VLCLogContext::file
NSString * file
Definition: VLCLogging.h:67
VLCLogContext::threadId
unsigned long threadId
Definition: VLCLogging.h:82
VLCLogContext::header
NSString * header
Definition: VLCLogging.h:62
VLCLogContext
Definition: VLCLogging.h:43
VLCFormattedMessageLogging-p
Protocol implemented by any logger that use a formatter.
Definition: VLCLogging.h:160
VLCLogMessageFormatting-p
Protocol implemented by any object that may format log messages with their context \discussion Its us...
Definition: VLCLogging.h:103
VLCLogging-p::level
VLCLogLevel level
Gets/sets this to filter in/out messages to handle.
Definition: VLCLogging.h:140
VLCLogContext::line
int line
Definition: VLCLogging.h:72
VLCLogContext::objectType
NSString * objectType
Definition: VLCLogging.h:52
VLCLogMessageFormatting-p::contextFlags
VLCLogContextFlag contextFlags
Enable/disable logging context options.
Definition: VLCLogging.h:109
VLCLogging-p
Protocol implemented by any logger used in -[VLCLibrary loggers].
Definition: VLCLogging.h:134
VLCLogContext::objectId
uintptr_t objectId
Definition: VLCLogging.h:47