Hey all,
I'm running into a very odd problem. I have an app here, and the GUI
is working. Things are where they should be, my buttons work, print
statements run, timers time... But logging isn't happening at all. I
get one debug statement just before I start creating my GUI, but I
should have dozens after that first one. Since this used to work, and
since my first call to logger.debug works, I know my logger is set up
how it should be. Is there any reason wx might be blocking logging? Is
that even possible? I'm not seeing any exceptions anywhere, so I can't
imagine what else the problem might be. WX is the only thing I can
think of that might have something to do with it. I'm using repeating
timers, but they don't get created until later; WX is the only other
thing that might be doing something funny with threads. Not that that
should interrupt logging to this extent, but I'm honestly out of
ideas. Could WX interfere in any way with loggers? Thanks!
I find it highly unlikely. But just for fun, I took my wxPython + threads article and added logging to find out what happens. It is attached. I tested it and it appeared to update just fine, both from the wx side and from the thread side. You’ll probably need to create a small, runnable example of what you’re doing so we can figure this out.
Mike
wxthreader.py (3.65 KB)
···
On Friday, January 29, 2016 at 10:26:26 AM UTC-6, Alex Hall wrote:
Hey all,
I’m running into a very odd problem. I have an app here, and the GUI
is working. Things are where they should be, my buttons work, print
statements run, timers time… But logging isn’t happening at all. I
get one debug statement just before I start creating my GUI, but I
should have dozens after that first one. Since this used to work, and
since my first call to logger.debug works, I know my logger is set up
how it should be. Is there any reason wx might be blocking logging? Is
that even possible? I’m not seeing any exceptions anywhere, so I can’t
imagine what else the problem might be. WX is the only thing I can
think of that might have something to do with it. I’m using repeating
timers, but they don’t get created until later; WX is the only other
thing that might be doing something funny with threads. Not that that
should interrupt logging to this extent, but I’m honestly out of
ideas. Could WX interfere in any way with loggers? Thanks!
Alex Hall wrote:
Is there any reason wx might be blocking logging? Is that even
possible? I'm not seeing any exceptions anywhere, so I can't imagine
what else the problem might be.
Impossible to say without looking at some code. If you can, please post
a short sample application which demonstrates the problem. If you can't
seem to recreate the issue in a sample application, then you'll have to
track down what is different between your production and sample
applications to solve the problem. Or you can post your production code
here if it isn't too long.
···
--
James Scholes
http://twitter.com/JamesScholes
I was afraid it would be unlikely. I'll try to make an example this
weekend if I don't figure it out.
When I said threads, I mean only timers. I have a little module called
repeating_timer, which does just what it say son the box. Given a
function and an interval, it runs the function every interval seconds
until it gets canceled. However, that doesn't start until the user
clicks the "start" button after choosing an item from my list. I'm not
using pubsub, because I don't know if I even need to. Before any
timers go off--even if I click the button--I should see messages about
creating controls, creating job objects, and so on. Oddly, if I put a
log statement in my main.py file (which is what I run) *after*
app.MainLoop(), that statement logs as the app closes, but there's
nothing from any file except main(). If WX is almost definitely not
the problem, what list do you recommend I ask on so as to not go off
topic here? Thanks.
···
On 1/29/16, Mike Driscoll <kyosohma@gmail.com> wrote:
On Friday, January 29, 2016 at 10:26:26 AM UTC-6, Alex Hall wrote:
Hey all,
I'm running into a very odd problem. I have an app here, and the GUI
is working. Things are where they should be, my buttons work, print
statements run, timers time... But logging isn't happening at all. I
get one debug statement just before I start creating my GUI, but I
should have dozens after that first one. Since this used to work, and
since my first call to logger.debug works, I know my logger is set up
how it should be. Is there any reason wx might be blocking logging? Is
that even possible? I'm not seeing any exceptions anywhere, so I can't
imagine what else the problem might be. WX is the only thing I can
think of that might have something to do with it. I'm using repeating
timers, but they don't get created until later; WX is the only other
thing that might be doing something funny with threads. Not that that
should interrupt logging to this extent, but I'm honestly out of
ideas. Could WX interfere in any way with loggers? Thanks!I find it highly unlikely. But just for fun, I took my wxPython + threads
article and added logging to find out what happens. It is attached. I
tested it and it appeared to update just fine, both from the wx side and
from the thread side. You'll probably need to create a small, runnable
example of what you're doing so we can figure this out.Mike
--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi, Alex,
I was afraid it would be unlikely. I'll try to make an example this
weekend if I don't figure it out.When I said threads, I mean only timers. I have a little module called
repeating_timer, which does just what it say son the box. Given a
function and an interval, it runs the function every interval seconds
until it gets canceled. However, that doesn't start until the user
clicks the "start" button after choosing an item from my list. I'm not
using pubsub, because I don't know if I even need to. Before any
timers go off--even if I click the button--I should see messages about
creating controls, creating job objects, and so on. Oddly, if I put a
log statement in my main.py file (which is what I run) *after*
app.MainLoop(), that statement logs as the app closes, but there's
nothing from any file except main(). If WX is almost definitely not
the problem, what list do you recommend I ask on so as to not go off
topic here? Thanks.
Do you use standard python logger?
Which OS and wxPython version do you use?
In you original post you said that it used to work. What wxPython
version was working?
Thank you.
···
On Fri, Jan 29, 2016 at 1:06 PM, Alex Hall <ahall@autodist.com> wrote:
On 1/29/16, Mike Driscoll <kyosohma@gmail.com> wrote:
On Friday, January 29, 2016 at 10:26:26 AM UTC-6, Alex Hall wrote:
Hey all,
I'm running into a very odd problem. I have an app here, and the GUI
is working. Things are where they should be, my buttons work, print
statements run, timers time... But logging isn't happening at all. I
get one debug statement just before I start creating my GUI, but I
should have dozens after that first one. Since this used to work, and
since my first call to logger.debug works, I know my logger is set up
how it should be. Is there any reason wx might be blocking logging? Is
that even possible? I'm not seeing any exceptions anywhere, so I can't
imagine what else the problem might be. WX is the only thing I can
think of that might have something to do with it. I'm using repeating
timers, but they don't get created until later; WX is the only other
thing that might be doing something funny with threads. Not that that
should interrupt logging to this extent, but I'm honestly out of
ideas. Could WX interfere in any way with loggers? Thanks!I find it highly unlikely. But just for fun, I took my wxPython + threads
article and added logging to find out what happens. It is attached. I
tested it and it appeared to update just fine, both from the wx side and
from the thread side. You'll probably need to create a small, runnable
example of what you're doing so we can figure this out.Mike
--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I'm on Windows 7, Python 2.7, WX 3.0.2.0. This is the version I've
been using the whole time; something changed in my code to make it not
work.
Interestingly, I just did a little experiment. I made a very simple
"test" script and called it from my main script.
#test.py
import logging
logger = logging.getLogger(__name__) #main.py has already configured a logger
def logSomething():
print("About to log in test module") #this line prints as expected
logger.info("Just saying hello.") #this line does nothing
It prints when main.py calls it, but it doesn't log. At least I know
it's not my GUI. Sorry for the false alarm, but I couldn't find
anything online about others having a problem where logging.getLogger
wouldn't print to the file configured for that session, so i thought
it might be WX doing something I hadn't counted on. Apparently not. In
case anyone's interested, here's my logging setup from main.py:
import globals
import logging
import test
#set up the logger for the app
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
logFilename = globals.appName+", debug log.log" #appears in the same
directory as main.py
logFileHandler = logging.FileHandler(logFilename, mode="w")
logFileHandler.level = logging.DEBUG
logFormatter = logging.Formatter("%(asctime)s\n%(name)s,
%(levelname)s: %(message)s", datefmt = "%I:%M:%S %p, %B %d, %Y")
logFileHandler.setFormatter(logFormatter)
logger.addHandler(logFileHandler)
test.logSomething() #prints, but doesn't log
When I saved the above as main2.py and ran it, it did exactly the same
thing--no log from test.py. *shrug*
···
On 1/29/16, Igor Korot <ikorot01@gmail.com> wrote:
Hi, Alex,
On Fri, Jan 29, 2016 at 1:06 PM, Alex Hall <ahall@autodist.com> wrote:
I was afraid it would be unlikely. I'll try to make an example this
weekend if I don't figure it out.When I said threads, I mean only timers. I have a little module called
repeating_timer, which does just what it say son the box. Given a
function and an interval, it runs the function every interval seconds
until it gets canceled. However, that doesn't start until the user
clicks the "start" button after choosing an item from my list. I'm not
using pubsub, because I don't know if I even need to. Before any
timers go off--even if I click the button--I should see messages about
creating controls, creating job objects, and so on. Oddly, if I put a
log statement in my main.py file (which is what I run) *after*
app.MainLoop(), that statement logs as the app closes, but there's
nothing from any file except main(). If WX is almost definitely not
the problem, what list do you recommend I ask on so as to not go off
topic here? Thanks.Do you use standard python logger?
Which OS and wxPython version do you use?
In you original post you said that it used to work. What wxPython
version was working?Thank you.
On 1/29/16, Mike Driscoll <kyosohma@gmail.com> wrote:
On Friday, January 29, 2016 at 10:26:26 AM UTC-6, Alex Hall wrote:
Hey all,
I'm running into a very odd problem. I have an app here, and the GUI
is working. Things are where they should be, my buttons work, print
statements run, timers time... But logging isn't happening at all. I
get one debug statement just before I start creating my GUI, but I
should have dozens after that first one. Since this used to work, and
since my first call to logger.debug works, I know my logger is set up
how it should be. Is there any reason wx might be blocking logging? Is
that even possible? I'm not seeing any exceptions anywhere, so I can't
imagine what else the problem might be. WX is the only thing I can
think of that might have something to do with it. I'm using repeating
timers, but they don't get created until later; WX is the only other
thing that might be doing something funny with threads. Not that that
should interrupt logging to this extent, but I'm honestly out of
ideas. Could WX interfere in any way with loggers? Thanks!I find it highly unlikely. But just for fun, I took my wxPython +
threads
article and added logging to find out what happens. It is attached. I
tested it and it appeared to update just fine, both from the wx side and
from the thread side. You'll probably need to create a small, runnable
example of what you're doing so we can figure this out.Mike
--
You received this message because you are subscribed to the Google
Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send
an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I would suggest that, after creating your loggers, you check the value
of logger.name, or the __name__ builtin. You'll see that in your
main.py module, the logger has a name of '__main__', because that is the
value of __name__. But in test.py, __name__ is set to 'test'. In other
words, there is absolutely no relationship between them. Python has no
way of knowing that a logger called test is related to a logger called
__main__. So your logging code in test.py does nothing, because there
is no logging configuration for that module. That is undoubtedly what's
going wrong in your app's production code also.
···
--
James Scholes
http://twitter.com/JamesScholes
Okay, you're right! I'd tried, in main.py:
logger = logging.getLogger(globals.appName+"."+__name__)
but that didn't work either. Suddenly, it clicked: the first instance
of logging.Logger that gets created must have the root name. I changed
it to
logger = logging.getLogger(globals.appName)
and all other modules to
logger = logging.getLogger(globals.appName+"."+__name__)
and now it runs as expected. I thought the first Logger to be made in
a given session became the one returned by getLogger() thereafter for
any module, I didn't realize the names were so vital. It makes perfect
sense now, though. Thanks for your patience with what wound up being
an OT thread.
···
On 1/29/16, James Scholes <james@jls-radio.com> wrote:
I would suggest that, after creating your loggers, you check the value
of logger.name, or the __name__ builtin. You'll see that in your
main.py module, the logger has a name of '__main__', because that is the
value of __name__. But in test.py, __name__ is set to 'test'. In other
words, there is absolutely no relationship between them. Python has no
way of knowing that a logger called test is related to a logger called
__main__. So your logging code in test.py does nothing, because there
is no logging configuration for that module. That is undoubtedly what's
going wrong in your app's production code also.
--
James Scholes
x.com--
You received this message because you are subscribed to the Google Groups
"wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to wxpython-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.