Revision 4fd46efa
Added by david.sorber over 2 years ago
| src/CopyManager.cc | ||
|---|---|---|
|
{
|
||
|
// Unsupported entry type
|
||
|
LOG(error) << "Unsupported entry type: " << entry.path();
|
||
|
incInvalidEntries();
|
||
|
}
|
||
|
|
||
|
}
|
||
| src/CopyManagerOptions.cc | ||
|---|---|---|
|
bool copyTopLevel)
|
||
|
: r_srcPath(srcPath),
|
||
|
m_destPath(destPath),
|
||
|
m_disableLog(disableLog),
|
||
|
m_enableLog(disableLog),
|
||
|
m_logToStderr(logToStderr),
|
||
|
r_logFilePath(logFilePath),
|
||
|
m_logLevel(logLevel),
|
||
| src/CopyManagerOptions.h | ||
|---|---|---|
|
public:
|
||
|
|
||
|
// Log option defaults
|
||
|
static const bool DEFAULT_DISABLE_LOG{false};
|
||
|
static const bool DEFAULT_ENABLE_LOG{false};
|
||
|
static const bool DEFAULT_LOG_TO_STDERR{true};
|
||
|
static const int DEFAULT_LOG_LEVEL{3};
|
||
|
static inline const std::string DEFAULT_LOG_FILE_PATH{"./copyfile.log"};
|
||
| ... | ... | |
|
return m_destPath;
|
||
|
}
|
||
|
|
||
|
inline bool getDisableLog() const
|
||
|
inline bool getEnableLog() const
|
||
|
{
|
||
|
return m_disableLog;
|
||
|
return m_enableLog;
|
||
|
}
|
||
|
|
||
|
inline bool getLogToStderr() const
|
||
| ... | ... | |
|
std::string m_destPath; // destination path; "copy to"
|
||
|
|
||
|
// Logging related options
|
||
|
bool m_disableLog; // Enable/disable the log
|
||
|
bool m_enableLog; // Enable/disable the log
|
||
|
bool m_logToStderr; // Write log messages to stderr instead of file
|
||
|
const std::string& r_logFilePath; // Path to log file
|
||
|
int m_logLevel; // Log messages >= selected level will be output
|
||
| src/Logger.cc | ||
|---|---|---|
|
const std::string& msg)
|
||
|
{
|
||
|
// Filter log messages as needed
|
||
|
if (r_options.getDisableLog() || level > r_options.getLogLevel())
|
||
|
if ((! r_options.getEnableLog()) || level > r_options.getLogLevel())
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
| src/copytool_main.cc | ||
|---|---|---|
|
|
||
|
namespace sfs = std::filesystem;
|
||
|
|
||
|
const std::string VERSION("v0.2.0");
|
||
|
const std::string VERSION("v0.2.1");
|
||
|
|
||
|
const std::string BOLD{"\033[1m"};
|
||
|
const std::string ENDC{"\033[0m"};
|
||
| ... | ... | |
|
->check(CLI::ExistingDirectory);
|
||
|
|
||
|
// Logging related options
|
||
|
bool disableLog = DBS::CopyManagerOptions::DEFAULT_DISABLE_LOG;
|
||
|
bool enableLog = DBS::CopyManagerOptions::DEFAULT_ENABLE_LOG;
|
||
|
bool logToStderr = DBS::CopyManagerOptions::DEFAULT_LOG_TO_STDERR;
|
||
|
std::string logFilePath{DBS::CopyManagerOptions::DEFAULT_LOG_FILE_PATH};
|
||
|
int logLevel = DBS::CopyManagerOptions::DEFAULT_LOG_LEVEL;
|
||
|
|
||
|
// Add logging options
|
||
|
app.add_flag("--disable-log", disableLog, "disable (do not output) log");
|
||
|
app.add_flag("--enable-log", enableLog, "enable the log (default: disabled)");
|
||
|
app.add_flag("--log-to-stderr", logToStderr, "write log messages to stderr");
|
||
|
app.add_option("-l,--log-file-path", logFilePath, "log file path");
|
||
|
app.add_option("--log-level", logLevel,
|
||
| ... | ... | |
|
bool copyTopLevel = DBS::CopyManagerOptions::DEFAULT_COPY_TOPLEVEL;
|
||
|
|
||
|
app.add_option("--flow-control-threshold", flowControlThreshold,
|
||
|
"flow control threshold")
|
||
|
"flow control threshold (default: "
|
||
|
+ std::to_string(flowControlThreshold) + ")")
|
||
|
->check(CLI::Range(100,65535));
|
||
|
app.add_option("-n,--num-copy-threads", numCopyThreads,
|
||
|
"number of copy threads to spawn (default: 4)")
|
||
|
"number of copy threads to spawn (default: "
|
||
|
+ std::to_string(numCopyThreads) + ")")
|
||
|
->check(CLI::Range(1, 512));
|
||
|
app.add_flag("--copy-top-level", copyTopLevel,
|
||
|
"copy top level source directory to destination rather then "
|
||
| ... | ... | |
|
// Build options object
|
||
|
DBS::CopyManagerOptions options(srcPath,
|
||
|
destPath,
|
||
|
disableLog,
|
||
|
enableLog,
|
||
|
logToStderr,
|
||
|
logFilePath,
|
||
|
logLevel,
|
||
| ... | ... | |
|
|
||
|
// The callback structure requires a global
|
||
|
indicators::BlockProgressBar pBarEta{
|
||
|
indicators::option::BarWidth{80},
|
||
|
indicators::option::Start{"["},
|
||
|
indicators::option::End{"]"},
|
||
|
indicators::option::PrefixText{"Complete: "},
|
||
|
indicators::option::ShowElapsedTime{true},
|
||
|
indicators::option::ShowRemainingTime{true},
|
||
|
indicators::option::BarWidth{80},
|
||
|
indicators::option::Start{"["},
|
||
|
indicators::option::End{"]"},
|
||
|
indicators::option::PrefixText{"Complete: "},
|
||
|
indicators::option::ShowElapsedTime{true},
|
||
|
indicators::option::ShowRemainingTime{true},
|
||
|
};
|
||
|
|
||
|
|
||
|
// Run the manager
|
||
|
manager.run();
|
||
|
|
||
| ... | ... | |
|
indicators::show_console_cursor(true);
|
||
|
std::cout << std::endl;
|
||
|
|
||
|
// Display warning to user if any invalid/unsupported directory entries were
|
||
|
// found while copying
|
||
|
if (manager.getInvalidEntries() > 0)
|
||
|
{
|
||
|
std::cout << BOLD << YELLOW << "WARNING: " << ENDC
|
||
|
<< manager.getInvalidEntries() << " unsupported directory "
|
||
|
<< "entries (symlinks, FIFOs, etc.) were NOT copied.\n"
|
||
|
<< std::endl;
|
||
|
}
|
||
|
|
||
|
return rc;
|
||
|
}
|
||
Change "disable-log" option to "enable-log" and make the log disabled by
default. Also add a warning if unsupported directory entries are
detected while copying. Version: v0.2.1.