diff --git a/examples/business-id-runtime/pom.xml b/examples/business-id-runtime/pom.xml
index 4cd2051d7..322678f78 100644
--- a/examples/business-id-runtime/pom.xml
+++ b/examples/business-id-runtime/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
../../pom.xml
teaql-business-id-example
diff --git a/examples/conformance/lib/pom.xml b/examples/conformance/lib/pom.xml
index eae44f2c7..0eabc1b7e 100644
--- a/examples/conformance/lib/pom.xml
+++ b/examples/conformance/lib/pom.xml
@@ -12,7 +12,7 @@
21
4.1.1
- 1.557-RELEASE
+ 6.3.0
UTF-8
true
diff --git a/examples/conformance/pom.xml b/examples/conformance/pom.xml
index 9c5443e6d..f32c5cea9 100644
--- a/examples/conformance/pom.xml
+++ b/examples/conformance/pom.xml
@@ -16,7 +16,7 @@
1.0.0
UTF-8
true
- 1.557-RELEASE
+ 6.3.0
diff --git a/examples/http-resilience/pom.xml b/examples/http-resilience/pom.xml
index 37d50b531..268d843a3 100644
--- a/examples/http-resilience/pom.xml
+++ b/examples/http-resilience/pom.xml
@@ -1,6 +1,6 @@
4.0.0
- io.teaqlteaql-java-parent1.557-RELEASE../../pom.xml
+ io.teaqlteaql-java-parent6.3.0../../pom.xml
teaql-http-resilience-example
io.teaqlteaql-runtime
diff --git a/examples/inheritance-save/pom.xml b/examples/inheritance-save/pom.xml
index 238c7ee43..88c7c5c1d 100644
--- a/examples/inheritance-save/pom.xml
+++ b/examples/inheritance-save/pom.xml
@@ -1,6 +1,6 @@
4.0.0
- io.teaqlteaql-java-parent1.557-RELEASE../../pom.xml
+ io.teaqlteaql-java-parent6.3.0../../pom.xml
io.teaql.examplesinherited-save-example
com.exampleinheritance-matching-service-core0.0.1-SNAPSHOT
diff --git a/examples/object-storage/pom.xml b/examples/object-storage/pom.xml
index 7c082fe5f..57c1768af 100644
--- a/examples/object-storage/pom.xml
+++ b/examples/object-storage/pom.xml
@@ -1,6 +1,6 @@
4.0.0
- io.teaqlteaql-java-parent1.557-RELEASE../../pom.xml
+ io.teaqlteaql-java-parent6.3.0../../pom.xml
teaql-object-storage-example
io.teaqlteaql-runtime
diff --git a/examples/order-management/java-app-console/pom.xml b/examples/order-management/java-app-console/pom.xml
index fcea2c6f4..2c4e154e8 100644
--- a/examples/order-management/java-app-console/pom.xml
+++ b/examples/order-management/java-app-console/pom.xml
@@ -11,7 +11,7 @@
21
UTF-8
- 1.557-RELEASE
+ 6.3.0
diff --git a/examples/order-management/java-lib-core/lib/pom.xml b/examples/order-management/java-lib-core/lib/pom.xml
index 2fcf76bd7..01159a1ff 100644
--- a/examples/order-management/java-lib-core/lib/pom.xml
+++ b/examples/order-management/java-lib-core/lib/pom.xml
@@ -12,7 +12,7 @@
21
4.1.1
- 1.557-RELEASE
+ 6.3.0
UTF-8
true
diff --git a/examples/round-trip-reference-runtime/pom.xml b/examples/round-trip-reference-runtime/pom.xml
index 265b611be..69dde59ef 100644
--- a/examples/round-trip-reference-runtime/pom.xml
+++ b/examples/round-trip-reference-runtime/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
../../pom.xml
teaql-round-trip-reference-example
diff --git a/examples/school-management/lib/pom.xml b/examples/school-management/lib/pom.xml
index 06d3ffb40..982a09839 100644
--- a/examples/school-management/lib/pom.xml
+++ b/examples/school-management/lib/pom.xml
@@ -12,7 +12,7 @@
21
4.1.1
- 1.557-RELEASE
+ 6.3.0
UTF-8
true
diff --git a/examples/school-management/pom.xml b/examples/school-management/pom.xml
index e7c6d0ca2..45e61b182 100644
--- a/examples/school-management/pom.xml
+++ b/examples/school-management/pom.xml
@@ -16,7 +16,7 @@
0.0.1-SNAPSHOT
UTF-8
true
- 1.557-RELEASE
+ 6.3.0
diff --git a/examples/security-foundations/pom.xml b/examples/security-foundations/pom.xml
index 72a89e3eb..043dfb5c2 100644
--- a/examples/security-foundations/pom.xml
+++ b/examples/security-foundations/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
../../pom.xml
teaql-security-foundations-example
diff --git a/examples/shared-load-state/pom.xml b/examples/shared-load-state/pom.xml
index c9cf6df0a..89287c85a 100644
--- a/examples/shared-load-state/pom.xml
+++ b/examples/shared-load-state/pom.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- io.teaqlteaql-java-parent1.557-RELEASE
+ io.teaqlteaql-java-parent6.3.0
../../pom.xml
shared-load-state-example
diff --git a/examples/standard-order/pom.xml b/examples/standard-order/pom.xml
index e68edf37b..ef492e2df 100644
--- a/examples/standard-order/pom.xml
+++ b/examples/standard-order/pom.xml
@@ -3,7 +3,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
io.teaqlteaql-java-parent
- 1.557-RELEASE../../pom.xml
+ 6.3.0../../pom.xml
teaql-standard-order-example
21
diff --git a/examples/trace-chain/lib/pom.xml b/examples/trace-chain/lib/pom.xml
index 20467e3f6..d92318d76 100644
--- a/examples/trace-chain/lib/pom.xml
+++ b/examples/trace-chain/lib/pom.xml
@@ -12,7 +12,7 @@
21
4.1.1
- 1.557-RELEASE
+ 6.3.0
UTF-8
true
@@ -67,7 +67,7 @@
io.teaql
teaql-sqlite
- 1.557-RELEASE
+ 6.3.0
io.teaql
diff --git a/examples/trace-chain/pom.xml b/examples/trace-chain/pom.xml
index 8141f0923..3df008b9c 100644
--- a/examples/trace-chain/pom.xml
+++ b/examples/trace-chain/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
../../pom.xml
teaql-trace-chain-example
diff --git a/pom.xml b/pom.xml
index 98359d085..065bfd24b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
pom
teaql-java-parent
diff --git a/releases/6.3.0.md b/releases/6.3.0.md
new file mode 100644
index 000000000..120d58b2b
--- /dev/null
+++ b/releases/6.3.0.md
@@ -0,0 +1,22 @@
+# 6.3.0: JSON and human runtime logging
+
+Both `json` and `human` logging presentations are supported. JSON remains the
+default. Select the presentation when composing the runtime logger; an explicit
+application option takes precedence over the server `TEAQL_LOG_FORMAT` setting.
+The exact accepted values are `json` and `human`.
+
+Both presentations use the same privacy-safe event projection. Human SQL is
+readable and indented across multiple lines. File output preserves severity,
+UTF-8 whole-event rotation, UTC-day rollover, retention and concurrent writers.
+A non-empty file using the other presentation is rejected before archive changes.
+Plaintext SQL acknowledgement and existing privacy controls retain their meaning.
+
+Choose a fresh destination when changing an existing file's presentation. Existing
+generated APIs do not require regeneration for this logging feature.
+
+
+Tracking: https://github.com/teaql/teaql-java/issues/286; coordinated release https://github.com/teaql/teaql-conformance/issues/248.
+
+Release status and the source, internal-artifact and public-delivery gates are
+recorded separately in teaql/teaql-conformance,
+`evidence/2026-11-18-logging-release`. These notes do not establish publication.
diff --git a/teaql-android/pom.xml b/teaql-android/pom.xml
index 878162428..6f5fd8064 100644
--- a/teaql-android/pom.xml
+++ b/teaql-android/pom.xml
@@ -7,7 +7,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-android
diff --git a/teaql-business-id-jdbc/pom.xml b/teaql-business-id-jdbc/pom.xml
index 0a050b215..1049b6722 100644
--- a/teaql-business-id-jdbc/pom.xml
+++ b/teaql-business-id-jdbc/pom.xml
@@ -7,7 +7,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
../pom.xml
diff --git a/teaql-cloud/pom.xml b/teaql-cloud/pom.xml
index 3f6e2909f..c88013601 100644
--- a/teaql-cloud/pom.xml
+++ b/teaql-cloud/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-cloud
teaql-cloud
diff --git a/teaql-context-runtime-tools/pom.xml b/teaql-context-runtime-tools/pom.xml
index 38ef0c7be..e8ead8b17 100644
--- a/teaql-context-runtime-tools/pom.xml
+++ b/teaql-context-runtime-tools/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-context-runtime-tools
diff --git a/teaql-core/pom.xml b/teaql-core/pom.xml
index 102865067..29e0308dd 100644
--- a/teaql-core/pom.xml
+++ b/teaql-core/pom.xml
@@ -7,7 +7,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
../pom.xml
diff --git a/teaql-data-service-sql/pom.xml b/teaql-data-service-sql/pom.xml
index 2098e1432..5f4179b02 100644
--- a/teaql-data-service-sql/pom.xml
+++ b/teaql-data-service-sql/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
../pom.xml
diff --git a/teaql-db2/pom.xml b/teaql-db2/pom.xml
index 29e94a204..f4d07fd61 100644
--- a/teaql-db2/pom.xml
+++ b/teaql-db2/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-db2
teaql-db2
diff --git a/teaql-dm8/pom.xml b/teaql-dm8/pom.xml
index 29795df7f..95abd08b4 100644
--- a/teaql-dm8/pom.xml
+++ b/teaql-dm8/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-dm8
teaql-dm8
diff --git a/teaql-duckdb/pom.xml b/teaql-duckdb/pom.xml
index 4cececa5a..b4d51a903 100644
--- a/teaql-duckdb/pom.xml
+++ b/teaql-duckdb/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-duckdb
teaql-duckdb
diff --git a/teaql-dynamic-fields-api/pom.xml b/teaql-dynamic-fields-api/pom.xml
index fae9e7f30..e13a83f0c 100644
--- a/teaql-dynamic-fields-api/pom.xml
+++ b/teaql-dynamic-fields-api/pom.xml
@@ -7,7 +7,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
../pom.xml
diff --git a/teaql-dynamic-fields-jdbc/pom.xml b/teaql-dynamic-fields-jdbc/pom.xml
index 17ffdd834..a50e1e70d 100644
--- a/teaql-dynamic-fields-jdbc/pom.xml
+++ b/teaql-dynamic-fields-jdbc/pom.xml
@@ -7,7 +7,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
../pom.xml
diff --git a/teaql-hana/pom.xml b/teaql-hana/pom.xml
index d21269bff..4fdc8a78d 100644
--- a/teaql-hana/pom.xml
+++ b/teaql-hana/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-hana
teaql-hana
diff --git a/teaql-jackson/pom.xml b/teaql-jackson/pom.xml
index affedf4ae..8c1f255fa 100644
--- a/teaql-jackson/pom.xml
+++ b/teaql-jackson/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-jackson
diff --git a/teaql-mssql/pom.xml b/teaql-mssql/pom.xml
index 678bf9c48..14ec88182 100644
--- a/teaql-mssql/pom.xml
+++ b/teaql-mssql/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-mssql
teaql-mssql
diff --git a/teaql-mysql/pom.xml b/teaql-mysql/pom.xml
index ebbc0b5ff..3d5cdbdd4 100644
--- a/teaql-mysql/pom.xml
+++ b/teaql-mysql/pom.xml
@@ -7,7 +7,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-mysql
diff --git a/teaql-object-storage-s3/pom.xml b/teaql-object-storage-s3/pom.xml
index a49b5e369..dd6acd62d 100644
--- a/teaql-object-storage-s3/pom.xml
+++ b/teaql-object-storage-s3/pom.xml
@@ -1,6 +1,6 @@
4.0.0
- io.teaqlteaql-java-parent1.557-RELEASE
+ io.teaqlteaql-java-parent6.3.0
teaql-object-storage-s3
S3-compatible provider for context-owned TeaQL binary object storage
2.55.16
diff --git a/teaql-opentelemetry/pom.xml b/teaql-opentelemetry/pom.xml
index ed0f665be..27c59cd47 100644
--- a/teaql-opentelemetry/pom.xml
+++ b/teaql-opentelemetry/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-opentelemetry
diff --git a/teaql-oracle/pom.xml b/teaql-oracle/pom.xml
index 873b231e0..97a7a0563 100644
--- a/teaql-oracle/pom.xml
+++ b/teaql-oracle/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-oracle
teaql-oracle
diff --git a/teaql-postgres/pom.xml b/teaql-postgres/pom.xml
index 58836c097..4180cb3af 100644
--- a/teaql-postgres/pom.xml
+++ b/teaql-postgres/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-postgres
teaql-postgres
diff --git a/teaql-provider-jdbc/pom.xml b/teaql-provider-jdbc/pom.xml
index 5e8f3d1c0..998f0a792 100644
--- a/teaql-provider-jdbc/pom.xml
+++ b/teaql-provider-jdbc/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
../pom.xml
diff --git a/teaql-provider-spring-jdbc/pom.xml b/teaql-provider-spring-jdbc/pom.xml
index bdb64c528..18efad683 100644
--- a/teaql-provider-spring-jdbc/pom.xml
+++ b/teaql-provider-spring-jdbc/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
../pom.xml
diff --git a/teaql-query-json/pom.xml b/teaql-query-json/pom.xml
index a6979684d..2874d62a7 100644
--- a/teaql-query-json/pom.xml
+++ b/teaql-query-json/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-query-json
diff --git a/teaql-redis/pom.xml b/teaql-redis/pom.xml
index 182345f2c..f345b29ee 100644
--- a/teaql-redis/pom.xml
+++ b/teaql-redis/pom.xml
@@ -7,7 +7,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
../pom.xml
diff --git a/teaql-runtime-log/pom.xml b/teaql-runtime-log/pom.xml
index 4fbcf8fb0..dd6e304fa 100644
--- a/teaql-runtime-log/pom.xml
+++ b/teaql-runtime-log/pom.xml
@@ -6,7 +6,7 @@
io.teaql
teaql-java-parent
- 1.557-RELEASE
+ 6.3.0
teaql-runtime-log
diff --git a/teaql-runtime-log/src/main/java/io/teaql/runtime/log/LogManager.java b/teaql-runtime-log/src/main/java/io/teaql/runtime/log/LogManager.java
index 173e6ea69..37f4cdce8 100644
--- a/teaql-runtime-log/src/main/java/io/teaql/runtime/log/LogManager.java
+++ b/teaql-runtime-log/src/main/java/io/teaql/runtime/log/LogManager.java
@@ -1,342 +1,75 @@
package io.teaql.runtime.log;
-import io.teaql.runtime.config.TeaQLEnv;
-import io.teaql.runtime.RuntimeLogSink;
-import io.teaql.runtime.RawAuditEvent;
+import io.teaql.core.ExecutionMetadata;
import io.teaql.core.TraceNode;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-import java.nio.file.StandardCopyOption;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.time.ZoneId;
-import java.util.Arrays;
-import java.util.Comparator;
+import io.teaql.core.UserContext;
+import io.teaql.runtime.LogPrivacy;
+import io.teaql.runtime.RawAuditEvent;
+import io.teaql.runtime.RuntimeLogSink;
+import io.teaql.runtime.RuntimeLogger;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
import java.util.List;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.zip.GZIPOutputStream;
-import java.io.FileInputStream;
+import java.util.Map;
+/** Optional formatting/custom-sink adapter using the runtime-owned JSONL destination. */
public class LogManager implements RuntimeLogSink {
-
private static final LogManager INSTANCE = new LogManager();
- private static final String EXTREME_TEST_FLAG = "__i_agree_to_disable_runtime_trace_only_for_extreme_performance_testing";
-
- private final String endpoint;
- private final long maxSize;
- private final int maxFiles;
-
- private final BlockingQueue queue;
- private final Thread workerThread;
-
- private FileChannel currentChannel;
- private final AtomicLong currentSize = new AtomicLong(0);
- private final Object fileLock = new Object();
- private long nextMidnightMillis;
- private volatile boolean headerWritten = false;
-
- private String determineEndpoint() {
- String mode = TeaQLEnv.get("TEAQL_TRACE_MODE");
- if ("off".equals(mode)) {
- String ack = TeaQLEnv.get("TEAQL_TRACE_OFF_ACK");
- if (EXTREME_TEST_FLAG.equals(ack)) {
- return "off";
- }
- }
- String val = TeaQLEnv.get("TEAQL_LOG_ENDPOINT");
- if (val != null && !val.trim().isEmpty()) {
- return val;
- }
- String domain = TeaQLEnv.get("TEAQL_DOMAIN");
- if (domain != null && !domain.trim().isEmpty()) {
- return domain.trim() + ".log";
- }
- String command = System.getProperty("sun.java.command");
- String exeName = "teaql";
- if (command != null && !command.trim().isEmpty()) {
- exeName = command.split(" ")[0];
- int lastDot = exeName.lastIndexOf('.');
- if (lastDot >= 0 && lastDot < exeName.length() - 1) {
- exeName = exeName.substring(lastDot + 1);
- }
- }
- return exeName + ".log";
- }
-
- private LogManager() {
- this.endpoint = determineEndpoint();
- this.maxSize = TeaQLEnv.getSizeInBytes("TEAQL_LOG_MAX_SIZE", 50 * 1024 * 1024L); // default 50MB
- this.maxFiles = TeaQLEnv.getInt("TEAQL_LOG_MAX_FILES", 7);
-
- this.queue = new ArrayBlockingQueue<>(10000);
+ private LogManager() { }
+ public static LogManager getInstance() { return INSTANCE; }
- if (!"off".equals(this.endpoint) && !"stdout".equals(this.endpoint)) {
- initFileChannel();
- }
-
- this.workerThread = new Thread(this::processQueue, "TeaQL-LogWriter-Thread");
- this.workerThread.setDaemon(true);
- this.workerThread.start();
-
- Runtime.getRuntime().addShutdownHook(new Thread(() -> {
- // Drain remaining log entries before JVM exits
- Runnable task;
- while ((task = queue.poll()) != null) {
- try { task.run(); } catch (Exception ignored) {}
- }
- synchronized (fileLock) {
- if (currentChannel != null) {
- try { currentChannel.force(true); currentChannel.close(); } catch (Exception ignored) {}
- }
- }
- }, "TeaQL-LogFlush-Shutdown"));
- }
-
- public static LogManager getInstance() {
- return INSTANCE;
- }
-
- @Override
- public boolean requiresSensitiveSqlData() {
+ @Override public boolean requiresSensitiveSqlData() {
return LogConfig.getInstance().includesSensitiveSqlData();
}
- private void calculateNextMidnight() {
- LocalDateTime tomorrowMidnight = LocalDateTime.now().plusDays(1).withHour(0).withMinute(0).withSecond(0).withNano(0);
- this.nextMidnightMillis = tomorrowMidnight.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
- }
-
- private void initFileChannel() {
- synchronized (fileLock) {
- try {
- Path path = Paths.get(this.endpoint);
- if (path.getParent() != null) {
- Files.createDirectories(path.getParent());
- }
- FileOutputStream fos = new FileOutputStream(path.toFile(), true);
- this.currentChannel = fos.getChannel();
- this.currentSize.set(this.currentChannel.size());
- calculateNextMidnight();
- } catch (Exception e) {
- System.err.println("TeaQL LogManager Failed to initialize file channel: " + e.getClass().getSimpleName());
- }
- }
- }
-
- private void processQueue() {
- while (!Thread.currentThread().isInterrupted()) {
- try {
- Runnable task = queue.take();
- task.run();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- break;
- } catch (Exception e) {
- System.err.println("TeaQL LogManager Exception in worker thread: " + e.getClass().getSimpleName());
- }
- }
- }
-
- private void writeHeaderIfNeeded() {
- if (headerWritten || "off".equals(endpoint)) return;
- synchronized (fileLock) {
- if (headerWritten) return;
- try {
- java.net.URL url = getClass().getResource("/log_header.txt");
- String header = "================================================================================\n" +
- "๐ TEAQL Holographic Trace Log\n" +
- "================================================================================";
- if (url != null) {
- try (java.io.InputStream is = url.openStream();
- java.util.Scanner s = new java.util.Scanner(is, StandardCharsets.UTF_8.name()).useDelimiter("\\A")) {
- header = readHeaderOrDefault(s);
- }
- }
- byte[] bytes = (header + "\n").getBytes(StandardCharsets.UTF_8);
- if ("stdout".equals(endpoint)) {
- System.out.print(new String(bytes, StandardCharsets.UTF_8));
- } else if (currentChannel != null) {
- currentChannel.write(ByteBuffer.wrap(bytes));
- currentSize.addAndGet(bytes.length);
- }
- } catch (Exception e) {
- System.err.println("TeaQL LogManager Failed to write header: " + e.getClass().getSimpleName());
- } finally {
- headerWritten = true;
- }
- }
- }
-
- private void asyncWrite(String content, CustomLogSink customSink) {
- if (!queue.offer(() -> syncWrite(content, customSink))) {
- // Queue is full, drop or print to standard error to prevent blocking main business logic
- System.err.println("TeaQL LogManager queue full, dropped log.");
- }
- }
-
- private void syncWrite(String content, CustomLogSink customSink) {
- if (content == null || content.isEmpty()) return;
- if (customSink != null) {
- customSink.onLog(content);
- }
-
- if ("off".equals(endpoint)) return;
- writeHeaderIfNeeded();
-
- byte[] bytes = (content + "\n").getBytes(StandardCharsets.UTF_8);
-
- if ("stdout".equals(endpoint)) {
- System.out.print(new String(bytes, StandardCharsets.UTF_8));
- return;
- }
-
- synchronized (fileLock) {
- if (currentChannel == null) return;
-
- try {
- boolean timeToRotate = System.currentTimeMillis() >= nextMidnightMillis;
- boolean sizeToRotate = currentSize.get() + bytes.length > maxSize;
-
- if (timeToRotate || sizeToRotate) {
- rotateLogFile();
- if (timeToRotate) {
- calculateNextMidnight();
- }
- }
-
- currentChannel.write(ByteBuffer.wrap(bytes));
- currentSize.addAndGet(bytes.length);
- } catch (Exception e) {
- System.err.println("TeaQL LogManager Failed to write to log file: " + e.getClass().getSimpleName());
- }
- }
- }
-
- private void rotateLogFile() {
+ private void custom(UserContext context, String content, RuntimeLogger logger) {
try {
- if (currentChannel != null) {
- currentChannel.close();
- }
-
- File currentFile = new File(endpoint);
- File backupFile = null;
- if (currentFile.exists()) {
- String timestamp = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss"));
- backupFile = new File(endpoint + "." + timestamp);
- Files.move(currentFile.toPath(), backupFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
- }
-
- initFileChannel();
- cleanupOldFiles();
-
- if (backupFile != null && backupFile.exists()) {
- compressAsync(backupFile);
- }
-
- } catch (Exception e) {
- System.err.println("TeaQL LogManager Failed to rotate log file: " + e.getClass().getSimpleName());
+ CustomLogSink sink = resolveCustomSink(context);
+ if (sink != null) sink.onLog(content);
+ } catch (RuntimeException unavailable) {
+ RuntimeLogger.failure(logger.logName(), "custom_log_sink_failed");
}
}
- private void compressAsync(File source) {
- CompletableFuture.runAsync(() -> {
- File target = new File(source.getAbsolutePath() + ".gz");
- try (FileInputStream fis = new FileInputStream(source);
- FileOutputStream fos = new FileOutputStream(target);
- GZIPOutputStream gos = new GZIPOutputStream(fos)) {
-
- byte[] buffer = new byte[8192];
- int len;
- while ((len = fis.read(buffer)) > 0) {
- gos.write(buffer, 0, len);
- }
- gos.finish();
- source.delete();
- } catch (Exception e) {
- System.err.println("TeaQL LogManager Failed to compress log file: " + e.getClass().getSimpleName());
- }
- });
- }
-
- private void cleanupOldFiles() {
- File currentFile = new File(endpoint);
- File parentDir = currentFile.getParentFile();
- if (parentDir == null) {
- parentDir = new File(".");
- }
-
- final String baseName = currentFile.getName();
- File[] files = parentDir.listFiles((dir, name) -> name.startsWith(baseName + "."));
-
- if (files != null && files.length > maxFiles) {
- Arrays.sort(files, Comparator.comparingLong(File::lastModified));
- int filesToDelete = files.length - maxFiles;
- for (int i = 0; i < filesToDelete; i++) {
- if (!files[i].delete()) {
- System.err.println("TeaQL LogManager Failed to delete old log file: " + files[i].getName());
- }
- }
- }
+ @Override public void writeExecutionLog(UserContext context, ExecutionMetadata metadata) {
+ if (!LogConfig.getInstance().shouldLogSql(metadata.getParameterizedQuery())) return;
+ var logger = RuntimeLogger.forContext(context);
+ var safe = LogPrivacy.sql(metadata, requiresSensitiveSqlData() && LogPrivacy.plaintextEnabled());
+ try { custom(context, LogFormatterFactory.getFormatter().formatExecutionLog(safe), logger); }
+ catch (RuntimeException unavailable) { RuntimeLogger.failure(logger.logName(), "log_projection_failed"); }
+ logger.writeSql(safe, requiresSensitiveSqlData());
}
- @Override
- public void writeExecutionLog(io.teaql.core.UserContext context, io.teaql.core.ExecutionMetadata metadata) {
- if (!LogConfig.getInstance().shouldLogSql(metadata.getParameterizedQuery())) {
- return;
- }
- metadata = io.teaql.runtime.LogPrivacy.sql(metadata, io.teaql.runtime.LogPrivacy.plaintextEnabled());
- String content = LogFormatterFactory.getFormatter().formatExecutionLog(metadata);
- CustomLogSink customSink = resolveCustomSink(context);
- asyncWrite(content, customSink);
+ @Override public void writeAuditEvent(UserContext context, RawAuditEvent event) {
+ List changes = event.changes().stream()
+ .map(change -> new FieldChange(change.field(), change.oldValue(), change.newValue())).toList();
+ writeAuditLog(context, event.traceChain(), new AuditEvent(event.entityType(), event.entityId(), event.kind().name(), changes));
}
- @Override
- public void writeAuditEvent(io.teaql.core.UserContext context, RawAuditEvent event) {
- java.util.List changes = event.changes().stream()
- .map(change -> new FieldChange(
- change.field(), change.oldValue(), change.newValue()))
- .collect(java.util.stream.Collectors.toList());
- writeAuditLog(context, event.traceChain(), new AuditEvent(
- event.entityType(), event.entityId(), event.kind().name(), changes));
- }
-
- public void writeAuditLog(io.teaql.core.UserContext context, List traceChain, AuditEvent event) {
- if (!LogConfig.getInstance().shouldLogAudit(event.getEntityType())) {
- return;
- }
- boolean allow = io.teaql.runtime.LogPrivacy.plaintextEnabled();
- java.util.List