Skip to content
Merged
Show file tree
Hide file tree
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
18 changes: 18 additions & 0 deletions src/main/java/com/microsoft/sqlserver/jdbc/SQLServerDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,24 @@ public SQLServerDriver() {
loggingClassName = "com.microsoft.sqlserver.jdbc." + "SQLServerDriver:" + instanceID;
}

/**
* Registers a global performance log callback.
*
* @param cb The callback to register.
* @throws IllegalStateException if a callback is already registered.
*/
public static synchronized void registerPerformanceLogCallback(PerformanceLogCallback cb) {
PerformanceLog.registerCallback(cb);
}

/**
* Unregisters the global performance log callback.
*/
public static synchronized void unregisterPerformanceLogCallback() {
PerformanceLog.unregisterCallback();
}


/**
* Provides Helper function used to fix the case sensitivity, synonyms and remove unknown tokens from the
* properties.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void publish(PerformanceActivity activity, int connectionId, int statemen
}
};

PerformanceLog.registerCallback(callbackInstance);
SQLServerDriver.registerPerformanceLogCallback(callbackInstance);

try (Connection con = getConnection()) {
DatabaseMetaData metaData = con.getMetaData();
Expand All @@ -87,7 +87,7 @@ public void publish(PerformanceActivity activity, int connectionId, int statemen
assertTrue(Files.exists(logPath), "performance.log file should exist");
System.out.println("Log file absolute path: " + logPath.toAbsolutePath());

PerformanceLog.unregisterCallback();
SQLServerDriver.unregisterPerformanceLogCallback();

}
}