Skip to content

Commit

Permalink
#833 - reduce log
Browse files Browse the repository at this point in the history
  • Loading branch information
grabdoc committed Dec 15, 2024
1 parent 421cf44 commit 623b79a
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ public class SchemaController implements SchemaRestApi {
@Override
public List<? extends TableObject> getObjects(String dbId, String filter, Boolean columns) {

log.info("Filter - {}", filter);
log.debug("Filter - {}", filter);

DbMeta dbMeta = jdbcManager.getDbMetaByDbId(dbId);

log.info("dbMeta - {}", dbMeta);


if (Objects.isNull(dbMeta)) {
return List.of();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public Object sqlTemplate(@PathVariable String dbId,
) {
final Map<String, Object> context = createContext(userPathVariable, requestParams, requestHeaders, matrixVariables);

log.info("context - {}", context);
log.debug("context - {}", context);

return sqlTemplateExecutorService.execute(dbId, fileName, context);

Expand Down
10 changes: 5 additions & 5 deletions auth/src/main/java/com/homihq/db2rest/auth/AuthFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ protected void doFilterInternal(
final FilterChain filterChain
) throws ServletException, IOException {

log.info("Handling Auth");
log.debug("Handling Auth");

String requestUri = urlPathHelper.getRequestUri(request);
String method = request.getMethod();

log.info("Request URI - {}", requestUri);
log.debug("Request URI - {}", requestUri);

if (!authProvider.isExcluded(requestUri, method)) {

//authenticate
UserDetail userDetail = authProvider.authenticate(request);

log.info("user detail - {}", userDetail);
log.debug("user detail - {}", userDetail);

if (Objects.isNull(userDetail)) {
String errorMessage = "Authentication failure.";
Expand All @@ -63,12 +63,12 @@ protected void doFilterInternal(
return;
}
} else {
log.info("URI in whitelist. Security checks not applied.");
log.debug("URI in whitelist. Security checks not applied.");
}

filterChain.doFilter(request, response);

logger.info("Completed Auth Filter");
logger.debug("Completed Auth Filter");
}

private void addError(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ protected boolean authorizeInternal(
.stream()
.anyMatch(role -> StringUtils.equalsAnyIgnoreCase(role, userDetail.getRoles()));

log.info("Role match result - {}", roleMatch);
log.debug("Role match result - {}", roleMatch);

return roleMatch;

}

log.info("Failed to match resource role and/or HTTP method");
log.debug("Failed to match resource role and/or HTTP method");

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ApiAuthDataProvider(String apiEndPoint, String apiKey) {
.retrieve()
.body(AuthDataSource.class);

log.info("Auth data - {}", authDataSource);
log.debug("Auth data - {}", authDataSource);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public FileAuthDataProvider(String authFileFullPath) {

authDataSource = objectMapper.readValue(inputStream, AuthDataSource.class);

log.info("authDataSource - {}", authDataSource);
log.debug("authDataSource - {}", authDataSource);


} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class UnKeyAuthFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(final HttpServletRequest request, final HttpServletResponse response,
final FilterChain filterChain) throws ServletException, IOException {
logger.info(" *** Apply UnKeyAuth Filter ***");
logger.debug(" *** Apply UnKeyAuth Filter ***");

// Check the header and return authentication failed if header not present

Expand All @@ -43,7 +43,7 @@ protected void doFilterInternal(final HttpServletRequest request, final HttpServ

if (verifyResponse.isPresent()) {
//TODO convert and add to request attributes
log.info("Unkey response - {}", verifyResponse.get());
log.debug("Unkey response - {}", verifyResponse.get());
if (!verifyResponse.get().isValidKey()) {
addAuthenticationError(request, response);
return;
Expand All @@ -55,7 +55,7 @@ protected void doFilterInternal(final HttpServletRequest request, final HttpServ

filterChain.doFilter(request, response);

logger.info("Completed UnKey Auth Filter");
logger.debug("Completed UnKey Auth Filter");
}

private void addAuthenticationError(HttpServletRequest request, HttpServletResponse response) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void processTypes(DbTable table, List<String> insertableColumns, Map<Stri

String columnDataTypeName = table.getColumnDataTypeName(columnName);

log.info("columnName : {} || columnDataTypeName - {}", columnName, columnDataTypeName);
log.debug("columnName : {} || columnDataTypeName - {}", columnName, columnDataTypeName);
if (Objects.isNull(value)) {
continue;
}
Expand All @@ -64,7 +64,7 @@ public void processTypes(DbTable table, List<String> insertableColumns, Map<Stri
data.put(columnName, Integer.valueOf(value.toString().trim()));
} else if (StringUtils.equalsAnyIgnoreCase(columnDataTypeName, "_varchar")) {

log.info("Array type found");
log.debug("Array type found");

data.put(columnName, new ArrayTypeValueHolder("java.sql.Array", "varchar", ((ArrayList) value).toArray()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ private List<InsertableColumn> convertToInsertableColumnList(
insertableColumnList.add(new InsertableColumn(colName, null));
}

log.info("Sequences - {}", sequences);
log.debug("Sequences - {}", sequences);
if (Objects.nonNull(sequences)) {
for (String sequence : sequences) {
String[] colSeq = sequence.split(":");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public CreateResponse save(
List<DbColumn> pkColumns = dbTable.buildPkColumns();

for (DbColumn pkColumn : pkColumns) {
log.info("Adding primary key columns - {}", pkColumn.name());
log.debug("Adding primary key columns - {}", pkColumn.name());
insertableColumns.add(pkColumn.name());
}

Expand All @@ -65,7 +65,7 @@ public CreateResponse save(
insertableColumnList.add(new InsertableColumn(colName, null));
}

log.info("Sequences - {}", sequences);
log.debug("Sequences - {}", sequences);
if (Objects.nonNull(sequences)) { //handle oracle sequence
for (String sequence : sequences) {
String[] colSeq = sequence.split(":");
Expand All @@ -81,8 +81,8 @@ public CreateResponse save(
CreateContext context = new CreateContext(dbId, dbTable, insertableColumns, insertableColumnList);
String sql = sqlCreatorTemplate.create(context);

log.info("SQL - {}", sql);
log.info("Data - {}", data);
log.debug("SQL - {}", sql);
log.debug("Data - {}", data);


CreateResponse createResponse =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ private int executeDelete(String dbId, String filter, DbTable table, DeleteConte
String sql =
sqlCreatorTemplate.deleteQuery(context);

log.info("{}", sql);
log.info("{}", context.getParamMap());
log.debug("{}", sql);
log.debug("{}", context.getParamMap());

Integer i = this.jdbcManager.getTxnTemplate(dbId).execute(status -> {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public class JdbcFunctionService implements FunctionService {

@Override
public SimpleJdbcCall getSimpleJdbcCall(String dbId, String subRoutineName) {
log.info("dbId - {}", dbId);

JdbcTemplate jdbcTemplate = jdbcManager.getNamedParameterJdbcTemplate(dbId).getJdbcTemplate();
return new SimpleJdbcCall(jdbcTemplate).withFunctionName(subRoutineName);
}

@Override
public Map<String, Object> execute(String dbId, String subRoutineName, Map<String, Object> inParams) {
log.info("dbId - {}", dbId);

JdbcTemplate jdbcTemplate = jdbcManager.getNamedParameterJdbcTemplate(dbId).getJdbcTemplate();
return doExecute(jdbcTemplate, dbId, subRoutineName, inParams);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public Map<String, Object> execute(String dbId, String subRoutineName, Map<Strin
JdbcTemplate jdbcTemplate = jdbcManager.getNamedParameterJdbcTemplate(dbId).getJdbcTemplate();
Dialect dialect = jdbcManager.getDialect(dbId);

log.info("Dialect selected: {}", dialect);
log.info("inParams: {}", inParams);
log.debug("Dialect selected: {}", dialect);
log.debug("inParams: {}", inParams);

return doExecuteInternal(jdbcTemplate, subRoutineName, inParams);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ public class JdbcReadService implements ReadService {
@Override
public Object findAll(ReadContext readContext) {

log.info("readContext : {}", readContext);
log.debug("readContext : {}", readContext);

try {
for (ReadProcessor processor : processorList) {
processor.process(readContext);
}

String sql = sqlCreatorTemplate.query(readContext);
log.info("{}", sql);
log.info("{}", readContext.getParamMap());
log.debug("{}", sql);
log.debug("{}", readContext.getParamMap());
return dbOperationService.read(
jdbcManager.getNamedParameterJdbcTemplate(readContext.getDbId()),
readContext.getParamMap(), sql, jdbcManager.getDialect(readContext.getDbId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class RoutingDataSource extends AbstractRoutingDataSource {
protected Object determineCurrentLookupKey() {

final String dbId = DatabaseContextHolder.getCurrentDbId();
log.info("Datasource Id - {}", dbId);
log.debug("Datasource Id - {}", dbId);


return dbId;
Expand Down

0 comments on commit 623b79a

Please sign in to comment.