mirror of
https://github.com/dbeaver/cloudbeaver.git
synced 2026-09-24 16:04:36 +08:00
Dbeaver/pro#5141 improve logging (#3367)
* dbeaver/pro#5141 Improve logging * dbeaver/pro#5141 Improve logging * dbeaver/pro#5141 improve logging * dbeaver/pro#5141 improve logging * dbeaver/pro#5141 improve logging --------- Co-authored-by: kseniaguzeeva <112612526+kseniaguzeeva@users.noreply.github.com> Co-authored-by: Daria Marutkina <125263541+dariamarutkina@users.noreply.github.com>
This commit is contained in:
co-authored by
kseniaguzeeva
Daria Marutkina
parent
2aca70043e
commit
f06b769cfc
@@ -326,6 +326,10 @@ public class WebSession extends BaseWebSession
|
||||
if (!project.isShared() || application.isConfigurationMode()) {
|
||||
getWorkspace().setActiveProject(sessionProject);
|
||||
}
|
||||
log.info(String.format(
|
||||
"Project created: [ID=%s, Name=%s, Type=%s, Creator=%s]",
|
||||
project.getId(), project.getName(), project.getType(), project.getCreator()
|
||||
));
|
||||
return sessionProject;
|
||||
}
|
||||
|
||||
@@ -933,6 +937,11 @@ public class WebSession extends BaseWebSession
|
||||
*/
|
||||
public void deleteSessionProject(@Nullable WebSessionProjectImpl project) {
|
||||
if (project != null) {
|
||||
RMProject rmProject = project.getRMProject();
|
||||
log.info(String.format(
|
||||
"Project deleted: [ID=%s, Name=%s, Type=%s, Creator=%s]",
|
||||
rmProject.getId(), rmProject.getName(), rmProject.getType(), rmProject.getCreator()
|
||||
));
|
||||
project.dispose();
|
||||
}
|
||||
getWorkspace().removeProject(project);
|
||||
|
||||
+16
@@ -112,6 +112,11 @@ public class ConnectionControllerCE implements ConnectionController {
|
||||
WSConstants.EventAction.CREATE,
|
||||
WSDataSourceProperty.CONFIGURATION
|
||||
);
|
||||
log.info(String.format(
|
||||
"New connection was created: [info=%s, user=%s]",
|
||||
WebServiceUtils.getConnectionContainerInfo(newDataSource),
|
||||
webSession.getUserId()
|
||||
));
|
||||
return connectionInfo;
|
||||
}
|
||||
|
||||
@@ -219,6 +224,11 @@ public class ConnectionControllerCE implements ConnectionController {
|
||||
property
|
||||
);
|
||||
}
|
||||
log.info(String.format(
|
||||
"Connection updated: [info=%s, userId=%s]",
|
||||
WebServiceUtils.getConnectionContainerInfo(dataSource),
|
||||
webSession.getUser()
|
||||
));
|
||||
return connectionInfo;
|
||||
}
|
||||
|
||||
@@ -240,6 +250,12 @@ public class ConnectionControllerCE implements ConnectionController {
|
||||
WSConstants.EventAction.DELETE,
|
||||
WSDataSourceProperty.CONFIGURATION
|
||||
);
|
||||
|
||||
log.info(String.format(
|
||||
"Connection deleted: [info=%s, userId=%s]",
|
||||
WebServiceUtils.getConnectionContainerInfo(connectionInfo.getDataSourceContainer()),
|
||||
webSession.getUserId()
|
||||
));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
+9
-1
@@ -39,7 +39,6 @@ import org.jkiss.code.NotNull;
|
||||
import org.jkiss.code.Nullable;
|
||||
import org.jkiss.dbeaver.DBException;
|
||||
import org.jkiss.dbeaver.Log;
|
||||
import org.jkiss.dbeaver.model.DBConstants;
|
||||
import org.jkiss.dbeaver.model.DBPDataSourceContainer;
|
||||
import org.jkiss.dbeaver.model.app.DBPDataSourceRegistry;
|
||||
import org.jkiss.dbeaver.model.app.DBPProject;
|
||||
@@ -291,6 +290,7 @@ public class WebServiceAdmin implements DBWServiceAdmin {
|
||||
try {
|
||||
var adminSecurityController = webSession.getAdminSecurityController();
|
||||
adminSecurityController.addUserTeams(user, new String[]{team}, grantor.getUserId());
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
throw new DBWebException("Error granting team", e);
|
||||
@@ -403,6 +403,7 @@ public class WebServiceAdmin implements DBWServiceAdmin {
|
||||
@Override
|
||||
public Boolean setUserAuthRole(WebSession webSession, String userId, String authRole) throws DBWebException {
|
||||
try {
|
||||
log.info(String.format("User set auth role: [grantorUserId=%s]", webSession.getUserId()));
|
||||
webSession.getAdminSecurityController().setUserAuthRole(userId, authRole);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
@@ -518,6 +519,12 @@ public class WebServiceAdmin implements DBWServiceAdmin {
|
||||
} catch (DBException e) {
|
||||
throw new DBWebException("Error saving server configuration", e);
|
||||
}
|
||||
log.info(String.format(
|
||||
"Auth provider configuration created: [id=%s, provider=%s, userId=%s]",
|
||||
providerConfig.getId(),
|
||||
providerConfig.getProvider(),
|
||||
webSession.getUserId()
|
||||
));
|
||||
return new WebAuthProviderConfiguration(authProvider, providerConfig);
|
||||
}
|
||||
|
||||
@@ -531,6 +538,7 @@ public class WebServiceAdmin implements DBWServiceAdmin {
|
||||
} catch (DBException e) {
|
||||
throw new DBWebException("Error saving server configuration", e);
|
||||
}
|
||||
log.info(String.format("Auth provider configuration deleted: [id=%s, userId=%s]", id, webSession.getUserId()));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
+3
@@ -173,6 +173,8 @@ public class WebServiceDataTransfer implements DBWServiceDataTransfer {
|
||||
@Nullable WebSQLResultsInfo resultsInfo
|
||||
) {
|
||||
sqlProcessor.getWebSession().addInfoMessage("Export data");
|
||||
log.info(String.format("Data export started: [userId=%s]", sqlProcessor.getWebSession().getUserId()));
|
||||
|
||||
DataTransferProcessorDescriptor processor = DataTransferRegistry.getInstance().getProcessor(parameters.getProcessorId());
|
||||
String uniqueFileName = makeUniqueFileName(sqlProcessor, processor, parameters.getProcessorProperties());
|
||||
var outputSettings = parameters.getOutputSettings();
|
||||
@@ -204,6 +206,7 @@ public class WebServiceDataTransfer implements DBWServiceDataTransfer {
|
||||
webSession.addInfoMessage("Import data");
|
||||
DataTransferProcessorDescriptor processor = DataTransferRegistry.getInstance().getProcessor(processorId);
|
||||
|
||||
log.info(String.format("Data import started: [userId=%s]", webSession.getUserId()));
|
||||
DBSDataContainer dataContainer = sqlContext.getDataContainer();
|
||||
WebAsyncTaskProcessor<String> runnable = new WebAsyncTaskProcessor<>() {
|
||||
@Override
|
||||
|
||||
+17
@@ -28,6 +28,7 @@ import io.cloudbeaver.utils.WebEventUtils;
|
||||
import org.jkiss.code.NotNull;
|
||||
import org.jkiss.code.Nullable;
|
||||
import org.jkiss.dbeaver.DBException;
|
||||
import org.jkiss.dbeaver.Log;
|
||||
import org.jkiss.dbeaver.model.rm.RMController;
|
||||
import org.jkiss.dbeaver.model.rm.RMProject;
|
||||
import org.jkiss.dbeaver.model.rm.RMResource;
|
||||
@@ -49,6 +50,8 @@ import java.util.Set;
|
||||
*/
|
||||
public class WebServiceRM implements DBWServiceRM {
|
||||
|
||||
private static final Log log = Log.getLog(WebServiceRM.class);
|
||||
|
||||
@Override
|
||||
public RMProject[] listProjects(@NotNull WebSession webSession) throws DBWebException {
|
||||
try {
|
||||
@@ -374,6 +377,13 @@ public class WebServiceRM implements DBWServiceRM {
|
||||
new HashSet<>(subjectIds),
|
||||
new HashSet<>(permissions)
|
||||
);
|
||||
log.info("Project permissions deleted: [projectIds=%s, subjectIds=%s, permissions=%s, madeBy=%s]"
|
||||
.formatted(
|
||||
String.join(",", projectIds),
|
||||
String.join(",", subjectIds),
|
||||
String.join(",", permissions),
|
||||
webSession.getUserId()
|
||||
));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
throw new DBWebException("Error deleting project permissions", e);
|
||||
@@ -396,6 +406,13 @@ public class WebServiceRM implements DBWServiceRM {
|
||||
new HashSet<>(permissions),
|
||||
webSession.getUserId()
|
||||
);
|
||||
log.info("Project permissions added: [projectIds=%s, subjectIds=%s, permissions=%s, madeBy=%s]"
|
||||
.formatted(
|
||||
String.join(",", projectIds),
|
||||
String.join(",", subjectIds),
|
||||
String.join(",", permissions),
|
||||
webSession.getUserId()
|
||||
));
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
throw new DBWebException("Error adding project permissions", e);
|
||||
|
||||
+21
@@ -170,6 +170,7 @@ public class CBEmbeddedSecurityController<T extends ServletAuthApplication>
|
||||
dbStat.setString(4, defaultAuthRole);
|
||||
}
|
||||
dbStat.execute();
|
||||
log.info(String.format("New user created: [userId=%s]", userId));
|
||||
}
|
||||
saveSubjectMetas(dbCon, userId, metaParameters);
|
||||
String defaultTeamName = getDefaultUserTeam();
|
||||
@@ -222,6 +223,7 @@ public class CBEmbeddedSecurityController<T extends ServletAuthApplication>
|
||||
}
|
||||
var event = new WSUserDeletedEvent(userId);
|
||||
application.getEventController().addEvent(event);
|
||||
log.info(String.format("User deleted: [userId=%s]", userId));
|
||||
}
|
||||
|
||||
public void setUserTeams(String userId, String[] teamIds, String grantorId) throws DBCException {
|
||||
@@ -286,6 +288,12 @@ public class CBEmbeddedSecurityController<T extends ServletAuthApplication>
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
log.info(String.format(
|
||||
"User set team role: [userId=%s,teamId=%s, role=%s]",
|
||||
userId,
|
||||
teamId,
|
||||
teamRole
|
||||
));
|
||||
}
|
||||
|
||||
//TODO implement add/delete user teams api
|
||||
@@ -358,6 +366,7 @@ public class CBEmbeddedSecurityController<T extends ServletAuthApplication>
|
||||
|
||||
Set<String> currentUserTeams = getCurrentUserTeams(dbCon, userId);
|
||||
|
||||
List<String> resultTeamIds = new ArrayList<>();
|
||||
try (PreparedStatement dbStat = dbCon.prepareStatement(
|
||||
"INSERT INTO {table_prefix}CB_USER_TEAM" +
|
||||
"(USER_ID,TEAM_ID,GRANT_TIME,GRANTED_BY) VALUES(?,?,?,?)")
|
||||
@@ -366,6 +375,7 @@ public class CBEmbeddedSecurityController<T extends ServletAuthApplication>
|
||||
if (currentUserTeams.contains(teamId)) {
|
||||
continue;
|
||||
}
|
||||
resultTeamIds.add(teamId);
|
||||
dbStat.setString(1, userId);
|
||||
dbStat.setString(2, teamId);
|
||||
dbStat.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
|
||||
@@ -373,6 +383,12 @@ public class CBEmbeddedSecurityController<T extends ServletAuthApplication>
|
||||
dbStat.execute();
|
||||
}
|
||||
}
|
||||
log.info(String.format(
|
||||
"User added to team: [userId=%s,team=%s, grantorUserId=%s]",
|
||||
userId,
|
||||
String.join(",", resultTeamIds),
|
||||
grantorId
|
||||
));
|
||||
}
|
||||
|
||||
protected void deleteUserTeams(
|
||||
@@ -392,6 +408,7 @@ public class CBEmbeddedSecurityController<T extends ServletAuthApplication>
|
||||
}
|
||||
dbStat.execute();
|
||||
}
|
||||
log.info(String.format("User deleted from team: [userId=%s,teamIds=%s]", userId, String.join(",", teamIds)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -773,6 +790,7 @@ public class CBEmbeddedSecurityController<T extends ServletAuthApplication>
|
||||
dbStat.setString(2, userId);
|
||||
dbStat.executeUpdate();
|
||||
}
|
||||
log.info(String.format("User updated: [userId=%s, isActive=%s]", userId, enabled));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -803,6 +821,7 @@ public class CBEmbeddedSecurityController<T extends ServletAuthApplication>
|
||||
if (dbStat.executeUpdate() <= 0) {
|
||||
throw new SMException("User not found");
|
||||
}
|
||||
log.info(String.format("User set auth role: [userId=%s,role=%s]", userId, authRole));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -902,6 +921,7 @@ public class CBEmbeddedSecurityController<T extends ServletAuthApplication>
|
||||
} catch (SQLException e) {
|
||||
throw new DBCException("Error saving user credentials in database", e);
|
||||
}
|
||||
log.info(String.format("Set credentials for user: [userId=%s,providerId=%s]", userId, authProviderId));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -916,6 +936,7 @@ public class CBEmbeddedSecurityController<T extends ServletAuthApplication>
|
||||
} catch (SQLException e) {
|
||||
throw new DBCException("Error deleting user credentials", e);
|
||||
}
|
||||
log.info(String.format("User credentials deleted: [userId=%s, providerId=%s]", userId, authProviderId));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
Reference in New Issue
Block a user