File tree Expand file tree Collapse file tree 12 files changed +54
-17
lines changed
constants/src/mill/constants
bsp-server/resources/snapshots
extended/idea/mill_modules
hello-idea/idea/mill_modules Expand file tree Collapse file tree 12 files changed +54
-17
lines changed Original file line number Diff line number Diff line change 1+ package mill .api
2+
3+ import mill .api .daemon .experimental
4+
5+ import java .io .{ByteArrayOutputStream , PrintStream }
6+
7+ @ experimental
8+ object Debug {
9+ def apply [T ](
10+ x : sourcecode.Text [T ],
11+ tag : String = " " ,
12+ width : Int = 100 ,
13+ height : Int = 500 ,
14+ indent : Int = 2 ,
15+ escapeUnicode : Boolean = true ,
16+ showFieldNames : Boolean = true
17+ )(implicit line : sourcecode.Line , fileName : sourcecode.FileName ): T = {
18+
19+ val baos = new ByteArrayOutputStream ()
20+ pprint.logTo(
21+ x,
22+ tag,
23+ width,
24+ height,
25+ indent,
26+ escapeUnicode,
27+ showFieldNames,
28+ new PrintStream (baos)
29+ )
30+ mill.constants.DebugLog .println(baos.toString)
31+ x.value
32+ }
33+ }
Original file line number Diff line number Diff line change @@ -14,6 +14,10 @@ public static synchronized void apply(String s) {
1414 }
1515
1616 public static synchronized void println (String s ) {
17+ if (System .getenv ("CI" ) != null ) {
18+ throw new RuntimeException ("DebugLog cannot be run in CI" );
19+ }
20+
1721 Path path = Paths .get (System .getProperty ("user.home" ), "mill-debug-log.txt" );
1822 try {
1923 if (!Files .exists (path )) Files .createFile (path );
Original file line number Diff line number Diff line change @@ -33,9 +33,9 @@ The following table contains the main ways you can test the code in
3333
3434In general, `println` or `pprint.log` should work in most places and be sufficient for
3535instrumenting and debugging the Mill codebase. In the occasional spot where `println`
36- doesn't work you can use `mill.constants.DebugLog.println` which writes to a file
37- `~/mill-debug-log.txt` in your home folder. `DebugLog` is useful for scenarios like
38- debugging Mill's terminal UI (where `println` would mess things up) or subprocesses
36+ doesn't work you can use `mill.constants.DebugLog.println`/`mill.api.Debug` which writes
37+ to a file `~/mill-debug-log.txt` in your home folder. `DebugLog` is useful for scenarios
38+ like debugging Mill's terminal UI (where `println` would mess things up) or subprocesses
3939(where stdout/stderr may get captured or used and cannot be used to display your own
4040debug statements).
4141
Original file line number Diff line number Diff line change 152152 },
153153 "classpath" : [
154154 " file:///coursier-cache/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/<scala3-version>/scala3-library_3-<scala3-version>.jar" ,
155- " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.5 .jar" ,
155+ " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.6 .jar" ,
156156 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_3/0.11.5/os-lib_3-0.11.5.jar" ,
157157 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/upickle_3/4.4.1/upickle_3-4.4.1.jar" ,
158158 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/requests_3/0.9.0/requests_3-0.9.0.jar" ,
230230 },
231231 "classpath" : [
232232 " file:///coursier-cache/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/<scala3-version>/scala3-library_3-<scala3-version>.jar" ,
233- " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.5 .jar" ,
233+ " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.6 .jar" ,
234234 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_3/0.11.5/os-lib_3-0.11.5.jar" ,
235235 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/upickle_3/4.4.1/upickle_3-4.4.1.jar" ,
236236 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/requests_3/0.9.0/requests_3-0.9.0.jar" ,
Original file line number Diff line number Diff line change 126126 },
127127 "sources" : [
128128 " file:///coursier-cache/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/<scala3-version>/scala3-library_3-<scala3-version>-sources.jar" ,
129- " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.5 -sources.jar" ,
129+ " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.6 -sources.jar" ,
130130 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_3/0.11.5/os-lib_3-0.11.5-sources.jar" ,
131131 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/upickle_3/4.4.1/upickle_3-4.4.1-sources.jar" ,
132132 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/requests_3/0.9.0/requests_3-0.9.0-sources.jar" ,
202202 },
203203 "sources" : [
204204 " file:///coursier-cache/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/<scala3-version>/scala3-library_3-<scala3-version>-sources.jar" ,
205- " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.5 -sources.jar" ,
205+ " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.6 -sources.jar" ,
206206 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_3/0.11.5/os-lib_3-0.11.5-sources.jar" ,
207207 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/upickle_3/4.4.1/upickle_3-4.4.1-sources.jar" ,
208208 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/requests_3/0.9.0/requests_3-0.9.0-sources.jar" ,
Original file line number Diff line number Diff line change 181181 "options" : [],
182182 "classpath" : [
183183 " file:///coursier-cache/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/<scala3-version>/scala3-library_3-<scala3-version>.jar" ,
184- " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.5 .jar" ,
184+ " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.6 .jar" ,
185185 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_3/0.11.5/os-lib_3-0.11.5.jar" ,
186186 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/upickle_3/4.4.1/upickle_3-4.4.1.jar" ,
187187 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/requests_3/0.9.0/requests_3-0.9.0.jar" ,
267267 "options" : [],
268268 "classpath" : [
269269 " file:///coursier-cache/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/<scala3-version>/scala3-library_3-<scala3-version>.jar" ,
270- " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.5 .jar" ,
270+ " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.6 .jar" ,
271271 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_3/0.11.5/os-lib_3-0.11.5.jar" ,
272272 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/upickle_3/4.4.1/upickle_3-4.4.1.jar" ,
273273 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/requests_3/0.9.0/requests_3-0.9.0.jar" ,
Original file line number Diff line number Diff line change 244244 },
245245 "classpath" : [
246246 " file:///coursier-cache/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/<scala3-version>/scala3-library_3-<scala3-version>.jar" ,
247- " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.5 .jar" ,
247+ " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.6 .jar" ,
248248 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_3/0.11.5/os-lib_3-0.11.5.jar" ,
249249 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/upickle_3/4.4.1/upickle_3-4.4.1.jar" ,
250250 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/requests_3/0.9.0/requests_3-0.9.0.jar" ,
367367 },
368368 "classpath" : [
369369 " file:///coursier-cache/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/<scala3-version>/scala3-library_3-<scala3-version>.jar" ,
370- " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.5 .jar" ,
370+ " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.6 .jar" ,
371371 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_3/0.11.5/os-lib_3-0.11.5.jar" ,
372372 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/upickle_3/4.4.1/upickle_3-4.4.1.jar" ,
373373 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/requests_3/0.9.0/requests_3-0.9.0.jar" ,
Original file line number Diff line number Diff line change 9494 "options" : [],
9595 "classpath" : [
9696 " file:///coursier-cache/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/<scala3-version>/scala3-library_3-<scala3-version>.jar" ,
97- " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.5 .jar" ,
97+ " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.6 .jar" ,
9898 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_3/0.11.5/os-lib_3-0.11.5.jar" ,
9999 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/upickle_3/4.4.1/upickle_3-4.4.1.jar" ,
100100 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/requests_3/0.9.0/requests_3-0.9.0.jar" ,
120120 "options" : [],
121121 "classpath" : [
122122 " file:///coursier-cache/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/<scala3-version>/scala3-library_3-<scala3-version>.jar" ,
123- " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.5 .jar" ,
123+ " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/pprint_3/0.9.5/pprint_3-0.9.6 .jar" ,
124124 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/os-lib_3/0.11.5/os-lib_3-0.11.5.jar" ,
125125 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/upickle_3/4.4.1/upickle_3-4.4.1.jar" ,
126126 " file:///coursier-cache/https/repo1.maven.org/maven2/com/lihaoyi/requests_3/0.9.0/requests_3-0.9.0.jar" ,
Original file line number Diff line number Diff line change 9696 <orderEntry type =" library" scope =" RUNTIME" name =" plexus-container-default-2.1.1.jar" level =" project" />
9797 <orderEntry type =" library" scope =" RUNTIME" name =" plexus-io-3.5.1.jar" level =" project" />
9898 <orderEntry type =" library" scope =" RUNTIME" name =" plexus-utils-4.0.2.jar" level =" project" />
99- <orderEntry type =" library" name =" pprint_3-0.9.5 .jar" level =" project" />
99+ <orderEntry type =" library" name =" pprint_3-0.9.6 .jar" level =" project" />
100100 <orderEntry type =" library" name =" requests_3-0.9.0.jar" level =" project" />
101101 <orderEntry type =" library" scope =" RUNTIME" name =" scala-collection-compat_2.13-2.13.0.jar" level =" project" />
102102 <orderEntry type =" library" name =" scala-collection-compat_3-2.12.0.jar" level =" project" />
Original file line number Diff line number Diff line change 9898 <orderEntry type =" library" scope =" RUNTIME" name =" plexus-container-default-2.1.1.jar" level =" project" />
9999 <orderEntry type =" library" scope =" RUNTIME" name =" plexus-io-3.5.1.jar" level =" project" />
100100 <orderEntry type =" library" scope =" RUNTIME" name =" plexus-utils-4.0.2.jar" level =" project" />
101- <orderEntry type =" library" name =" pprint_3-0.9.5 .jar" level =" project" />
101+ <orderEntry type =" library" name =" pprint_3-0.9.6 .jar" level =" project" />
102102 <orderEntry type =" library" name =" requests_3-0.9.0.jar" level =" project" />
103103 <orderEntry type =" library" scope =" RUNTIME" name =" scala-collection-compat_2.13-2.13.0.jar" level =" project" />
104104 <orderEntry type =" library" name =" scala-collection-compat_3-2.12.0.jar" level =" project" />
You can’t perform that action at this time.
0 commit comments