DDLogFormatter Protocol Reference
Conforms to | NSObject |
Declared in | DDLog.h |
Tasks
-
– formatLogMessage:
Formatters may optionally be added to any logger. This allows for increased flexibility in the logging environment. For example, log messages for log files may be formatted differently than log messages for the console.
required method -
– didAddToLogger:
A single formatter instance can be added to multiple loggers. These methods provides hooks to notify the formatter of when it’s added/removed.
Instance Methods
didAddToLogger:
A single formatter instance can be added to multiple loggers. These methods provides hooks to notify the formatter of when it’s added/removed.
- (void)didAddToLogger:(id<DDLogger>)logger
Discussion
A single formatter instance can be added to multiple loggers. These methods provides hooks to notify the formatter of when it’s added/removed.
This is primarily for thread-safety. If a formatter is explicitly not thread-safe, it may wish to throw an exception if added to multiple loggers. Or if a formatter has potentially thread-unsafe code (e.g. NSDateFormatter), it could possibly use these hooks to switch to thread-safe versions of the code.
Declared In
DDLog.h
formatLogMessage:
Formatters may optionally be added to any logger. This allows for increased flexibility in the logging environment. For example, log messages for log files may be formatted differently than log messages for the console.
- (NSString *)formatLogMessage:(DDLogMessage *)logMessage
Discussion
Formatters may optionally be added to any logger. This allows for increased flexibility in the logging environment. For example, log messages for log files may be formatted differently than log messages for the console.
For more information about formatters, see the “Custom Formatters” page: https://github.com/robbiehanson/CocoaLumberjack/wiki/CustomFormatters
The formatter may also optionally filter the log message by returning nil, in which case the logger will not log the message.
Declared In
DDLog.h