1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/crashreporter/google-breakpad/src/common/mac/GTMLogger.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,504 @@ 1.4 +// 1.5 +// GTMLogger.h 1.6 +// 1.7 +// Copyright 2007-2008 Google Inc. 1.8 +// 1.9 +// Licensed under the Apache License, Version 2.0 (the "License"); you may not 1.10 +// use this file except in compliance with the License. You may obtain a copy 1.11 +// of the License at 1.12 +// 1.13 +// http://www.apache.org/licenses/LICENSE-2.0 1.14 +// 1.15 +// Unless required by applicable law or agreed to in writing, software 1.16 +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 1.17 +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 1.18 +// License for the specific language governing permissions and limitations under 1.19 +// the License. 1.20 +// 1.21 + 1.22 +// Key Abstractions 1.23 +// ---------------- 1.24 +// 1.25 +// This file declares multiple classes and protocols that are used by the 1.26 +// GTMLogger logging system. The 4 main abstractions used in this file are the 1.27 +// following: 1.28 +// 1.29 +// * logger (GTMLogger) - The main logging class that users interact with. It 1.30 +// has methods for logging at different levels and uses a log writer, a log 1.31 +// formatter, and a log filter to get the job done. 1.32 +// 1.33 +// * log writer (GTMLogWriter) - Writes a given string to some log file, where 1.34 +// a "log file" can be a physical file on disk, a POST over HTTP to some URL, 1.35 +// or even some in-memory structure (e.g., a ring buffer). 1.36 +// 1.37 +// * log formatter (GTMLogFormatter) - Given a format string and arguments as 1.38 +// a va_list, returns a single formatted NSString. A "formatted string" could 1.39 +// be a string with the date prepended, a string with values in a CSV format, 1.40 +// or even a string of XML. 1.41 +// 1.42 +// * log filter (GTMLogFilter) - Given a formatted log message as an NSString 1.43 +// and the level at which the message is to be logged, this class will decide 1.44 +// whether the given message should be logged or not. This is a flexible way 1.45 +// to filter out messages logged at a certain level, messages that contain 1.46 +// certain text, or filter nothing out at all. This gives the caller the 1.47 +// flexibility to dynamically enable debug logging in Release builds. 1.48 +// 1.49 +// This file also declares some classes to handle the common log writer, log 1.50 +// formatter, and log filter cases. Callers can also create their own writers, 1.51 +// formatters, and filters and they can even build them on top of the ones 1.52 +// declared here. Keep in mind that your custom writer/formatter/filter may be 1.53 +// called from multiple threads, so it must be thread-safe. 1.54 + 1.55 +#import <Foundation/Foundation.h> 1.56 +#import "GTMDefines.h" 1.57 + 1.58 +// Predeclaration of used protocols that are declared later in this file. 1.59 +@protocol GTMLogWriter, GTMLogFormatter, GTMLogFilter; 1.60 + 1.61 +// GTMLogger 1.62 +// 1.63 +// GTMLogger is the primary user-facing class for an object-oriented logging 1.64 +// system. It is built on the concept of log formatters (GTMLogFormatter), log 1.65 +// writers (GTMLogWriter), and log filters (GTMLogFilter). When a message is 1.66 +// sent to a GTMLogger to log a message, the message is formatted using the log 1.67 +// formatter, then the log filter is consulted to see if the message should be 1.68 +// logged, and if so, the message is sent to the log writer to be written out. 1.69 +// 1.70 +// GTMLogger is intended to be a flexible and thread-safe logging solution. Its 1.71 +// flexibility comes from the fact that GTMLogger instances can be customized 1.72 +// with user defined formatters, filters, and writers. And these writers, 1.73 +// filters, and formatters can be combined, stacked, and customized in arbitrary 1.74 +// ways to suit the needs at hand. For example, multiple writers can be used at 1.75 +// the same time, and a GTMLogger instance can even be used as another 1.76 +// GTMLogger's writer. This allows for arbitrarily deep logging trees. 1.77 +// 1.78 +// A standard GTMLogger uses a writer that sends messages to standard out, a 1.79 +// formatter that smacks a timestamp and a few other bits of interesting 1.80 +// information on the message, and a filter that filters out debug messages from 1.81 +// release builds. Using the standard log settings, a log message will look like 1.82 +// the following: 1.83 +// 1.84 +// 2007-12-30 10:29:24.177 myapp[4588/0xa07d0f60] [lvl=1] foo=<Foo: 0x123> 1.85 +// 1.86 +// The output contains the date and time of the log message, the name of the 1.87 +// process followed by its process ID/thread ID, the log level at which the 1.88 +// message was logged (in the previous example the level was 1: 1.89 +// kGTMLoggerLevelDebug), and finally, the user-specified log message itself (in 1.90 +// this case, the log message was @"foo=%@", foo). 1.91 +// 1.92 +// Multiple instances of GTMLogger can be created, each configured their own 1.93 +// way. Though GTMLogger is not a singleton (in the GoF sense), it does provide 1.94 +// access to a shared (i.e., globally accessible) GTMLogger instance. This makes 1.95 +// it convenient for all code in a process to use the same GTMLogger instance. 1.96 +// The shared GTMLogger instance can also be configured in an arbitrary, and 1.97 +// these configuration changes will affect all code that logs through the shared 1.98 +// instance. 1.99 + 1.100 +// 1.101 +// Log Levels 1.102 +// ---------- 1.103 +// GTMLogger has 3 different log levels: Debug, Info, and Error. GTMLogger 1.104 +// doesn't take any special action based on the log level; it simply forwards 1.105 +// this information on to formatters, filters, and writers, each of which may 1.106 +// optionally take action based on the level. Since log level filtering is 1.107 +// performed at runtime, log messages are typically not filtered out at compile 1.108 +// time. The exception to this rule is that calls to the GTMLoggerDebug() macro 1.109 +// *ARE* filtered out of non-DEBUG builds. This is to be backwards compatible 1.110 +// with behavior that many developers are currently used to. Note that this 1.111 +// means that GTMLoggerDebug(@"hi") will be compiled out of Release builds, but 1.112 +// [[GTMLogger sharedLogger] logDebug:@"hi"] will NOT be compiled out. 1.113 +// 1.114 +// Standard loggers are created with the GTMLogLevelFilter log filter, which 1.115 +// filters out certain log messages based on log level, and some other settings. 1.116 +// 1.117 +// In addition to the -logDebug:, -logInfo:, and -logError: methods defined on 1.118 +// GTMLogger itself, there are also C macros that make usage of the shared 1.119 +// GTMLogger instance very convenient. These macros are: 1.120 +// 1.121 +// GTMLoggerDebug(...) 1.122 +// GTMLoggerInfo(...) 1.123 +// GTMLoggerError(...) 1.124 +// 1.125 +// Again, a notable feature of these macros is that GTMLogDebug() calls *will be 1.126 +// compiled out of non-DEBUG builds*. 1.127 +// 1.128 +// Standard Loggers 1.129 +// ---------------- 1.130 +// GTMLogger has the concept of "standard loggers". A standard logger is simply 1.131 +// a logger that is pre-configured with some standard/common writer, formatter, 1.132 +// and filter combination. Standard loggers are created using the creation 1.133 +// methods beginning with "standard". The alternative to a standard logger is a 1.134 +// regular logger, which will send messages to stdout, with no special 1.135 +// formatting, and no filtering. 1.136 +// 1.137 +// How do I use GTMLogger? 1.138 +// ---------------------- 1.139 +// The typical way you will want to use GTMLogger is to simply use the 1.140 +// GTMLogger*() macros for logging from code. That way we can easily make 1.141 +// changes to the GTMLogger class and simply update the macros accordingly. Only 1.142 +// your application startup code (perhaps, somewhere in main()) should use the 1.143 +// GTMLogger class directly in order to configure the shared logger, which all 1.144 +// of the code using the macros will be using. Again, this is just the typical 1.145 +// situation. 1.146 +// 1.147 +// To be complete, there are cases where you may want to use GTMLogger directly, 1.148 +// or even create separate GTMLogger instances for some reason. That's fine, 1.149 +// too. 1.150 +// 1.151 +// Examples 1.152 +// -------- 1.153 +// The following show some common GTMLogger use cases. 1.154 +// 1.155 +// 1. You want to log something as simply as possible. Also, this call will only 1.156 +// appear in debug builds. In non-DEBUG builds it will be completely removed. 1.157 +// 1.158 +// GTMLoggerDebug(@"foo = %@", foo); 1.159 +// 1.160 +// 2. The previous example is similar to the following. The major difference is 1.161 +// that the previous call (example 1) will be compiled out of Release builds 1.162 +// but this statement will not be compiled out. 1.163 +// 1.164 +// [[GTMLogger sharedLogger] logDebug:@"foo = %@", foo]; 1.165 +// 1.166 +// 3. Send all logging output from the shared logger to a file. We do this by 1.167 +// creating an NSFileHandle for writing associated with a file, and setting 1.168 +// that file handle as the logger's writer. 1.169 +// 1.170 +// NSFileHandle *f = [NSFileHandle fileHandleForWritingAtPath:@"/tmp/f.log" 1.171 +// create:YES]; 1.172 +// [[GTMLogger sharedLogger] setWriter:f]; 1.173 +// GTMLoggerError(@"hi"); // This will be sent to /tmp/f.log 1.174 +// 1.175 +// 4. Create a new GTMLogger that will log to a file. This example differs from 1.176 +// the previous one because here we create a new GTMLogger that is different 1.177 +// from the shared logger. 1.178 +// 1.179 +// GTMLogger *logger = [GTMLogger standardLoggerWithPath:@"/tmp/temp.log"]; 1.180 +// [logger logInfo:@"hi temp log file"]; 1.181 +// 1.182 +// 5. Create a logger that writes to stdout and does NOT do any formatting to 1.183 +// the log message. This might be useful, for example, when writing a help 1.184 +// screen for a command-line tool to standard output. 1.185 +// 1.186 +// GTMLogger *logger = [GTMLogger logger]; 1.187 +// [logger logInfo:@"%@ version 0.1 usage", progName]; 1.188 +// 1.189 +// 6. Send log output to stdout AND to a log file. The trick here is that 1.190 +// NSArrays function as composite log writers, which means when an array is 1.191 +// set as the log writer, it forwards all logging messages to all of its 1.192 +// contained GTMLogWriters. 1.193 +// 1.194 +// // Create array of GTMLogWriters 1.195 +// NSArray *writers = [NSArray arrayWithObjects: 1.196 +// [NSFileHandle fileHandleForWritingAtPath:@"/tmp/f.log" create:YES], 1.197 +// [NSFileHandle fileHandleWithStandardOutput], nil]; 1.198 +// 1.199 +// GTMLogger *logger = [GTMLogger standardLogger]; 1.200 +// [logger setWriter:writers]; 1.201 +// [logger logInfo:@"hi"]; // Output goes to stdout and /tmp/f.log 1.202 +// 1.203 +// For futher details on log writers, formatters, and filters, see the 1.204 +// documentation below. 1.205 +// 1.206 +// NOTE: GTMLogger is application level logging. By default it does nothing 1.207 +// with _GTMDevLog/_GTMDevAssert (see GTMDefines.h). An application can choose 1.208 +// to bridge _GTMDevLog/_GTMDevAssert to GTMLogger by providing macro 1.209 +// definitions in its prefix header (see GTMDefines.h for how one would do 1.210 +// that). 1.211 +// 1.212 +@interface GTMLogger : NSObject { 1.213 + @private 1.214 + id<GTMLogWriter> writer_; 1.215 + id<GTMLogFormatter> formatter_; 1.216 + id<GTMLogFilter> filter_; 1.217 +} 1.218 + 1.219 +// 1.220 +// Accessors for the shared logger instance 1.221 +// 1.222 + 1.223 +// Returns a shared/global standard GTMLogger instance. Callers should typically 1.224 +// use this method to get a GTMLogger instance, unless they explicitly want 1.225 +// their own instance to configure for their own needs. This is the only method 1.226 +// that returns a shared instance; all the rest return new GTMLogger instances. 1.227 ++ (id)sharedLogger; 1.228 + 1.229 +// Sets the shared logger instance to |logger|. Future calls to +sharedLogger 1.230 +// will return |logger| instead. 1.231 ++ (void)setSharedLogger:(GTMLogger *)logger; 1.232 + 1.233 +// 1.234 +// Creation methods 1.235 +// 1.236 + 1.237 +// Returns a new autoreleased GTMLogger instance that will log to stdout, using 1.238 +// the GTMLogStandardFormatter, and the GTMLogLevelFilter filter. 1.239 ++ (id)standardLogger; 1.240 + 1.241 +// Same as +standardLogger, but logs to stderr. 1.242 ++ (id)standardLoggerWithStderr; 1.243 + 1.244 +// Same as +standardLogger but levels >= kGTMLoggerLevelError are routed to 1.245 +// stderr, everything else goes to stdout. 1.246 ++ (id)standardLoggerWithStdoutAndStderr; 1.247 + 1.248 +// Returns a new standard GTMLogger instance with a log writer that will 1.249 +// write to the file at |path|, and will use the GTMLogStandardFormatter and 1.250 +// GTMLogLevelFilter classes. If |path| does not exist, it will be created. 1.251 ++ (id)standardLoggerWithPath:(NSString *)path; 1.252 + 1.253 +// Returns an autoreleased GTMLogger instance that will use the specified 1.254 +// |writer|, |formatter|, and |filter|. 1.255 ++ (id)loggerWithWriter:(id<GTMLogWriter>)writer 1.256 + formatter:(id<GTMLogFormatter>)formatter 1.257 + filter:(id<GTMLogFilter>)filter; 1.258 + 1.259 +// Returns an autoreleased GTMLogger instance that logs to stdout, with the 1.260 +// basic formatter, and no filter. The returned logger differs from the logger 1.261 +// returned by +standardLogger because this one does not do any filtering and 1.262 +// does not do any special log formatting; this is the difference between a 1.263 +// "regular" logger and a "standard" logger. 1.264 ++ (id)logger; 1.265 + 1.266 +// Designated initializer. This method returns a GTMLogger initialized with the 1.267 +// specified |writer|, |formatter|, and |filter|. See the setter methods below 1.268 +// for what values will be used if nil is passed for a parameter. 1.269 +- (id)initWithWriter:(id<GTMLogWriter>)writer 1.270 + formatter:(id<GTMLogFormatter>)formatter 1.271 + filter:(id<GTMLogFilter>)filter; 1.272 + 1.273 +// 1.274 +// Logging methods 1.275 +// 1.276 + 1.277 +// Logs a message at the debug level (kGTMLoggerLevelDebug). 1.278 +- (void)logDebug:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); 1.279 +// Logs a message at the info level (kGTMLoggerLevelInfo). 1.280 +- (void)logInfo:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); 1.281 +// Logs a message at the error level (kGTMLoggerLevelError). 1.282 +- (void)logError:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); 1.283 +// Logs a message at the assert level (kGTMLoggerLevelAssert). 1.284 +- (void)logAssert:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2); 1.285 + 1.286 + 1.287 +// 1.288 +// Accessors 1.289 +// 1.290 + 1.291 +// Accessor methods for the log writer. If the log writer is set to nil, 1.292 +// [NSFileHandle fileHandleWithStandardOutput] is used. 1.293 +- (id<GTMLogWriter>)writer; 1.294 +- (void)setWriter:(id<GTMLogWriter>)writer; 1.295 + 1.296 +// Accessor methods for the log formatter. If the log formatter is set to nil, 1.297 +// GTMLogBasicFormatter is used. This formatter will format log messages in a 1.298 +// plain printf style. 1.299 +- (id<GTMLogFormatter>)formatter; 1.300 +- (void)setFormatter:(id<GTMLogFormatter>)formatter; 1.301 + 1.302 +// Accessor methods for the log filter. If the log filter is set to nil, 1.303 +// GTMLogNoFilter is used, which allows all log messages through. 1.304 +- (id<GTMLogFilter>)filter; 1.305 +- (void)setFilter:(id<GTMLogFilter>)filter; 1.306 + 1.307 +@end // GTMLogger 1.308 + 1.309 + 1.310 +// Helper functions that are used by the convenience GTMLogger*() macros that 1.311 +// enable the logging of function names. 1.312 +@interface GTMLogger (GTMLoggerMacroHelpers) 1.313 +- (void)logFuncDebug:(const char *)func msg:(NSString *)fmt, ... 1.314 + NS_FORMAT_FUNCTION(2, 3); 1.315 +- (void)logFuncInfo:(const char *)func msg:(NSString *)fmt, ... 1.316 + NS_FORMAT_FUNCTION(2, 3); 1.317 +- (void)logFuncError:(const char *)func msg:(NSString *)fmt, ... 1.318 + NS_FORMAT_FUNCTION(2, 3); 1.319 +- (void)logFuncAssert:(const char *)func msg:(NSString *)fmt, ... 1.320 + NS_FORMAT_FUNCTION(2, 3); 1.321 +@end // GTMLoggerMacroHelpers 1.322 + 1.323 + 1.324 +// The convenience macros are only defined if they haven't already been defined. 1.325 +#ifndef GTMLoggerInfo 1.326 + 1.327 +// Convenience macros that log to the shared GTMLogger instance. These macros 1.328 +// are how users should typically log to GTMLogger. Notice that GTMLoggerDebug() 1.329 +// calls will be compiled out of non-Debug builds. 1.330 +#define GTMLoggerDebug(...) \ 1.331 + [[GTMLogger sharedLogger] logFuncDebug:__func__ msg:__VA_ARGS__] 1.332 +#define GTMLoggerInfo(...) \ 1.333 + [[GTMLogger sharedLogger] logFuncInfo:__func__ msg:__VA_ARGS__] 1.334 +#define GTMLoggerError(...) \ 1.335 + [[GTMLogger sharedLogger] logFuncError:__func__ msg:__VA_ARGS__] 1.336 +#define GTMLoggerAssert(...) \ 1.337 + [[GTMLogger sharedLogger] logFuncAssert:__func__ msg:__VA_ARGS__] 1.338 + 1.339 +// If we're not in a debug build, remove the GTMLoggerDebug statements. This 1.340 +// makes calls to GTMLoggerDebug "compile out" of Release builds 1.341 +#ifndef DEBUG 1.342 +#undef GTMLoggerDebug 1.343 +#define GTMLoggerDebug(...) do {} while(0) 1.344 +#endif 1.345 + 1.346 +#endif // !defined(GTMLoggerInfo) 1.347 + 1.348 +// Log levels. 1.349 +typedef enum { 1.350 + kGTMLoggerLevelUnknown, 1.351 + kGTMLoggerLevelDebug, 1.352 + kGTMLoggerLevelInfo, 1.353 + kGTMLoggerLevelError, 1.354 + kGTMLoggerLevelAssert, 1.355 +} GTMLoggerLevel; 1.356 + 1.357 + 1.358 +// 1.359 +// Log Writers 1.360 +// 1.361 + 1.362 +// Protocol to be implemented by a GTMLogWriter instance. 1.363 +@protocol GTMLogWriter <NSObject> 1.364 +// Writes the given log message to where the log writer is configured to write. 1.365 +- (void)logMessage:(NSString *)msg level:(GTMLoggerLevel)level; 1.366 +@end // GTMLogWriter 1.367 + 1.368 + 1.369 +// Simple category on NSFileHandle that makes NSFileHandles valid log writers. 1.370 +// This is convenient because something like, say, +fileHandleWithStandardError 1.371 +// now becomes a valid log writer. Log messages are written to the file handle 1.372 +// with a newline appended. 1.373 +@interface NSFileHandle (GTMFileHandleLogWriter) <GTMLogWriter> 1.374 +// Opens the file at |path| in append mode, and creates the file with |mode| 1.375 +// if it didn't previously exist. 1.376 ++ (id)fileHandleForLoggingAtPath:(NSString *)path mode:(mode_t)mode; 1.377 +@end // NSFileHandle 1.378 + 1.379 + 1.380 +// This category makes NSArray a GTMLogWriter that can be composed of other 1.381 +// GTMLogWriters. This is the classic Composite GoF design pattern. When the 1.382 +// GTMLogWriter -logMessage:level: message is sent to the array, the array 1.383 +// forwards the message to all of its elements that implement the GTMLogWriter 1.384 +// protocol. 1.385 +// 1.386 +// This is useful in situations where you would like to send log output to 1.387 +// multiple log writers at the same time. Simply create an NSArray of the log 1.388 +// writers you wish to use, then set the array as the "writer" for your 1.389 +// GTMLogger instance. 1.390 +@interface NSArray (GTMArrayCompositeLogWriter) <GTMLogWriter> 1.391 +@end // GTMArrayCompositeLogWriter 1.392 + 1.393 + 1.394 +// This category adapts the GTMLogger interface so that it can be used as a log 1.395 +// writer; it's an "adapter" in the GoF Adapter pattern sense. 1.396 +// 1.397 +// This is useful when you want to configure a logger to log to a specific 1.398 +// writer with a specific formatter and/or filter. But you want to also compose 1.399 +// that with a different log writer that may have its own formatter and/or 1.400 +// filter. 1.401 +@interface GTMLogger (GTMLoggerLogWriter) <GTMLogWriter> 1.402 +@end // GTMLoggerLogWriter 1.403 + 1.404 + 1.405 +// 1.406 +// Log Formatters 1.407 +// 1.408 + 1.409 +// Protocol to be implemented by a GTMLogFormatter instance. 1.410 +@protocol GTMLogFormatter <NSObject> 1.411 +// Returns a formatted string using the format specified in |fmt| and the va 1.412 +// args specified in |args|. 1.413 +- (NSString *)stringForFunc:(NSString *)func 1.414 + withFormat:(NSString *)fmt 1.415 + valist:(va_list)args 1.416 + level:(GTMLoggerLevel)level NS_FORMAT_FUNCTION(2, 0); 1.417 +@end // GTMLogFormatter 1.418 + 1.419 + 1.420 +// A basic log formatter that formats a string the same way that NSLog (or 1.421 +// printf) would. It does not do anything fancy, nor does it add any data of its 1.422 +// own. 1.423 +@interface GTMLogBasicFormatter : NSObject <GTMLogFormatter> 1.424 + 1.425 +// Helper method for prettying C99 __func__ and GCC __PRETTY_FUNCTION__ 1.426 +- (NSString *)prettyNameForFunc:(NSString *)func; 1.427 + 1.428 +@end // GTMLogBasicFormatter 1.429 + 1.430 + 1.431 +// A log formatter that formats the log string like the basic formatter, but 1.432 +// also prepends a timestamp and some basic process info to the message, as 1.433 +// shown in the following sample output. 1.434 +// 2007-12-30 10:29:24.177 myapp[4588/0xa07d0f60] [lvl=1] log mesage here 1.435 +@interface GTMLogStandardFormatter : GTMLogBasicFormatter { 1.436 + @private 1.437 + NSDateFormatter *dateFormatter_; // yyyy-MM-dd HH:mm:ss.SSS 1.438 + NSString *pname_; 1.439 + pid_t pid_; 1.440 +} 1.441 +@end // GTMLogStandardFormatter 1.442 + 1.443 + 1.444 +// 1.445 +// Log Filters 1.446 +// 1.447 + 1.448 +// Protocol to be imlemented by a GTMLogFilter instance. 1.449 +@protocol GTMLogFilter <NSObject> 1.450 +// Returns YES if |msg| at |level| should be filtered out; NO otherwise. 1.451 +- (BOOL)filterAllowsMessage:(NSString *)msg level:(GTMLoggerLevel)level; 1.452 +@end // GTMLogFilter 1.453 + 1.454 + 1.455 +// A log filter that filters messages at the kGTMLoggerLevelDebug level out of 1.456 +// non-debug builds. Messages at the kGTMLoggerLevelInfo level are also filtered 1.457 +// out of non-debug builds unless GTMVerboseLogging is set in the environment or 1.458 +// the processes's defaults. Messages at the kGTMLoggerLevelError level are 1.459 +// never filtered. 1.460 +@interface GTMLogLevelFilter : NSObject <GTMLogFilter> 1.461 +@end // GTMLogLevelFilter 1.462 + 1.463 +// A simple log filter that does NOT filter anything out; 1.464 +// -filterAllowsMessage:level will always return YES. This can be a convenient 1.465 +// way to enable debug-level logging in release builds (if you so desire). 1.466 +@interface GTMLogNoFilter : NSObject <GTMLogFilter> 1.467 +@end // GTMLogNoFilter 1.468 + 1.469 + 1.470 +// Base class for custom level filters. Not for direct use, use the minimum 1.471 +// or maximum level subclasses below. 1.472 +@interface GTMLogAllowedLevelFilter : NSObject <GTMLogFilter> { 1.473 + @private 1.474 + NSIndexSet *allowedLevels_; 1.475 +} 1.476 +@end 1.477 + 1.478 +// A log filter that allows you to set a minimum log level. Messages below this 1.479 +// level will be filtered. 1.480 +@interface GTMLogMininumLevelFilter : GTMLogAllowedLevelFilter 1.481 + 1.482 +// Designated initializer, logs at levels < |level| will be filtered. 1.483 +- (id)initWithMinimumLevel:(GTMLoggerLevel)level; 1.484 + 1.485 +@end 1.486 + 1.487 +// A log filter that allows you to set a maximum log level. Messages whose level 1.488 +// exceeds this level will be filtered. This is really only useful if you have 1.489 +// a composite GTMLogger that is sending the other messages elsewhere. 1.490 +@interface GTMLogMaximumLevelFilter : GTMLogAllowedLevelFilter 1.491 + 1.492 +// Designated initializer, logs at levels > |level| will be filtered. 1.493 +- (id)initWithMaximumLevel:(GTMLoggerLevel)level; 1.494 + 1.495 +@end 1.496 + 1.497 + 1.498 +// For subclasses only 1.499 +@interface GTMLogger (PrivateMethods) 1.500 + 1.501 +- (void)logInternalFunc:(const char *)func 1.502 + format:(NSString *)fmt 1.503 + valist:(va_list)args 1.504 + level:(GTMLoggerLevel)level NS_FORMAT_FUNCTION(2, 0); 1.505 + 1.506 +@end 1.507 +