-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace System.out with Jboss logging
- Loading branch information
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
runtime/src/main/java/io/quarkiverse/playwright/graal/DriverLoggingSubstitution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.quarkiverse.playwright.graal; | ||
|
||
import java.time.ZonedDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import io.quarkus.logging.Log; | ||
|
||
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 { | ||
|
||
@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); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
runtime/src/main/java/io/quarkiverse/playwright/graal/LoggingSupportSubstitution.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package io.quarkiverse.playwright.graal; | ||
|
||
import java.time.ZonedDateTime; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import io.quarkus.logging.Log; | ||
|
||
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 { | ||
|
||
@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); | ||
} | ||
} |