The Sleuth Kit Framework
4.1
|
Logging class to enable the framework, apps that use it, and modules to log error and warning messages. More...
#include <Log.h>
Public Types | |
enum | Channel { Error, Warn, Info } |
Defined logging levels. More... | |
Public Member Functions | |
int | close () |
Close the opened log file. More... | |
const char * | getLogPath () |
const wchar_t * | getLogPathW () |
Return the path to the log file. More... | |
virtual void | log (Channel a_channel, const std::wstring &a_msg) |
Generate a log message with a given level (wide string). More... | |
virtual void | log (Channel a_channel, const std::string &a_msg) |
Generate a log message with a given level (narrow string). More... | |
void | logError (const std::wstring &msg) |
Log an error message. More... | |
virtual void | logf (Channel a_channel, char const *format,...) |
Generate a log message with a given level (printf-style arguments). More... | |
void | logInfo (const std::wstring &msg) |
Log an info message. More... | |
void | logWarn (const std::wstring &msg) |
Log a warning message. More... | |
int | open (const wchar_t *a_logFileFullPath) |
Open the single log file at the path specified. More... | |
int | open (const char *a_outDir) |
int | open () |
Opens a single log file with a default name, based on the time that the log was opened. More... | |
Protected Member Functions | |
void | logMessage (const std::string &level, const std::string &msg) |
Protected Attributes | |
std::string | m_filePath |
unsigned int | m_messageRepeatCount |
std::ofstream | m_outStream |
std::string | m_previousMessage |
Static Protected Attributes | |
static const int | REPEAT_THRESHOLD = 500 |
Logging class to enable the framework, apps that use it, and modules to log error and warning messages.
The default implementation writes the log messages to a file if open() was called or prints the messages to stderr if open() was never called. The class can be extended if you want logs to be saved in another way. Can be registered with and retrieved from TskServices.
Developers can either directly call the log() method with the logging level, can call the logError(), etc. methods on the class or use the LOGERROR() etc. macros, which will also get the Log service from TskServices.
enum Log::Channel |
int Log::close | ( | ) |
Close the opened log file.
const wchar_t * Log::getLogPathW | ( | ) |
Return the path to the log file.
References TskUtilities::toUTF16().
|
virtual |
Generate a log message with a given level (wide string).
a_channel | Level of log to make |
a_msg | Message to record. |
References TskUtilities::toUTF8().
Referenced by logf().
|
virtual |
|
inline |
Log an error message.
msg | Message to log |
References Error.
Referenced by SectorRuns::addRun().
|
virtual |
Generate a log message with a given level (printf-style arguments).
a_channel | Level of log to make |
format | Message to record. |
References log().
|
inline |
Log an info message.
msg | Message to log |
References Info.
Referenced by TskServices::getLog().
|
inline |
int Log::open | ( | const wchar_t * | a_logFileFullPath) |
Open the single log file at the path specified.
All messages will be printed to the log.
a_logFileFullPath | Path to logfile to open. |
References open(), and TskUtilities::toUTF8().
int Log::open | ( | ) |
Opens a single log file with a default name, based on the time that the log was opened.
Referenced by open().
Copyright © 2011-2013 Brian Carrier. (carrier -at- sleuthkit -dot- org)
This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 United States License.