Skip to content
Jason Watkins edited this page May 12, 2015 · 1 revision

The Log component facilitates the logging of information about what the XPC plugin is doing while it is running. Logging is accomplished through two methods. Other components can write to the XPC log either by calling Log::WriteLine to write a string to the log directly, or Log::FormatLine to write a formatted string to the log.

###Preprocessor Definitions The following constants are defined to identify progressively more comprehensive levels of logging. The first parameter of any of the Log methods should be one of these constants.

  • LOG_OFF
  • LOG_FATAL
  • LOG_ERROR
  • LOG_WARN
  • LOG_INFO
  • LOG_DEBUG
  • LOG_TRACE

LOG_LEVEL: If LOG_LEVEL is not defined elsewhere, Log.h will default to logging all errors.

###Types

####Log Provides methods for writing formatted text to the log file.

#####Log Methods

######Initialize Signature: static void Initialize(const std::string& header);

Initializes the logging component by deleting old log files, writing header information to the log file.

######Close Signature: static void Close();

Closes the log file.

######FormatLine Signature:

static void FormatLine(int level,
                       const std::string& tag,
                       const std::string& format,
                       ...);

Writes the string pointed to by format, followed by a line terminator to the XPC log file. If format contains format specifiers, additional arguments following format will be formatted and inserted in the resulting string, replacing their respective specifiers.

######WriteLine Signature:

static void WriteLine(int level,
                      const std::string& tag,
                      const std::string& value);

Writes the specified string value, followed by a line terminator to the XPC log file.

#####Internal Functions

######WriteTime Signature: static void WriteTime(FILE* fd)

Helper function to write a formatted timestamp at the beginning of a log line.