Skip to content

Commit f96b407

Browse files
committed
[main] rootcp: add verbosity level and be quiet by default
With this change rootcp will by default not print Info messages (same as rootcp.py), will print a `cp -v`-like output with -v and more detailed info with -vv.
1 parent 7b338f0 commit f96b407

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

main/src/rootcp.cxx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ positional arguments:
4343
--recreate recreate the destination file.
4444
-r, --recursive recurse inside directories
4545
--replace replace object if already existing
46-
-v, --verbose be verbose
46+
-v be verbose
47+
-vv be even more verbose
4748
4849
Note: If an object has been written to a file multiple times, rootcp will copy only the latest version of that object.
4950
@@ -100,7 +101,8 @@ static RootCpArgs ParseArgs(const char **args, int nArgs)
100101
opts.AddFlag({"--replace"});
101102
opts.AddFlag({"-r", "--recursive"});
102103
opts.AddFlag({"-h", "--help"});
103-
opts.AddFlag({"-v", "--verbose"});
104+
opts.AddFlag({"-v"});
105+
opts.AddFlag({"-vv"});
104106

105107
opts.Parse(args, nArgs);
106108

@@ -123,7 +125,9 @@ static RootCpArgs ParseArgs(const char **args, int nArgs)
123125
outArgs.fReplace = opts.GetSwitch("replace");
124126
outArgs.fRecreate = opts.GetSwitch("recreate");
125127

126-
if (opts.GetSwitch("verbose"))
128+
if (opts.GetSwitch("vv"))
129+
SetLogVerbosity(3);
130+
else if (opts.GetSwitch("v"))
127131
SetLogVerbosity(2);
128132

129133
outArgs.fSources = opts.GetArgs();
@@ -195,11 +199,11 @@ static void CopyNode(const RootSource &src, const RootCpDestination &dest, NodeI
195199
destFullPath = std::string(destDirPath) + "/" + node.fName;
196200
}
197201

198-
Info(1) << "cp " << src.fFileName << ":" << srcFullPath << " -> " << dest.fFname << ":" << destFullPath << "\n";
202+
Info(2) << "cp " << src.fFileName << ":" << srcFullPath << " -> " << dest.fFname << ":" << destFullPath << "\n";
199203

200204
TDirectory *destDir = dest.fFile;
201205
if (!destDirPath.empty()) {
202-
Info(2) << "mkdir " << destDirPath << "\n";
206+
Info(3) << "mkdir " << destDirPath << "\n";
203207
destDir = dest.fFile->mkdir(std::string(destDirPath).c_str(), /* title = */ "",
204208
/* returnPreExisting = */ true);
205209
}
@@ -236,7 +240,7 @@ static void CopyNode(const RootSource &src, const RootCpDestination &dest, NodeI
236240
return;
237241
}
238242

239-
Info(2) << "read object \"" << srcFullPath << "\" of type " << node.fClassName << "\n";
243+
Info(3) << "read object \"" << srcFullPath << "\" of type " << node.fClassName << "\n";
240244
if (!destDir) {
241245
Err() << "failed to create or get destination directory \"" << dest.fFname << ":" << destDirPath << "\"\n";
242246
return;

0 commit comments

Comments
 (0)