File tree Expand file tree Collapse file tree 7 files changed +44
-7
lines changed
constants/src/mill/constants
integration/ide/gen-idea/resources
extended/idea/mill_modules
hello-idea/idea/mill_modules Expand file tree Collapse file tree 7 files changed +44
-7
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 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" />
Original file line number Diff line number Diff line change 9292 <orderEntry type =" library" scope =" RUNTIME" name =" plexus-container-default-2.1.1.jar" level =" project" />
9393 <orderEntry type =" library" scope =" RUNTIME" name =" plexus-io-3.5.1.jar" level =" project" />
9494 <orderEntry type =" library" scope =" RUNTIME" name =" plexus-utils-4.0.2.jar" level =" project" />
95- <orderEntry type =" library" name =" pprint_3-0.9.5 .jar" level =" project" />
95+ <orderEntry type =" library" name =" pprint_3-0.9.6 .jar" level =" project" />
9696 <orderEntry type =" library" name =" requests_3-0.9.0.jar" level =" project" />
9797 <orderEntry type =" library" scope =" RUNTIME" name =" scala-collection-compat_2.13-2.13.0.jar" level =" project" />
9898 <orderEntry type =" library" name =" scala-collection-compat_3-2.12.0.jar" level =" project" />
Original file line number Diff line number Diff line change @@ -140,7 +140,7 @@ object Deps {
140140 val osLibVersion = " 0.11.5"
141141 val osLib = mvn " com.lihaoyi::os-lib: $osLibVersion"
142142 val osLibWatch = mvn " com.lihaoyi::os-lib-watch: $osLibVersion"
143- val pprint = mvn " com.lihaoyi::pprint:0.9.5 "
143+ val pprint = mvn " com.lihaoyi::pprint:0.9.6 "
144144 val mainargs = mvn " com.lihaoyi::mainargs:0.7.7 "
145145 val millModuledefsVersion = " 0.12.3"
146146 val millModuledefsString = s " com.lihaoyi::mill-moduledefs: ${millModuledefsVersion}"
You can’t perform that action at this time.
0 commit comments