@@ -19,11 +19,14 @@ import com.intellij.ui.awt.RelativePoint
1919import com.intellij.util.ui.JBFont
2020import java.awt.Point
2121import javax.swing.event.HyperlinkEvent
22+ import mu.KotlinLogging
2223
2324abstract class Notifier {
25+ protected val logger = KotlinLogging .logger {}
26+
2427 protected abstract val notificationType: NotificationType
2528 protected abstract val displayId: String
26- protected abstract fun content (project : Project ? , module : Module ? , info : String ): String
29+ protected open fun content (project : Project ? , module : Module ? , info : String ): String = info
2730
2831 open fun notify (info : String , project : Project ? = null, module : Module ? = null) {
2932 notificationGroup
@@ -47,15 +50,28 @@ abstract class WarningNotifier : Notifier() {
4750abstract class ErrorNotifier : Notifier () {
4851 final override val notificationType: NotificationType = NotificationType .ERROR
4952
50- final override fun notify (info : String , project : Project ? , module : Module ? ) {
53+ override fun notify (info : String , project : Project ? , module : Module ? ) {
5154 super .notify(info, project, module)
5255 error(content(project, module, info))
5356 }
5457}
5558
5659object CommonErrorNotifier : ErrorNotifier() {
5760 override val displayId: String = " UTBot plugin errors"
58- override fun content (project : Project ? , module : Module ? , info : String ): String = info
61+ }
62+
63+ class CommonLoggingNotifier (val type : NotificationType = NotificationType .WARNING ) : Notifier() {
64+ override val displayId: String = " UTBot plugin errors"
65+ override val notificationType = type
66+
67+ override fun notify (info : String , project : Project ? , module : Module ? ) {
68+ super .notify(info, project, module)
69+ when (notificationType) {
70+ NotificationType .WARNING -> logger.warn(content(project, module, info))
71+ NotificationType .INFORMATION -> logger.info(content(project, module, info))
72+ else -> logger.error(content(project, module, info))
73+ }
74+ }
5975}
6076
6177object UnsupportedJdkNotifier : ErrorNotifier() {
@@ -113,8 +129,6 @@ object SarifReportNotifier : EventLogNotifier() {
113129 override val titleText: String = " " // no title
114130
115131 override val urlOpeningListener: NotificationListener = NotificationListener .UrlOpeningListener (false )
116-
117- override fun content (project : Project ? , module : Module ? , info : String ): String = info
118132}
119133
120134object TestsReportNotifier : InformationUrlNotifier() {
@@ -123,8 +137,6 @@ object TestsReportNotifier : InformationUrlNotifier() {
123137 override val titleText: String = " UTBot: unit tests generated successfully"
124138
125139 public override val urlOpeningListener: TestReportUrlOpeningListener = TestReportUrlOpeningListener
126-
127- override fun content (project : Project ? , module : Module ? , info : String ): String = info
128140}
129141
130142// TODO replace inheritance with decorators
@@ -134,8 +146,6 @@ object WarningTestsReportNotifier : WarningUrlNotifier() {
134146 override val titleText: String = " UTBot: unit tests generated with warnings"
135147
136148 public override val urlOpeningListener: TestReportUrlOpeningListener = TestReportUrlOpeningListener
137-
138- override fun content (project : Project ? , module : Module ? , info : String ): String = info
139149}
140150
141151object DetailsTestsReportNotifier : EventLogNotifier() {
@@ -144,8 +154,6 @@ object DetailsTestsReportNotifier : EventLogNotifier() {
144154 override val titleText: String = " Test report details of the unit tests generation via UtBot"
145155
146156 public override val urlOpeningListener: TestReportUrlOpeningListener = TestReportUrlOpeningListener
147-
148- override fun content (project : Project ? , module : Module ? , info : String ): String = info
149157}
150158
151159/* *
0 commit comments