Addins and logging

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

madm
Posts: 12
Joined: Mon Oct 23, 2017 1:13 pm

Addins and logging

Postby madm » Tue Nov 21, 2023 5:17 pm

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.

EViews Steve
EViews Developer
Posts: 799
Joined: Tue Sep 16, 2008 3:00 pm
Location: Irvine, CA

Re: Addins and logging

Postby EViews Steve » Tue Nov 21, 2023 9:50 pm

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 3127 times

Try giving your log a name, and it should stay around after a program run.

Code: Select all

logmode(name=mylog) l

Steve

madm
Posts: 12
Joined: Mon Oct 23, 2017 1:13 pm

Re: Addins and logging

Postby madm » Wed Nov 22, 2023 7:14 am

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!


Return to “Programming”

Who is online

Users browsing this forum: Google [Bot] and 27 guests