Skip to content

Commit 64cc4b5

Browse files
committed
--log working
1 parent 570e0d0 commit 64cc4b5

File tree

6 files changed

+18
-12
lines changed

6 files changed

+18
-12
lines changed

astra-shell/src/main/java/com/datastax/astra/shell/AstraCli.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public static void main(String[] args) {
8585
try {
8686

8787
// Enable Colored outputs
88-
//AnsiConsole.systemInstall();
88+
AnsiConsole.systemInstall();
8989

9090
// Save the command line to log it later
9191
ShellContext.getInstance().setRawCommand(args);

astra-shell/src/main/java/com/datastax/astra/shell/ShellContext.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,24 +147,24 @@ private boolean isSectionTokenValid(BaseCommand cmd) {
147147
public void init(BaseCliCommand cli) {
148148
this.startCommand = cli;
149149
LoggerShell.info("-----------------------------------------------------");
150-
LoggerShell.info("Command : astra " + String.join(" ", ShellContext.getInstance().getRawCommand()));
150+
LoggerShell.info("Command : " + ShellContext.getInstance().getRawCommandString());
151151
LoggerShell.info("Class : " + cli.getClass());
152152
this.token = cli.getToken();
153153

154154
// No token = use configuration file
155155
if (this.token == null) {
156156
// Overriding default config
157157
if (cli.getConfigFilename() != null) {
158-
LoggerShell.trace("ConfigFilename: " + cli.getConfigFilename());
158+
LoggerShell.debug("ConfigFilename: " + cli.getConfigFilename());
159159
this.astraRc = new AstraRc(cli.getConfigFilename());
160160
} else {
161-
LoggerShell.trace("ConfigFilename: " + AstraRc.getDefaultConfigurationFileName());
161+
LoggerShell.debug("ConfigFilename: " + AstraRc.getDefaultConfigurationFileName());
162162
this.astraRc = new AstraRc();
163163
}
164164
// Overriding default section
165165
if (!StringUtils.isEmpty(cli.getConfigSectionName())) {
166166
this.configSection = cli.getConfigSectionName();
167-
LoggerShell.trace("ConfigSectionName: " + configSection);
167+
LoggerShell.debug("ConfigSectionName: " + configSection);
168168
}
169169

170170
if (isSectionValid(cli) && isSectionTokenValid(cli)) {
@@ -175,7 +175,7 @@ public void init(BaseCliCommand cli) {
175175
}
176176

177177
if (token != null) {
178-
LoggerShell.trace("Token retrieved: " + token);
178+
LoggerShell.debug("Token retrieved: " + token);
179179
connect(token);
180180
} else {
181181
INVALID_PARAMETER.exit();
@@ -409,4 +409,13 @@ public void setRawCommand(String... args) {
409409
this.rawCommand = Arrays.asList(args);
410410
}
411411

412+
/**
413+
* Get Current command as a String.
414+
*
415+
* @return
416+
* current command as a String
417+
*/
418+
public String getRawCommandString() {
419+
return "astra " + StringUtils.join(" ", getRawCommand());
420+
}
412421
}

astra-shell/src/main/java/com/datastax/astra/shell/cmd/BaseShellCommand.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ public void run() {
2020
} else {
2121
// Keep history of commands and options of the shell
2222
ShellContext.getInstance().setCurrentShellCommand(this);
23-
this.verbose = true;
2423
this.format = OutputFormat.human;
2524
execute();
2625
}

astra-shell/src/main/java/com/datastax/astra/shell/cmd/db/OperationsDb.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ public static ExitCode createDb(BaseCommand cmd, String databaseName, String dat
116116
.regionsServerless()
117117
.collect(Collectors
118118
.toMap(DatabaseRegionServerless::getName, Function.identity()));
119-
LoggerShell.trace("Available regions :" + regionMap);
119+
LoggerShell.debug("Available regions :" + regionMap);
120120

121121
// Validate region
122122
if (!regionMap.containsKey(databaseRegion)) {

astra-shell/src/main/java/com/datastax/astra/shell/utils/LoggerShell.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public static void warning(String text) {
111111
* @param text
112112
* text to show in success
113113
*/
114-
public static void trace(String text) {
114+
public static void debug(String text) {
115115
if (isVerbose()) {
116116
System.out.println(ansi().fg(YELLOW).a("[DEBUG] - ").reset().a(text));
117117
}

astra-shell/src/main/java/com/datastax/astra/shell/utils/ShellPrinter.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ public static String version() {
5757
return versionPackage;
5858
}
5959

60-
private static final ObjectMapper MAPPER = new ObjectMapper();
61-
6260
/**
6361
* Json Object Mapper.
6462
*/
@@ -166,7 +164,7 @@ public static void printShellTable(ShellTable sht, OutputFormat fmt) {
166164
*/
167165
public static final void printObjectAsJson(Object obj, Ansi.Color color) {
168166
try {
169-
println(MAPPER
167+
println(OM
170168
.writerWithDefaultPrettyPrinter()
171169
.writeValueAsString(obj), color);
172170
} catch (JsonProcessingException e) {

0 commit comments

Comments
 (0)