Open Gedochao opened 1 year ago
What is the problem? Our loggers currently have comprehensive stacktrace printing and exception handling for BuildException only, which excludes non-build-related throwables. We should be able to handle those as well, to simplify error handling in the cli layer. https://github.com/VirtusLab/scala-cli/blob/518d63de7592b665c3134b5f2b0905e7a8a4abdc/modules/core/src/main/scala/scala/build/Logger.scala#L27
BuildException
cli
Additionally, our naming for different verbosity levels is slightly off. For example, it requires deeper code knowledge to know the difference between logger.log and logger.message. https://github.com/VirtusLab/scala-cli/blob/518d63de7592b665c3134b5f2b0905e7a8a4abdc/modules/core/src/main/scala/scala/build/Logger.scala#L14 logger.message should probably be named logger.warn. a more standard logging level should probably be in place. For example, we could mimic Log4j's levels, having:
logger.log
logger.message
logger.warn
Additional context Inspired by https://github.com/VirtusLab/scala-cli/pull/1760#discussion_r1065807688
Additional refactor suggestions:
using
logger.warn(msg: String)
[${Console.YELLOW}warn${Console.RESET}] $msg
What is the problem? Our loggers currently have comprehensive stacktrace printing and exception handling for
BuildException
only, which excludes non-build-related throwables. We should be able to handle those as well, to simplify error handling in thecli
layer. https://github.com/VirtusLab/scala-cli/blob/518d63de7592b665c3134b5f2b0905e7a8a4abdc/modules/core/src/main/scala/scala/build/Logger.scala#L27Additionally, our naming for different verbosity levels is slightly off. For example, it requires deeper code knowledge to know the difference between
logger.log
andlogger.message
. https://github.com/VirtusLab/scala-cli/blob/518d63de7592b665c3134b5f2b0905e7a8a4abdc/modules/core/src/main/scala/scala/build/Logger.scala#L14logger.message
should probably be namedlogger.warn
. a more standard logging level should probably be in place. For example, we could mimic Log4j's levels, having:Additional context Inspired by https://github.com/VirtusLab/scala-cli/pull/1760#discussion_r1065807688