Skip to content

Commit

Permalink
Clean up CLI log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
edewata committed Jul 27, 2023
1 parent d937dc1 commit b093635
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 16 deletions.
6 changes: 3 additions & 3 deletions base/common/python/pki/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def execute_java(self, args, stdout=sys.stdout):

cmd.extend(args)

logger.info('Java command: %s', ' '.join(cmd))
logger.debug('Command: %s', ' '.join(cmd))

subprocess.check_call(cmd, stdout=stdout)

Expand Down Expand Up @@ -260,8 +260,8 @@ def execute(self, argv):
cmd_args.append(args[i])
i = i + 1

logger.info('PKI options: %s', ' '.join(pki_options))
logger.info('PKI command: %s %s', command, ' '.join(cmd_args))
logger.debug('PKI options: %s', ' '.join(pki_options))
logger.debug('PKI command: %s %s', command, ' '.join(cmd_args))

if client_type == 'python' or command in PYTHON_COMMANDS:
(module, module_args) = self.parse_args(cmd_args)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void process(HttpRequest request, HttpContext context) throws HttpExcepti
value = "********";
}

logger.info(" " + name + ": " + value);
logger.debug("- " + name + ": " + value);
}

if (output != null) {
Expand Down Expand Up @@ -148,7 +148,7 @@ public void process(HttpResponse response, HttpContext context) throws HttpExcep

logger.info("HTTP response: " + response.getStatusLine());
for (Header header : response.getAllHeaders()) {
logger.info(" " + header.getName() + ": " + header.getValue());
logger.debug("- " + header.getName() + ": " + header.getValue());
}

if (output != null) {
Expand Down
2 changes: 1 addition & 1 deletion base/common/src/main/java/org/dogtagpki/cli/CLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public void execute(String[] args) throws Exception {
throw new Exception("Invalid module \"" + getFullModuleName(moduleName) + "\".");
}

logger.info("Module: " + moduleName);
logger.debug("Module: " + moduleName);

// Prepare module arguments.
String[] moduleArgs;
Expand Down
2 changes: 1 addition & 1 deletion base/server/python/pki/server/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def execute(self, argv):
self.print_help()
sys.exit(1)

logger.info('Command: %s', ' '.join(args))
logger.debug('Command: %s', ' '.join(args))

super().execute(args)

Expand Down
3 changes: 1 addition & 2 deletions base/server/python/pki/server/cli/audit.py
Original file line number Diff line number Diff line change
Expand Up @@ -917,8 +917,7 @@ def execute(self, argv):
'-n', signing_cert['nickname'],
'-a', file_list])

if logger.isEnabledFor(logging.INFO):
print('Command: %s' % ' '.join(cmd))
logger.debug('Command: %s', ' '.join(cmd))

subprocess.call(cmd)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void subsystemStarted() throws Exception {
command.add("systemd-notify");
command.add("--ready");

logger.info("SystemdNotifier: Command: " + String.join(" ", command));
logger.debug("SystemdNotifier: Command: " + String.join(" ", command));

ProcessBuilder pb = new ProcessBuilder(command);
pb.inheritIO();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void execute(String[] args) throws Exception {
}

String[] cmdArgs = cmd.getArgs();
logger.info("Command: " + String.join(" ", cmdArgs));
logger.debug("Command: " + String.join(" ", cmdArgs));

super.execute(cmdArgs);
}
Expand Down
10 changes: 5 additions & 5 deletions base/tools/src/main/java/com/netscape/cmstools/cli/MainCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ public Map<String, String> loadPasswordConfig(String filename) throws Exception
String password = line.substring(p + 1).trim();

if (name.equals("internal")) {
logger.info("- internal: ********");
logger.debug("- internal: ********");
passwords.put(name, password);

} else if (name.startsWith("hardware-")) {
name = name.substring(9); // remove hardware- prefix
logger.info("- " + name + ": ********");
logger.debug("- " + name + ": ********");
passwords.put(name, password);

} else {
Expand Down Expand Up @@ -462,7 +462,7 @@ public void parseOptions(CommandLine cmd) throws Exception {

String messageFormat = cmd.getOptionValue("message-format");
config.setMessageFormat(messageFormat);
logger.info("Message format: " + messageFormat);
logger.debug("Message format: " + messageFormat);

optionsParsed = true;
}
Expand Down Expand Up @@ -646,14 +646,14 @@ public void execute(String[] args) throws Exception {

parseOptions(cmd);

if (logger.isInfoEnabled()) {
if (logger.isDebugEnabled()) {
StringBuilder sb = new StringBuilder("Command:");
for (String arg : cmdArgs) {
if (arg.contains(" ")) arg = "\"" + arg + "\"";
sb.append(" ");
sb.append(arg);
}
logger.info(sb.toString());
logger.debug(sb.toString());
}

super.execute(cmdArgs);
Expand Down

0 comments on commit b093635

Please sign in to comment.