Plain text file in TFile

Hi everyone,

My program creates a TFile with some objects in it, I would also like to include a log file in it with some notes (plain text), instead of creating a separate .txt file. What’s the best way to do this?

Use the TMacro class.

//TFile is already opened, "/tmp/log.txt" already available.
TMacro ma("/tmp/log.txt","My Log File");
ma.Write();

If you prefer to write your log file line by line instead of storing it temporarily in a file log.txt, you can use the AddLine method.

In either case, later on, you can open your TFile with a TBrowser, right click on the TMacro object, Print, and you get the output written on the console.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.