How to hook the command window to capture output in real-time?

10 ビュー (過去 30 日間)
Zohar
Zohar 2025 年 6 月 18 日
編集済み: Zohar 2025 年 6 月 19 日
I need a way to hook the command window to capture output in real-time. Probably modify the java ui. I'd like whenever a line (errors included) is written to the command window, it would pass through my callback, and I'll send it to my log.
The motivation is viewing output when running a script from C++ API. I'm flying blind here, and my scripts may take hours. Current solutions such as diary, log file, or returned output from c++ eval() provide output only on completion.
This has been a long standing problem:
Currently, whenever I can, I use my own logger:
However, when calling external libs such as gurobi or ipopt, I don't have control. I could hook each one to write its own log file, but its a hassle.
---
UPDATE
Considering the comments below, the post should be better named:
"How to capture C API output in real-time?"
Related post:
https://www.mathworks.com/matlabcentral/answers/52545-how-can-i-request-an-output-in-real-time-without-interrupting-my-program
  2 件のコメント
Walter Roberson
Walter Roberson 2025 年 6 月 18 日
If I recall correctly, diary() is specifically documented as flushing output no later than end-of-line... but the relevant documentation might be buried in release notes (that are no longer available online...)
Zohar
Zohar 2025 年 6 月 19 日
編集済み: Zohar 2025 年 6 月 19 日
A correction: Diary flushes every line during an interactive session in the command window. However, it records nothing from the C API eval. Hooking the command window won't help me...

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeDesktop についてさらに検索

タグ

製品


リリース

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by