FC++  v0.9.0-9e9b65
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()
{
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

◆ EType

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

◆ enable()

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 as the code above, but this time on a pre-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()

References fc::Exception::createLogFile(), disable(), fc::kNone, fc::Options::setLogFileOutputDir(), fc::Options::setTrace(), and fc::SummaryLog::truncateLogFile().

Here is the call graph for this function:

◆ 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()

References fc::SummaryLog::removeLogFile(), fc::Exception::removeLogFile(), and fc::Options::setTrace().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_filename()

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

Here is the call graph for this function:
fc::Logging::EType::kSummary
@ kSummary
Summary of the FTP session is logged.
fc::Options::setFtpServer
virtual Options & setFtpServer(const std::string &ip_or_hostname, const unsigned short tcp_port=21)
Set the FTP server address and port.
Definition: FCOptions.cpp:303
fc::Logging::EType::kNormal
@ kNormal
Same as EType::kException + EType::kSummary.
fc::Options::setUsernameAndPassword
virtual Options & setUsernameAndPassword(const std::string &username, const std::string &password)
Set the username and password to use when connecting to the FTP server.
Definition: FCOptions.cpp:347
main
int main(int argc, char *argv[])
Definition: example001.cpp:96
fc::Logging::EType::kTrace
@ kTrace
UDP upload packet and block trace.
fc::Logging::enable
bool enable(const EType type, fc::Options &options, const std::string &log_directory="")
Enable the specified type of logging.
Definition: FCLogging.cpp:11
fc::Options
fc::Options contains all the default and user-defined settings required by fc::Control to connect to ...
Definition: FCOptions.hpp:282
fc::Logging::disable
bool disable(const EType type, fc::Options &options)
Disable the specified logging type.
Definition: FCLogging.cpp:72
fc::Control::getOptions
const fc::Options & getOptions() const
Get the current set of options.
Definition: FCControl.cpp:269
fc::Control::setNewOptions
Control & setNewOptions(const fc::Options &newOptions)
Set new options.
Definition: FCControl.cpp:281
fc::Logging::EType::kAll
@ kAll
Same as EType::kException + EType::kSummary + EType::kTrace (and EType::kDebug if available)
fc::Logging::EType::kException
@ kException
C++ exceptions are logged with a backtrace.
fc::Control
Definition: FCControl.hpp:52