-
Notifications
You must be signed in to change notification settings - Fork 81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build(core): support scala native + enabled JS tests #909
Merged
justcoon
merged 5 commits into
zio:master
from
ThijsBroersen:feat/core/support-scala-native
Dec 6, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
13e49e5
build(core): support scala native
ThijsBroersen 6e6fd37
add .jvmopts (JDK_JAVA_OPTIONS not working)
ThijsBroersen 03f3543
fix scala-js scala-java-time dependencies
ThijsBroersen 2bc0fd1
wait longer for config to reconfigure logger
ThijsBroersen 10ddb39
update docs
ThijsBroersen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-XX:+PrintCommandLineFlags | ||
-Xss2m | ||
-Xmx6g | ||
-XX:+UseG1GC |
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
18 changes: 18 additions & 0 deletions
18
core/js/src/main/scala/zio/logging/LoggingPackagePlatformSpecific.scala
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,18 @@ | ||
/* | ||
* Copyright 2019-2024 John A. De Goes and the ZIO Contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package zio.logging | ||
|
||
private[logging] trait LoggingPackagePlatformSpecific |
170 changes: 170 additions & 0 deletions
170
core/jvm-native/src/main/scala/zio/logging/FileLoggerLayers.scala
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,170 @@ | ||
/* | ||
* Copyright 2019-2024 John A. De Goes and the ZIO Contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package zio.logging | ||
|
||
import zio.{ Config, NonEmptyChunk, Queue, Runtime, Scope, UIO, ZIO, ZLayer, ZLogger } | ||
|
||
import java.nio.charset.Charset | ||
import java.nio.file.Path | ||
|
||
private[logging] trait FileLoggerLayers { | ||
|
||
def fileAsyncJsonLogger(config: FileLoggerConfig): ZLayer[Any, Nothing, Unit] = | ||
makeFileAsyncJsonLogger(config).installUnscoped | ||
|
||
def fileAsyncJsonLogger(configPath: NonEmptyChunk[String] = loggerConfigPath): ZLayer[Any, Config.Error, Unit] = | ||
FileLoggerConfig.load(configPath).flatMap(makeFileAsyncJsonLogger).installUnscoped | ||
|
||
def fileAsyncLogger(config: FileLoggerConfig): ZLayer[Any, Nothing, Unit] = | ||
makeFileAsyncLogger(config).installUnscoped | ||
|
||
def fileAsyncLogger(configPath: NonEmptyChunk[String] = loggerConfigPath): ZLayer[Any, Config.Error, Unit] = | ||
FileLoggerConfig.load(configPath).flatMap(makeFileAsyncLogger).installUnscoped | ||
|
||
def fileJsonLogger(config: FileLoggerConfig): ZLayer[Any, Nothing, Unit] = | ||
makeFileJsonLogger(config).install | ||
|
||
def fileJsonLogger(configPath: NonEmptyChunk[String] = loggerConfigPath): ZLayer[Any, Config.Error, Unit] = | ||
FileLoggerConfig.load(configPath).flatMap(makeFileJsonLogger).install | ||
|
||
def fileLogger(config: FileLoggerConfig): ZLayer[Any, Nothing, Unit] = | ||
makeFileLogger(config).install | ||
|
||
def fileLogger(configPath: NonEmptyChunk[String] = loggerConfigPath): ZLayer[Any, Config.Error, Unit] = | ||
FileLoggerConfig.load(configPath).flatMap(makeFileLogger).install | ||
|
||
def makeFileAsyncJsonLogger(config: FileLoggerConfig): ZIO[Scope, Nothing, FilteredLogger[String, Any]] = | ||
makeFileAsyncLogger( | ||
config.destination, | ||
config.format.toJsonLogger, | ||
config.charset, | ||
config.autoFlushBatchSize, | ||
config.bufferedIOSize, | ||
config.rollingPolicy | ||
).filter(config.toFilter) | ||
|
||
def makeFileAsyncLogger(config: FileLoggerConfig): ZIO[Scope, Nothing, FilteredLogger[String, Any]] = | ||
makeFileAsyncLogger( | ||
config.destination, | ||
config.format.toLogger, | ||
config.charset, | ||
config.autoFlushBatchSize, | ||
config.bufferedIOSize, | ||
config.rollingPolicy | ||
).filter(config.toFilter) | ||
|
||
def makeFileAsyncLogger( | ||
destination: Path, | ||
logger: ZLogger[String, String], | ||
charset: Charset, | ||
autoFlushBatchSize: Int, | ||
bufferedIOSize: Option[Int], | ||
rollingPolicy: Option[FileLoggerConfig.FileRollingPolicy] | ||
): ZIO[Scope, Nothing, ZLogger[String, Any]] = | ||
for { | ||
queue <- Queue.bounded[UIO[Any]](1000) | ||
_ <- queue.take.flatMap(task => task.ignore).forever.forkScoped | ||
} yield fileWriterAsyncLogger( | ||
destination, | ||
logger, | ||
charset, | ||
autoFlushBatchSize, | ||
bufferedIOSize, | ||
queue, | ||
rollingPolicy | ||
) | ||
|
||
private def fileWriterAsyncLogger( | ||
destination: Path, | ||
logger: ZLogger[String, String], | ||
charset: Charset, | ||
autoFlushBatchSize: Int, | ||
bufferedIOSize: Option[Int], | ||
queue: Queue[UIO[Any]], | ||
rollingPolicy: Option[FileLoggerConfig.FileRollingPolicy] | ||
): ZLogger[String, Any] = { | ||
val logWriter = | ||
new zio.logging.internal.FileWriter(destination, charset, autoFlushBatchSize, bufferedIOSize, rollingPolicy) | ||
|
||
val stringLogger: ZLogger[String, Any] = logger.map { (line: String) => | ||
zio.Unsafe.unsafe { implicit u => | ||
Runtime.default.unsafe.run(queue.offer(ZIO.succeed { | ||
try logWriter.writeln(line) | ||
catch { | ||
case t: VirtualMachineError => throw t | ||
case _: Throwable => () | ||
} | ||
})) | ||
} | ||
} | ||
stringLogger | ||
} | ||
|
||
def makeFileJsonLogger(config: FileLoggerConfig): ZIO[Any, Nothing, FilteredLogger[String, Any]] = | ||
makeFileLogger( | ||
config.destination, | ||
config.format.toJsonLogger, | ||
config.charset, | ||
config.autoFlushBatchSize, | ||
config.bufferedIOSize, | ||
config.rollingPolicy | ||
).filter(config.toFilter) | ||
|
||
def makeFileLogger(config: FileLoggerConfig): ZIO[Any, Nothing, FilteredLogger[String, Any]] = | ||
makeFileLogger( | ||
config.destination, | ||
config.format.toLogger, | ||
config.charset, | ||
config.autoFlushBatchSize, | ||
config.bufferedIOSize, | ||
config.rollingPolicy | ||
).filter(config.toFilter) | ||
|
||
def makeFileLogger( | ||
destination: Path, | ||
logger: ZLogger[String, String], | ||
charset: Charset, | ||
autoFlushBatchSize: Int, | ||
bufferedIOSize: Option[Int], | ||
rollingPolicy: Option[FileLoggerConfig.FileRollingPolicy] | ||
): ZIO[Any, Nothing, ZLogger[String, Any]] = | ||
ZIO.succeed( | ||
fileWriterLogger(destination, logger, charset, autoFlushBatchSize, bufferedIOSize, rollingPolicy) | ||
) | ||
|
||
private def fileWriterLogger( | ||
destination: Path, | ||
logger: ZLogger[String, String], | ||
charset: Charset, | ||
autoFlushBatchSize: Int, | ||
bufferedIOSize: Option[Int], | ||
rollingPolicy: Option[FileLoggerConfig.FileRollingPolicy] | ||
): ZLogger[String, Any] = { | ||
val logWriter = | ||
new zio.logging.internal.FileWriter(destination, charset, autoFlushBatchSize, bufferedIOSize, rollingPolicy) | ||
|
||
val stringLogger: ZLogger[String, Any] = logger.map { (line: String) => | ||
try logWriter.writeln(line) | ||
catch { | ||
case t: VirtualMachineError => throw t | ||
case _: Throwable => () | ||
} | ||
} | ||
|
||
stringLogger | ||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
core/jvm-native/src/main/scala/zio/logging/LoggingPackagePlatformSpecific.scala
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,18 @@ | ||
/* | ||
* Copyright 2019-2024 John A. De Goes and the ZIO Contributors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package zio.logging | ||
|
||
private[logging] trait LoggingPackagePlatformSpecific extends FileLoggerLayers |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this some leftover ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is was rendered in the ci.yaml but not properly picked up in the job. If you check the jobs here then you will see it was picked up but later in the job it still seemed to have only the default 1GB of memory: https://github.com/zio/zio-logging/actions/runs/11993647760/job/33434815940
So for now I added a
.jvmopts
file to fix it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left the commented out part there so it can be fixed. I am not sure where it goes wrong. It prints
NOTE: Picked up JDK_JAVA_OPTIONS: -XX:+PrintCommandLineFlags -Xmx6G -Xss2M -XX:+UseG1GC -XX:G1ConcRefinementThreads=4 -XX:GCDrainStackTargetSize=64 -XX:InitialHeapSize=1073741824 -XX:MaxHeapSize=1073741824 -XX:+PrintCommandLineFlags -XX:ReservedCodeCacheSize=134217728 -XX:ThreadStackSize=4096 -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseG1GC
which shows different InitialHeapSize and MaxHeapSize than the passed Xmx.Locally I have the same issue. I am a bit puzzeled here. With the .jvmopts it is fine.