Re: [Tutor] Logging exceptions, but getting stderr output instead

2016-05-29 Thread Steven D'Aprano
On Wed, May 25, 2016 at 03:44:28PM -0400, Alex Hall wrote: > You're not missing anything; I wasn't clear. I wasn't sure if raise or > sys.exit(1) were the preferred ways, or if there was some other way I > didn't know about. I've never had to force a script to halt before, at > least not one I mean

Re: [Tutor] Logging exceptions, but getting stderr output instead

2016-05-29 Thread Steven D'Aprano
On Wed, May 25, 2016 at 02:11:01PM -0400, Alex Hall wrote: > As a quick aside, is there an easy way to halt script execution for some > exceptions? Right now, catching them means that execution continues, but I > sometimes want to log the problem and then abort the script, as the error > means it

Re: [Tutor] Logging exceptions, but getting stderr output instead

2016-05-26 Thread Terry Carroll
On Wed, 25 May 2016, Alex Hall wrote: You're not missing anything; I wasn't clear. I wasn't sure if raise or sys.exit(1) were the preferred ways, or if there was some other way I didn't know about. If you're aborting because of the exception after unsuccessfully trying to handle it, you can a

Re: [Tutor] Logging exceptions, but getting stderr output instead

2016-05-25 Thread Alex Hall
You're not missing anything; I wasn't clear. I wasn't sure if raise or sys.exit(1) were the preferred ways, or if there was some other way I didn't know about. I've never had to force a script to halt before, at least not one I mean to schedule to run on its own once a day, so wanted to check that

Re: [Tutor] Logging exceptions, but getting stderr output instead

2016-05-25 Thread Alex Hall
Well, I found the major problem: I had logging.exception() not logger.exception() All I can say is, with the screen reader I'm using, they sound similar. Things are now working as expected. I'm still wondering about stopping execution, though: call exit(), raise, or some other way? On Wed, May 25

Re: [Tutor] Logging exceptions, but getting stderr output instead

2016-05-25 Thread Peter Otten
Alex Hall wrote: > Hello again list, > I didn't expect to be back so soon. :) I'm trying to log my new script, > and logger.info() works fine. However, logger.exception() doesn't; I see > the exception print to stderr, and it never appears in the log. Oddly, > info messages after that appear in th

Re: [Tutor] Logging exceptions, but getting stderr output instead

2016-05-25 Thread Alan Gauld via Tutor
On 25/05/16 19:11, Alex Hall wrote: > As a quick aside, is there an easy way to halt script execution for some > exceptions? Right now, catching them means that execution continues, but I > sometimes want to log the problem and then abort the script, as the error > means it shouldn't continue. Tha

[Tutor] Logging exceptions, but getting stderr output instead

2016-05-25 Thread Alex Hall
Hello again list, I didn't expect to be back so soon. :) I'm trying to log my new script, and logger.info() works fine. However, logger.exception() doesn't; I see the exception print to stderr, and it never appears in the log. Oddly, info messages after that appear in the shell and in my log, where