The fc::Logging namespace contains helper functions to easily manage the different types of logging available in FC++. More...
Enumerations | |
enum | EType { EType::kInvalid = 0, EType::kDebug, EType::kTrace, EType::kException, EType::kSummary, EType::kNone, EType::kMinimal, EType::kNormal, EType::kAll } |
Functions | |
bool | enable (const EType type, fc::Options &options, const std::string &log_directory="") |
Enable the specified type of logging. More... | |
bool | disable (const EType type, fc::Options &options) |
Disable the specified logging type. More... | |
std::string | get_filename (const EType type) |
Get the filename for the specified log type. More... | |
The fc::Logging namespace contains helper functions to easily manage the different types of logging available in FC++.
There are several log files, for different purposes, some of which have similar content.
Name | Filename | Performance Impact | Description | Example API |
---|---|---|---|---|
Debug | fc_debug.log | Very high. | Debugging statements. This is only available for special builds in select cases to debug issues. It is not available in normal release builds. | n/a |
Trace | fc_trace.log | High. | UDP upload packet and block trace. Only useful for debugging UDP upload problems. | fc::Options::setTrace() |
Exception | fc_exception.log | Extremely low. | C++ exceptions. All fc::Exception objects created by FC++ are logged to this file, if it exists. | fc::Exception::createLogFile() |
Summary | fc_summary.log | Low. | Summary of the FTP session. Contains client-server conversations, files transferred, and exceptions. | fc::SummaryLog::truncateLogFile() |
n/a | n/a | n/a | Set the base path used for all FC++ log files. | fc::Options::setLogFileOutputDir() |
In addition to these, there are additional high-level functions from the fc::Logging namespace that can be used to enable or disable logs. These helper functions make calls to various other public API methods, but is meant to be easy-to-use since all the functionality is located in one convenient location.
For example:
off
by default. Use fc::Logging::enable() to turn logging on
.
|
strong |
Enumerator | |
---|---|
kInvalid | |
kDebug | Debug-level logging is not available in release builds. It cannot be enabled or disabled through this interface. |
kTrace | UDP upload packet and block trace. |
kException | C++ exceptions are logged with a backtrace. |
kSummary | Summary of the FTP session is logged. |
kNone | Calling |
kMinimal | Same as EType::kException. |
kNormal | Same as EType::kException + EType::kSummary. |
kAll | Same as EType::kException + EType::kSummary + EType::kTrace (and EType::kDebug if available) |
bool fc::Logging::enable | ( | const EType | type, |
fc::Options & | options, | ||
const std::string & | log_directory = "" |
||
) |
Enable the specified type of logging.
This may be called multiple times to re-configure the same or different logging levels. Internally, only 1 log directory
is stored by FC++, so if enable() is called multiple times, only the very last log_directory
specified will apply to all logs. When left as a blank string, the log directory will default to the current working directory.
For example, to turn on logging prior to instantiating the FTP server object:
Another example showing the same as the code above, but this time on a pre-existing FTP server object:
TRUE
if the specified logging has been enabled.off
by default. Use fc::Logging::enable() to turn logging on
.References fc::Exception::createLogFile(), disable(), fc::kNone, fc::Options::setLogFileOutputDir(), fc::Options::setTrace(), and fc::SummaryLog::truncateLogFile().
bool fc::Logging::disable | ( | const EType | type, |
fc::Options & | options | ||
) |
Disable the specified logging type.
This can be called many times, even with identical log types.
For example:
TRUE
if the specified log was successfully disabled.off
by default. Use fc::Logging::enable() to turn logging on
.References fc::SummaryLog::removeLogFile(), fc::Exception::removeLogFile(), and fc::Options::setTrace().
std::string fc::Logging::get_filename | ( | const EType | type | ) |
Get the filename for the specified log type.
This returns the filename even when the specified log type is disabled. The filename returned may not exist if logging hasn't started, logging has been disabled, or if no messages have yet been logged.
References fc::Name::full(), fc::SummaryLog::getLogFilename(), fc::Exception::getLogFilename(), and fc::Options::getLogFileOutputDir().