diff --git a/README.md b/README.md index d790cf0..0db8276 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,11 @@ Just add the dependency as `test` to pom.xml: ${playwright.version} test + + io.quarkus + quarkus-junit5 + test + ``` Write your tests: ````java diff --git a/docs/modules/ROOT/pages/index.adoc b/docs/modules/ROOT/pages/index.adoc index a858fea..fb4ce45 100644 --- a/docs/modules/ROOT/pages/index.adoc +++ b/docs/modules/ROOT/pages/index.adoc @@ -21,6 +21,11 @@ Just add the dependency as `test` to your `pom.xml`: {project-version} test + + io.quarkus + quarkus-junit5 + test + ---- Write your tests: diff --git a/runtime/src/main/java/io/quarkiverse/playwright/graal/DriverLoggingSubstitution.java b/runtime/src/main/java/io/quarkiverse/playwright/graal/DriverLoggingSubstitution.java new file mode 100644 index 0000000..9a49701 --- /dev/null +++ b/runtime/src/main/java/io/quarkiverse/playwright/graal/DriverLoggingSubstitution.java @@ -0,0 +1,33 @@ +package io.quarkiverse.playwright.graal; + +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +import org.jboss.logging.Logger; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +/** + * Replace System.err.println with Jboss Logging. + */ +@TargetClass(className = "com.microsoft.playwright.impl.driver.DriverLogging") +final class DriverLoggingSubstitution { + private static final Logger log = Logger.getLogger("Playwright Driver"); + + @Alias + private static boolean isEnabled; + + @Alias + private static DateTimeFormatter timestampFormat; + + @Substitute + static void logWithTimestamp(String message) { + if (!isEnabled) { + return; + } + String timestamp = ZonedDateTime.now().format(timestampFormat); + log.infof("%s %s", timestamp, message); + } +} \ No newline at end of file diff --git a/runtime/src/main/java/io/quarkiverse/playwright/graal/LoggingSupportSubstitution.java b/runtime/src/main/java/io/quarkiverse/playwright/graal/LoggingSupportSubstitution.java new file mode 100644 index 0000000..01ab801 --- /dev/null +++ b/runtime/src/main/java/io/quarkiverse/playwright/graal/LoggingSupportSubstitution.java @@ -0,0 +1,42 @@ +package io.quarkiverse.playwright.graal; + +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +import org.jboss.logging.Logger; + +import com.oracle.svm.core.annotate.Alias; +import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.annotate.TargetClass; + +/** + * Replace System.out.println with Jboss Logging. + */ +@TargetClass(className = "com.microsoft.playwright.impl.LoggingSupport") +final class LoggingSupportSubstitution { + private static final Logger log = Logger.getLogger("Playwright"); + + @Alias + private static boolean isEnabled; + + @Alias + private static DateTimeFormatter timestampFormat; + + @Substitute + static void logWithTimestamp(String message) { + String timestamp = ZonedDateTime.now().format(timestampFormat); + log.infof("%s %s", timestamp, message); + } + + @Substitute + static void logApiIfEnabled(String message) { + if (isEnabled) { + logApi(message); + } + } + + @Substitute + static void logApi(String message) { + logWithTimestamp("pw:api " + message); + } +} \ No newline at end of file