FC++  v0.7.1-1067
FileCatalyst Fast File Transfers - C++ Library
fc::Logging Namespace Reference

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...
 

Detailed Description

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:

int main(void)
{
fc::Options options;
options.setUsernameAndPassword( "bob", "secret" );
options.setFtpServer( "ftp.example.com" );
fc::Control ftp( options );
// ...etc...
return 0;
}
Note
All logging is off by default. Use fc::Logging::enable() to turn logging on.

Enumeration Type Documentation

enum fc::Logging::EType
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 fc::Logging::enable(kNone) is equivalent to calling fc::Logging::disable(kAll).

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)

Function Documentation

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:

fc::Options options;
options.setUsernameAndPassword( "bob", "secret" );
options.setFtpServer( "ftp.example.com" );
fc::Control ftp( options );
// ...etc...

Another example showing the same thing as the code above, but this time on an existing FTP server object:

Returns
TRUE if the specified logging has been enabled.
Note
All logging is off by default. Use fc::Logging::enable() to turn logging on.
See also
fc::Logging::disable()
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:

Returns
TRUE if the specified log was successfully disabled.
Note
All logging is off by default. Use fc::Logging::enable() to turn logging on.
See also
fc::Logging::enable()
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.