Skip to content

Commit 7e2460d

Browse files
committed
[*] improve log messages for standalone tasks
1 parent c6cc954 commit 7e2460d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

internal/pgengine/transaction.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,15 @@ func (pge *PgEngine) ExecStandaloneTask(ctx context.Context, connf func() (PgxCo
100100

101101
// ExecRemoteSQLTask executes task against remote connection
102102
func (pge *PgEngine) ExecRemoteSQLTask(ctx context.Context, task *ChainTask, paramValues []string) (string, error) {
103+
log.GetLogger(ctx).Info("Switching to remote task mode")
103104
return pge.ExecStandaloneTask(ctx,
104105
func() (PgxConnIface, error) { return pge.GetRemoteDBConnection(ctx, task.ConnectString.String) },
105106
task, paramValues)
106107
}
107108

108109
// ExecAutonomousSQLTask executes autonomous task in an acquired connection from pool
109110
func (pge *PgEngine) ExecAutonomousSQLTask(ctx context.Context, task *ChainTask, paramValues []string) (string, error) {
111+
log.GetLogger(ctx).Info("Switching to autonomous task mode")
110112
return pge.ExecStandaloneTask(ctx,
111113
func() (PgxConnIface, error) { return pge.GetLocalDBConnection(ctx) },
112114
task, paramValues)
@@ -158,7 +160,7 @@ func (pge *PgEngine) GetRemoteDBConnection(ctx context.Context, connectionString
158160
// FinalizeDBConnection closes session
159161
func (pge *PgEngine) FinalizeDBConnection(ctx context.Context, remoteDb PgxConnIface) {
160162
l := log.GetLogger(ctx)
161-
l.Info("Closing remote session")
163+
l.Info("Closing standalone session")
162164
if err := remoteDb.Close(ctx); err != nil {
163165
l.WithError(err).Error("Cannot close database connection:", err)
164166
}
@@ -170,15 +172,15 @@ func (pge *PgEngine) SetRole(ctx context.Context, executor executor, runUID pgty
170172
if !runUID.Valid || strings.TrimSpace(runUID.String) == "" {
171173
return nil
172174
}
173-
log.GetLogger(ctx).Info("Setting Role to ", runUID.String)
175+
log.GetLogger(ctx).Info("Setting role to ", runUID.String)
174176
_, err := executor.Exec(ctx, fmt.Sprintf("SET ROLE %v", runUID.String))
175177
return err
176178
}
177179

178180
// ResetRole - RESET forms reset the current user identifier to be the current session user identifier
179181
func (pge *PgEngine) ResetRole(ctx context.Context, executor executor) {
180182
l := log.GetLogger(ctx)
181-
l.Info("Resetting Role")
183+
l.Info("Resetting role")
182184
_, err := executor.Exec(ctx, `RESET ROLE`)
183185
if err != nil {
184186
l.WithError(err).Error("Failed to set a role", err)

0 commit comments

Comments
 (0)