Author Topic: Batch file to build Lix, how to catch output  (Read 2488 times)

0 Members and 1 Guest are viewing this topic.

Offline Forestidia86

  • Posts: 723
  • inactive
    • View Profile
Batch file to build Lix, how to catch output
« on: January 07, 2018, 07:33:20 PM »
I don't know if this is the right place to ask this and it is I think Win specific:

But I don't want to use command prompt for building, so I do it via batch file. The problem is that it is then hard to catch error messages since the window closes usually immediately.
So I'd actually like to create a logfile. I know that you can generally use > to get the output to a file. But now my problem: While it catches some messages like concerning the libraries it doesn't seem to catch the actual compiling messages, in particular not compiling errors.
I don't know why and what I can do about it. Has anyone an idea?

Edit: Okay, I think I have found it out myself. For the compiling messages I seem to need to use 2>.
« Last Edit: January 07, 2018, 08:00:48 PM by Forestidia86 »

Offline Simon

  • Administrator
  • Posts: 3876
    • View Profile
    • Lix
Re: Batch file to build Lix, how to catch output
« Reply #1 on: January 07, 2018, 09:47:46 PM »
Redirecting errors is one good solution, yeah. Programs have standard output and a separate error stream.

Alternatively, you should be able to right-click the batch file, properties (Eigenschaften), then find a checkbox to keep the console open after the program has finished running.

Another alternative is to add "pause" without quotes to the end of the batch file. For a debugging build:

Code: [Select]
dub build
pause

For a release build that runs faster, but doesn't produce nice error messages when something fails during runtime:

Code: [Select]
dub build -b release
pause

-- Simon
« Last Edit: January 07, 2018, 09:53:04 PM by Simon »

Offline ccexplore

  • Posts: 5311
    • View Profile
Re: Batch file to build Lix, how to catch output
« Reply #2 on: January 08, 2018, 09:27:12 AM »
Generically speaking, the compiler etc. might also have command line options as well to output errors and/or warnings to files, either in lieu of or in addition to outputting to console, but redirecting stderr as you did seems to work okay in a pinch.  Adding the pause at the end can be useful just to see whether the final output reports success or failure before digging into logs.

Offline Forestidia86

  • Posts: 723
  • inactive
    • View Profile
Re: Batch file to build Lix, how to catch output
« Reply #3 on: January 14, 2018, 04:45:37 AM »
After reading mobius' problems with copying the output from the cmd prompt:
That's one of the reasons why I want to use logfiles for building because I can copy the output (esp. error messages) conveniently from the text files.
Copying from cmd prompt seems convoluted and unintuitive for a Win user. (I know one method is: right click -> choose mark -> mark with mouse movement+ hold left click or with arrow keys+ hold Shift -> press Enter => now the marked text should be in copy buffer and can be pasted.)

Offline Simon

  • Administrator
  • Posts: 3876
    • View Profile
    • Lix
Re: Batch file to build Lix, how to catch output
« Reply #4 on: January 14, 2018, 05:02:17 AM »
Wow, I didn't know the Windows console is that unusable. Good to keep in mind, and important for remote troubleshooting.

You could install bash for Windows or Powershell, but I don't want to recommend anything over cmd. Once somebody benefits from any of those, they could decide themselves what they want.

-- Simon