-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue 25721 cli improve logging handling (#25858)
* #25721 Logging configurations in application.properties files have been updated to improve overall logging efficiency. * #25721 Logging configurations in application.properties files have been updated to improve overall logging efficiency. * #25721 Logging configurations in application.properties files have been updated to improve overall logging efficiency. * #25721 Logging configurations in application.properties files have been updated to improve overall logging efficiency. * #25721 Add logging for executed commands A new class, `LoggingExecutionStrategy`, has been added to the project. This class implements `IExecutionStrategy` with the added functionality to log the command being executed. It is used in `EntryCommand` class to wrap the existing execution strategy, allowing us to log the commands entered by users in the command-line interface. This helps in debugging by providing a clearer picture of the sequence of commands executed. * #25721 Updating documentation
- Loading branch information
1 parent
e689dc0
commit 2cdfd50
Showing
17 changed files
with
164 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 25 additions & 3 deletions
28
tools/dotcms-cli/api-data-model/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
tools/dotcms-cli/cli/src/main/java/com/dotcms/cli/common/LoggingExecutionStrategy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.dotcms.cli.common; | ||
|
||
import picocli.CommandLine; | ||
import picocli.CommandLine.ExecutionException; | ||
import picocli.CommandLine.IExecutionStrategy; | ||
import picocli.CommandLine.ParameterException; | ||
|
||
/** | ||
* This class implements the execution strategy interface, with the added functionality of logging | ||
* the command being executed. | ||
*/ | ||
public class LoggingExecutionStrategy implements IExecutionStrategy { | ||
|
||
private static final java.util.logging.Logger LOGGER = java.util.logging.Logger.getLogger( | ||
LoggingExecutionStrategy.class.getName()); | ||
private final IExecutionStrategy underlyingStrategy; | ||
|
||
/** | ||
* Constructs a new instance of LoggingExecutionStrategy with the provided underlying strategy. | ||
* | ||
* @param underlyingStrategy the underlying strategy to use for execution | ||
*/ | ||
public LoggingExecutionStrategy(IExecutionStrategy underlyingStrategy) { | ||
this.underlyingStrategy = underlyingStrategy; | ||
} | ||
|
||
/** | ||
* Executes the command specified in the parse result, while logging the executed command. | ||
* | ||
* @param parseResult the parse result from which to select one or more CommandSpec instances to | ||
* execute | ||
* @return the exit code of the executed command | ||
* @throws ExecutionException if an exception occurs during command execution | ||
* @throws ParameterException if there is an error with the command parameters | ||
*/ | ||
@Override | ||
public int execute(CommandLine.ParseResult parseResult) | ||
throws ExecutionException, ParameterException { | ||
|
||
if (!parseResult.originalArgs().isEmpty()) { | ||
String commandLineString = String.join(" ", parseResult.originalArgs()); | ||
LOGGER.info("Executing command: " + commandLineString); | ||
} | ||
|
||
return underlyingStrategy.execute(parseResult); | ||
} | ||
} |
Oops, something went wrong.