AMC::Basic::debug in user scripts

Added by Matthew Leingang about 7 years ago

I am writing some command line scripts for my AMC jobs. I would like to use the debug utility from AMC::Basic.pm, but just print to STDOUT (or STDERR) rather than to a log file.

By tracing the source, it seems that set_debug($foo) checks first if $foo is the name of an existing file. If so, that file is opened and a package local variable $amc_debug_fh$ is set to write to that file. If $foo is not the name of an existing file, but still evaluates to true, a temporary file is created and $amc_debug_fh is set to write to it. There is a third possibility, which I don't quite get: if $foo equals '', the file handle STDERR is set to point to a local file handle AMC_STDERR_BACKUP (I think).

The debug() routine first checks for a flag $amc_debug and exits if it's not set. If the file handle $amc_debug_fh is set, debugging messages are print to that file handle. If not, debugging messages are print to STDOUT.

But I don't understand which public methods would result in setting $amc_debug to something true and $amc_debug_fh to something false. What am I missing?


Replies (5)

RE: AMC::Basic::debug in user scripts - Added by Alexis Bienvenüe about 7 years ago

You're right: I'm afraid the code has to be cleaned up!

RE: AMC::Basic::debug in user scripts - Added by Matthew Leingang about 7 years ago

That's OK, at least I'm not nuts. I'll just use my own debugging mechanism.

RE: AMC::Basic::debug in user scripts - Added by Alexis Bienvenüe about 7 years ago

From revision hg:1919154fdd29, you should be able to call auto-multiple-choice with --debug-file stdout.

RE: AMC::Basic::debug in user scripts - Added by Matthew Leingang about 7 years ago

Thanks! I use the macports installation of AMC so I will have to wait for that until the next release, I guess.

RE: AMC::Basic::debug in user scripts - Added by Alexis Bienvenüe about 7 years ago

Maybe you can also try the port development version, which is often quite close from the last AMC development version. It does not include hg:1919154fdd29 right now, but this should be the case in a near future.
See Installing AMC development version on macOS.

(1-5/5)