Lines Matching +full:log +full:-
4 // Copyright 2007-2008 Google Inc.
10 // http://www.apache.org/licenses/LICENSE-2.0
20 // ----------------
26 // * logger (GTMLogger) - The main logging class that users interact with. It
27 // has methods for logging at different levels and uses a log writer, a log
28 // formatter, and a log filter to get the job done.
30 // * log writer (GTMLogWriter) - Writes a given string to some log file, where
31 // a "log file" can be a physical file on disk, a POST over HTTP to some URL,
32 // or even some in-memory structure (e.g., a ring buffer).
34 // * log formatter (GTMLogFormatter) - Given a format string and arguments as
39 // * log filter (GTMLogFilter) - Given a formatted log message as an NSString
46 // This file also declares some classes to handle the common log writer, log
47 // formatter, and log filter cases. Callers can also create their own writers,
50 // called from multiple threads, so it must be thread-safe.
60 // GTMLogger is the primary user-facing class for an object-oriented logging
61 // system. It is built on the concept of log formatters (GTMLogFormatter), log
62 // writers (GTMLogWriter), and log filters (GTMLogFilter). When a message is
63 // sent to a GTMLogger to log a message, the message is formatted using the log
64 // formatter, then the log filter is consulted to see if the message should be
65 // logged, and if so, the message is sent to the log writer to be written out.
67 // GTMLogger is intended to be a flexible and thread-safe logging solution. Its
78 // release builds. Using the standard log settings, a log message will look like
81 // 2007-12-30 10:29:24.177 myapp[4588/0xa07d0f60] [lvl=1] foo=<Foo: 0x123>
83 // The output contains the date and time of the log message, the name of the
84 // process followed by its process ID/thread ID, the log level at which the
86 // kGTMLoggerLevelDebug), and finally, the user-specified log message itself (in
87 // this case, the log message was @"foo=%@", foo).
98 // Log Levels
99 // ----------
100 // GTMLogger has 3 different log levels: Debug, Info, and Error. GTMLogger
101 // doesn't take any special action based on the log level; it simply forwards
103 // optionally take action based on the level. Since log level filtering is
104 // performed at runtime, log messages are typically not filtered out at compile
106 // *ARE* filtered out of non-DEBUG builds. This is to be backwards compatible
111 // Standard loggers are created with the GTMLogLevelFilter log filter, which
112 // filters out certain log messages based on log level, and some other settings.
114 // In addition to the -logDebug:, -logInfo:, and -logError: methods defined on
123 // compiled out of non-DEBUG builds*.
126 // ----------------
128 // a logger that is pre-configured with some standard/common writer, formatter,
135 // ----------------------
149 // --------
152 // 1. You want to log something as simply as possible. Also, this call will only
153 // appear in debug builds. In non-DEBUG builds it will be completely removed.
167 // NSFileHandle *f = [NSFileHandle fileHandleForWritingAtPath:@"/tmp/f.log"
170 // GTMLoggerError(@"hi"); // This will be sent to /tmp/f.log
172 // 4. Create a new GTMLogger that will log to a file. This example differs from
176 // GTMLogger *logger = [GTMLogger standardLoggerWithPath:@"/tmp/temp.log"];
177 // [logger logInfo:@"hi temp log file"];
180 // the log message. This might be useful, for example, when writing a help
181 // screen for a command-line tool to standard output.
186 // 6. Send log output to stdout AND to a log file. The trick here is that
187 // NSArrays function as composite log writers, which means when an array is
188 // set as the log writer, it forwards all logging messages to all of its
193 // [NSFileHandle fileHandleForWritingAtPath:@"/tmp/f.log" create:YES],
198 // [logger logInfo:@"hi"]; // Output goes to stdout and /tmp/f.log
200 // For futher details on log writers, formatters, and filters, see the
234 // Returns a new autoreleased GTMLogger instance that will log to stdout, using
245 // Returns a new standard GTMLogger instance with a log writer that will
259 // does not do any special log formatting; this is the difference between a
266 - (id)initWithWriter:(id<GTMLogWriter>)writer
275 - (void)logDebug:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2);
277 - (void)logInfo:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2);
279 - (void)logError:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2);
281 - (void)logAssert:(NSString *)fmt, ... NS_FORMAT_FUNCTION(1, 2);
288 // Accessor methods for the log writer. If the log writer is set to nil,
290 - (id<GTMLogWriter>)writer;
291 - (void)setWriter:(id<GTMLogWriter>)writer;
293 // Accessor methods for the log formatter. If the log formatter is set to nil,
294 // GTMLogBasicFormatter is used. This formatter will format log messages in a
296 - (id<GTMLogFormatter>)formatter;
297 - (void)setFormatter:(id<GTMLogFormatter>)formatter;
299 // Accessor methods for the log filter. If the log filter is set to nil,
300 // GTMLogNoFilter is used, which allows all log messages through.
301 - (id<GTMLogFilter>)filter;
302 - (void)setFilter:(id<GTMLogFilter>)filter;
310 - (void)logFuncDebug:(const char *)func msg:(NSString *)fmt, ...
312 - (void)logFuncInfo:(const char *)func msg:(NSString *)fmt, ...
314 - (void)logFuncError:(const char *)func msg:(NSString *)fmt, ...
316 - (void)logFuncAssert:(const char *)func msg:(NSString *)fmt, ...
324 // Convenience macros that log to the shared GTMLogger instance. These macros
325 // are how users should typically log to GTMLogger. Notice that GTMLoggerDebug()
326 // calls will be compiled out of non-Debug builds.
345 // Log levels.
356 // Log Writers
361 // Writes the given log message to where the log writer is configured to write.
362 - (void)logMessage:(NSString *)msg level:(GTMLoggerLevel)level;
366 // Simple category on NSFileHandle that makes NSFileHandles valid log writers.
368 // now becomes a valid log writer. Log messages are written to the file handle
379 // GTMLogWriter -logMessage:level: message is sent to the array, the array
383 // This is useful in situations where you would like to send log output to
384 // multiple log writers at the same time. Simply create an NSArray of the log
391 // This category adapts the GTMLogger interface so that it can be used as a log
394 // This is useful when you want to configure a logger to log to a specific
396 // that with a different log writer that may have its own formatter and/or
403 // Log Formatters
410 - (NSString *)stringForFunc:(NSString *)func
417 // A basic log formatter that formats a string the same way that NSLog (or
423 - (NSString *)prettyNameForFunc:(NSString *)func;
428 // A log formatter that formats the log string like the basic formatter, but
431 // 2007-12-30 10:29:24.177 myapp[4588/0xa07d0f60] [lvl=1] log mesage here
434 NSDateFormatter *dateFormatter_; // yyyy-MM-dd HH:mm:ss.SSS
442 // Log Filters
448 - (BOOL)filterAllowsMessage:(NSString *)msg level:(GTMLoggerLevel)level;
452 // A log filter that filters messages at the kGTMLoggerLevelDebug level out of
453 // non-debug builds. Messages at the kGTMLoggerLevelInfo level are also filtered
454 // out of non-debug builds unless GTMVerboseLogging is set in the environment or
460 // A simple log filter that does NOT filter anything out;
461 // -filterAllowsMessage:level will always return YES. This can be a convenient
462 // way to enable debug-level logging in release builds (if you so desire).
475 // A log filter that allows you to set a minimum log level. Messages below this
480 - (id)initWithMinimumLevel:(GTMLoggerLevel)level;
484 // A log filter that allows you to set a maximum log level. Messages whose level
490 - (id)initWithMaximumLevel:(GTMLoggerLevel)level;
498 - (void)logInternalFunc:(const char *)func