@@ -19,11 +19,14 @@ import com.intellij.ui.awt.RelativePoint
19
19
import com.intellij.util.ui.JBFont
20
20
import java.awt.Point
21
21
import javax.swing.event.HyperlinkEvent
22
+ import mu.KotlinLogging
22
23
23
24
abstract class Notifier {
25
+ protected val logger = KotlinLogging .logger {}
26
+
24
27
protected abstract val notificationType: NotificationType
25
28
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
27
30
28
31
open fun notify (info : String , project : Project ? = null, module : Module ? = null) {
29
32
notificationGroup
@@ -47,15 +50,28 @@ abstract class WarningNotifier : Notifier() {
47
50
abstract class ErrorNotifier : Notifier () {
48
51
final override val notificationType: NotificationType = NotificationType .ERROR
49
52
50
- final override fun notify (info : String , project : Project ? , module : Module ? ) {
53
+ override fun notify (info : String , project : Project ? , module : Module ? ) {
51
54
super .notify(info, project, module)
52
55
error(content(project, module, info))
53
56
}
54
57
}
55
58
56
59
object CommonErrorNotifier : ErrorNotifier() {
57
60
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
+ }
59
75
}
60
76
61
77
object UnsupportedJdkNotifier : ErrorNotifier() {
@@ -113,8 +129,6 @@ object SarifReportNotifier : EventLogNotifier() {
113
129
override val titleText: String = " " // no title
114
130
115
131
override val urlOpeningListener: NotificationListener = NotificationListener .UrlOpeningListener (false )
116
-
117
- override fun content (project : Project ? , module : Module ? , info : String ): String = info
118
132
}
119
133
120
134
object TestsReportNotifier : InformationUrlNotifier() {
@@ -123,8 +137,6 @@ object TestsReportNotifier : InformationUrlNotifier() {
123
137
override val titleText: String = " UTBot: unit tests generated successfully"
124
138
125
139
public override val urlOpeningListener: TestReportUrlOpeningListener = TestReportUrlOpeningListener
126
-
127
- override fun content (project : Project ? , module : Module ? , info : String ): String = info
128
140
}
129
141
130
142
// TODO replace inheritance with decorators
@@ -134,8 +146,6 @@ object WarningTestsReportNotifier : WarningUrlNotifier() {
134
146
override val titleText: String = " UTBot: unit tests generated with warnings"
135
147
136
148
public override val urlOpeningListener: TestReportUrlOpeningListener = TestReportUrlOpeningListener
137
-
138
- override fun content (project : Project ? , module : Module ? , info : String ): String = info
139
149
}
140
150
141
151
object DetailsTestsReportNotifier : EventLogNotifier() {
@@ -144,8 +154,6 @@ object DetailsTestsReportNotifier : EventLogNotifier() {
144
154
override val titleText: String = " Test report details of the unit tests generation via UtBot"
145
155
146
156
public override val urlOpeningListener: TestReportUrlOpeningListener = TestReportUrlOpeningListener
147
-
148
- override fun content (project : Project ? , module : Module ? , info : String ): String = info
149
157
}
150
158
151
159
/* *
0 commit comments