Skip to content

Remove default logging in the Data Loader DAO #2708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,10 @@
import java.util.NoSuchElementException;
import java.util.Optional;
import javax.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/** The generic DAO that is used to scan ScalarDB data */
public class ScalarDbDao {

/* Class logger */
private static final Logger logger = LoggerFactory.getLogger(ScalarDbDao.class);
private static final String GET_COMPLETED_MSG = "GET completed for %s";
private static final String PUT_COMPLETED_MSG = "PUT completed for %s";
private static final String SCAN_START_MSG = "SCAN started...";
private static final String SCAN_END_MSG = "SCAN completed";

/**
* Retrieve record from ScalarDB instance in storage mode
*
Expand All @@ -59,9 +50,7 @@ public Optional<Result> get(

try {
Get get = createGetWith(namespace, table, partitionKey, clusteringKey);
Optional<Result> result = storage.get(get);
logger.info(String.format(GET_COMPLETED_MSG, loggingKey));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is another option to change the log level to DEBUG or TRACE. What do you think?

Copy link
Contributor Author

@thongdk8 thongdk8 May 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will add some verbose options later in the command args, also with some progress printing to the console I think. So we're gonna add the logger back if needed. WDYT? cc @ypeckstadt

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👍

return result;
return storage.get(get);
} catch (ExecutionException e) {
throw new ScalarDbDaoException("error GET " + loggingKey, e);
}
Expand Down Expand Up @@ -90,9 +79,7 @@ public Optional<Result> get(
// Retrieving the key data for logging
String loggingKey = keysToString(partitionKey, clusteringKey);
try {
Optional<Result> result = transaction.get(get);
logger.info(String.format(GET_COMPLETED_MSG, loggingKey));
return result;
return transaction.get(get);
} catch (CrudException e) {
throw new ScalarDbDaoException("error GET " + loggingKey, e.getCause());
}
Expand Down Expand Up @@ -125,7 +112,6 @@ public void put(
throw new ScalarDbDaoException(
CoreError.DATA_LOADER_ERROR_CRUD_EXCEPTION.buildMessage(e.getMessage()), e);
}
logger.info(String.format(PUT_COMPLETED_MSG, keysToString(partitionKey, clusteringKey)));
}

/**
Expand Down Expand Up @@ -154,7 +140,6 @@ public void put(
throw new ScalarDbDaoException(
CoreError.DATA_LOADER_ERROR_CRUD_EXCEPTION.buildMessage(e.getMessage()), e);
}
logger.info(String.format(PUT_COMPLETED_MSG, keysToString(partitionKey, clusteringKey)));
}

/**
Expand Down Expand Up @@ -186,11 +171,8 @@ public List<Result> scan(

// scan data
try {
logger.info(SCAN_START_MSG);
try (Scanner scanner = storage.scan(scan)) {
List<Result> allResults = scanner.all();
logger.info(SCAN_END_MSG);
return allResults;
return scanner.all();
}
} catch (ExecutionException | IOException e) {
throw new ScalarDbDaoException(
Expand Down Expand Up @@ -229,10 +211,7 @@ public List<Result> scan(

// scan data
try {
logger.info(SCAN_START_MSG);
List<Result> results = transaction.scan(scan);
logger.info(SCAN_END_MSG);
return results;
return transaction.scan(scan);
} catch (CrudException | NoSuchElementException e) {
// No such element Exception is thrown when the scan is done in transaction mode but
// ScalarDB is running in storage mode
Expand Down