Skip to content
Open
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
4 changes: 4 additions & 0 deletions ConnectionTraceContext.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Updated file content for ConnectionTraceContext.java without ✅ emojis
Comment thread
VinodTech92 marked this conversation as resolved.

// NEW: Add new logging methods
// FIXED: Corrected logging issue
9 changes: 6 additions & 3 deletions src/main/java/com/github/ibm/mapepire/SystemConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ public ConnectionMethod getConnectionMethod() {
private final ClientSpecialRegisters m_clientRegs;
private String m_applicationName;
private final String clientAddress;
private final Tracer m_tracer;

public SystemConnection() throws IOException {
if (!MapepireServer.isSingleMode()) {
Expand All @@ -109,9 +110,10 @@ public SystemConnection() throws IOException {
this.m_clientRegs = clientRegs;
this.clientAddress = clientRegs.getClientAddress();
this.userProfile = System.getProperty("user.name");
this.m_tracer = Tracer.getGlobalTracer(); // Single mode uses global tracer
}

public SystemConnection(String clientHost, String clientAddress, String host, String user, String pass) throws IOException {
public SystemConnection(String clientHost, String clientAddress, String host, String user, String pass, Tracer tracer) throws IOException {
super();
if (MapepireServer.isSingleMode()) {
throw new IOException("Improper usage");
Expand All @@ -130,6 +132,7 @@ public SystemConnection(String clientHost, String clientAddress, String host, St
this.password = pass;
this.clientAddress = clientAddress;
this.m_clientRegs = new ClientSpecialRegistersRemote(clientHost, clientAddress, user);
this.m_tracer = tracer; // Daemon mode uses per-connection tracer
}

public static boolean isRunningOnIBMi() {
Expand All @@ -154,7 +157,7 @@ public String getJdbcJobName() throws SQLException {
}
return c.getClass().getMethod("getServerJobName").invoke(c).toString();
} catch (Exception e) {
Tracer.err(e);
m_tracer.logErr(e);
return "??????/??????/??????";
}
}
Expand All @@ -171,7 +174,7 @@ public synchronized void close() {
try {
m_conn.close();
} catch (SQLException e) {
Tracer.err(e);
m_tracer.logErr(e);
}
m_conn = null;
}
Expand Down
32 changes: 32 additions & 0 deletions src/main/java/com/github/ibm/mapepire/SystemNativeUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.github.ibm.mapepire;

public class SystemNativeUtils {

private static native void writeToJobLog0(final String _msg);

private static native long getPid0();

private static final boolean s_isNativeLoaded;

static {
s_isNativeLoaded = false;
}

public static void writeToJobLog(final Tracer _tracer, final String _msg) {
if (s_isNativeLoaded) {
// TODO: handle messages too long for job log
writeToJobLog0(_msg);
} else {
_tracer.logInfo("Job log message not logged: " + _msg);
}
}

public static void printfToJobLog(final Tracer _tracer, final String _fmt, Object... _repldata) {
writeToJobLog(_tracer, String.format(_fmt, _repldata));
}

public static long getPid() {
return s_isNativeLoaded ? getPid0() : -1L;
}

}
Loading