Page 1 of 1

Addins and logging

Posted: Tue Nov 21, 2023 5:17 pm
by madm
I have a an add-in program where I want to use a log to track messages and errors:

Code: Select all

logmode l ... instructions logmsg some stuf ...instructions
But when the the program ends (in an error or otherwise) the log window disappears making it impossible to browse through the list of messages. Is there any way to keep it open?

One workaround I found is to launch a program from the add-in program:

Code: Select all

run .\run.prg
And then set the logging options in run.prg:

Code: Select all

logmode(filename=log.txt) -hideprogline error logmsg program ... do stuff
That will keep all the logmsg text in the log for run.prg after the program completes but not the error messages because the error message all appear in the add-in log, which still disappears.

Re: Addins and logging

Posted: Tue Nov 21, 2023 9:50 pm
by EViews Steve
I'm not sure in what scenario the log window closes, but my test program seems to stick around, even if I introduce an error at the end.
Screenshot 2023-11-21 at 8.48.36 PM.png
Screenshot 2023-11-21 at 8.48.36 PM.png (50.31 KiB) Viewed 15517 times
Try giving your log a name, and it should stay around after a program run.

Code: Select all

logmode(name=mylog) l
Steve

Re: Addins and logging

Posted: Wed Nov 22, 2023 7:14 am
by madm
The log closes when the program is called from an add-in. E.g., my add-in installer program had this command:

Code: Select all

addin(menu="Run project...", desc="Runs the project.", version="0.1") .\run_project.prg
And it's the log for run_project that would close after run_project.prg completed if it was run from the add in menu.

But your suggestion to name the log worked perfectly, so all good. Thanks Steve!