Files
XPlaneConnectCSP/xpcPlugin/Log.h
Jason Watkins ceba580450 Addressed issues found by Google code lint.
Fixed:
 - Removed trailing whitespace.
 - Removed out of date TODO's.
 - Added #include<algorithm> to DataManager.cpp
 - Reordered includes to include C system headers before C++ system headers.
 - Added username to TODO's
 - Renamed include guards to use full project name as prefix.
 - Made methods and parameters const where possible.
 - Made UDPSocket constructor explicit.

Won't Fix:
 - snprintf is introduced in C++11.
 - Trailing comments at the end of namespace & header guards
 - Did not re-inlude headers already included by the matching XPC header.
 - localtime is fine since X-Plane is not multithreaded at all on the plugin side.
 - Linter confuses #elif with parens as a function call.
 - namespace indentation
2015-05-08 15:18:24 -07:00

64 lines
2.4 KiB
C++

//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
//National Aeronautics and Space Administration. All Rights Reserved.
#ifndef XPCPLUGIN_LOG_H_
#define XPCPLUGIN_LOG_H_
#include <string>
// LOG_VERBOSITY determines the level of logging throughout the plugin.
// 0: Minimum logging. Only plugin manager events will be logged.
// 1: Critical errors. When an error that prevents correct operation of the
// plugin, attempt to write useful information to the log. Note that since
// XPC runs inside the X-Plane executable, we try very hard no to crash.
// As a result, these log messages may be the only indication of failure.
// 2: All errors. Any time something unexpected happens, log it.
// 3: Significant actions. Any time something happens outside of normal
// command processing, log it. Will also log when commands are received.
// 4: Detailed actions. Log aditional information as commands are processed.
// 5: Everything. Log nearly every single action the plugin takes. This may
// have a detrimental impact on X-Plane performance.
#define LOG_VERBOSITY 3
namespace XPC
{
/// Handles logging for the plugin.
///
/// \details Provides functions to write lines to the XPC log file.
/// \author Jason Watkins
/// \version 1.0
/// \since 1.0
/// \date Intial Version: 2015-04-09
/// \date Last Updated: 2015-04-09
class Log
{
public:
/// Initializes the logging component by deleting old log files,
/// writing header information to the log file.
static void Initialize(std::string header);
/// Closes the log file.
static void Close();
/// Writes the C 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.
///
/// \param format The format string appropriate for consumption by sprintf.
static void FormatLine(const char* format, ...);
/// Writes the specified string value, followed by a line terminator
/// to the XPC log file.
///
/// \param value The value to write.
static void WriteLine(const std::string& value);
/// Writes the specified C string value, followed by a line terminator
/// to the XPC log file.
///
/// \param value The value to write.
static void WriteLine(const char* value);
};
}
#endif