LogCabin
|
#include <cassert>
#include <cstdarg>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <mutex>
#include <strings.h>
#include <sys/types.h>
#include <unistd.h>
#include <unordered_map>
#include "Core/Debug.h"
#include "Core/StringUtil.h"
#include "Core/ThreadId.h"
#include "include/LogCabin/Debug.h"
Go to the source code of this file.
Namespaces | |
namespace | LogCabin |
namespace | LogCabin::Core |
namespace | LogCabin::Core::Debug |
namespace | LogCabin::Core::Debug::Internal |
Functions | |
const char * | LogCabin::Core::Debug::Internal::logLevelToString (LogLevel level) |
Convert a log level to a (static) string. | |
LogLevel | LogCabin::Core::Debug::Internal::logLevelFromString (const std::string &level) |
Convert a string to a log level. | |
LogLevel | LogCabin::Core::Debug::Internal::getLogLevel (const char *fileName) |
From the policy, calculate the most verbose log level that should be displayed for this file. | |
size_t | LogCabin::Core::Debug::Internal::calculateLengthFilePrefix () |
Return the number of characters of __FILE__ that make up the path prefix. | |
const char * | LogCabin::Core::Debug::Internal::relativeFileName (const char *fileName) |
Strip out the common prefix of a filename to get a path from the project's root directory. | |
std::string | LogCabin::Core::Debug::getLogFilename () |
Return the filename given to the last successful call to setLogFilename(), or the empty string if none. | |
std::string | LogCabin::Core::Debug::setLogFilename (const std::string &filename) |
Open the given file by name and append future debug log messages to it. | |
std::string | LogCabin::Core::Debug::reopenLogFromFilename () |
Called to rotate the log file. | |
FILE * | LogCabin::Core::Debug::setLogFile (FILE *newFile) |
Change the file on which debug log messages are written. | |
std::function< void(DebugMessage)> | LogCabin::Core::Debug::setLogHandler (std::function< void(DebugMessage)> newHandler) |
Accept log messages on the given callback instead of writing them to a file. | |
std::vector< std::pair < std::string, std::string > > | LogCabin::Core::Debug::getLogPolicy () |
Return the current log policy (as set by a previous call to setLogPolicy). | |
void | LogCabin::Core::Debug::setLogPolicy (const std::vector< std::pair< std::string, std::string >> &newPolicy) |
Specify the log messages that should be displayed for each filename. | |
void | LogCabin::Core::Debug::setLogPolicy (const std::initializer_list< std::pair< std::string, std::string >> &newPolicy) |
See setLogPolicy. | |
std::vector< std::pair < std::string, std::string > > | LogCabin::Core::Debug::logPolicyFromString (const std::string &in) |
Build a log policy from its string representation. | |
std::string | LogCabin::Core::Debug::logPolicyToString (const std::vector< std::pair< std::string, std::string >> &policy) |
Serialize a log policy into a string representation. | |
std::ostream & | LogCabin::Core::Debug::operator<< (std::ostream &ostream, LogLevel level) |
Output a LogLevel to a stream. | |
bool | LogCabin::Core::Debug::isLogging (LogLevel level, const char *fileName) |
Return whether the current logging configuration includes messages of the given level for the given filename. | |
void | LogCabin::Core::Debug::log (LogLevel level, const char *fileName, uint32_t lineNum, const char *functionName, const char *message) |
Unconditionally log the given message to stderr. | |
Variables | |
std::string | LogCabin::Core::Debug::processName |
A short name to be used in log messages to identify this process. | |
std::mutex | LogCabin::Core::Debug::Internal::mutex |
Protects logPolicy, isLoggingCache, and logFilename. | |
std::vector< std::pair < std::string, std::string > > | LogCabin::Core::Debug::Internal::logPolicy |
Specifies the log messages that should be displayed for each filename. | |
std::unordered_map< const char *, LogLevel > | LogCabin::Core::Debug::Internal::isLoggingCache |
A cache of the results of getLogLevel(), since that function is slow. | |
std::string | LogCabin::Core::Debug::Internal::logFilename |
Filename of currently open stream, if known. | |
FILE * | LogCabin::Core::Debug::Internal::stream |
Where log messages go (unless logHandler is set). | |
std::function< void(DebugMessage)> | LogCabin::Core::Debug::Internal::logHandler |
If set, a callback that takes log messages instead of the normal log file (stream). | |
const size_t | LogCabin::Core::Debug::Internal::lengthFilePrefix |
Stores result of calculateLengthFilePrefix(). |