File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
components/support/base/src/main/java/mozilla/components/support/base/log Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,9 @@ subprojects {
72
72
73
73
// Format test output
74
74
tasks. matching {it instanceof Test }. all {
75
+ systemProperty " robolectric.logging" , " stdout"
76
+ systemProperty " logging.test-mode" , " true"
77
+
75
78
testLogging. events = []
76
79
77
80
def out = services. get(StyledTextOutputFactory ). create(" an-ouput" )
Original file line number Diff line number Diff line change @@ -25,6 +25,8 @@ object Log {
25
25
26
26
private val sinks = mutableListOf<LogSink >()
27
27
28
+ private val testMode: Boolean = System .getProperty(" logging.test-mode" ) == " true"
29
+
28
30
/* *
29
31
* Adds a sink that will receive log calls.
30
32
*/
@@ -56,6 +58,10 @@ object Log {
56
58
}
57
59
}
58
60
}
61
+
62
+ if (testMode) {
63
+ printTestModeMessage(priority, tag, throwable, message)
64
+ }
59
65
}
60
66
61
67
// Only for testing
@@ -67,6 +73,26 @@ object Log {
67
73
}
68
74
}
69
75
76
+ private fun printTestModeMessage (
77
+ priority : Priority ,
78
+ tag : String? ,
79
+ throwable : Throwable ? ,
80
+ message : String?
81
+ ) {
82
+ val printMessage = StringBuilder ()
83
+ printMessage.append(priority.name[0 ])
84
+ printMessage.append(" " )
85
+ if (tag != null ) {
86
+ printMessage.append(" [$tag ] " )
87
+ }
88
+ if (message != null ) {
89
+ printMessage.append(message)
90
+ }
91
+
92
+ println (printMessage.toString())
93
+ throwable?.printStackTrace()
94
+ }
95
+
70
96
/* *
71
97
* Priority constants for logging calls.
72
98
*/
You can’t perform that action at this time.
0 commit comments