-
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
85 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
33 changes: 33 additions & 0 deletions
33
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,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); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
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,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); | ||
} | ||
} |