Closed Teque5 closed 5 years ago
They are in two tabs because you're creating two handlers. Each handler is a separate connection.
How I would structure your code:
import logging
from logging.handlers import SocketHandler
root_logger = logging.getLogger('fruit')
socket_handler = SocketHandler('127.0.0.1', 19996)
root_logger.addHandler(socket_handler)
apple_logger = root_logger.getChild('apple')
banana_logger = root_logger.getChild('banana')
apple_logger.error('apples are great')
banana_logger.error('peanutbutterjelly')
The way I do it is I always pass the parent logger to my objects and then they create their own child loggers (which then can become parent loggers for objects they create).
In this case I would pass root_logger
to Apple
and Banana
objects, and then they would pass the child loggers they created to BananaPeel
and AppleStem
, for example.
EDIT: I just noticed you said you were running two terminals. In this case there are two solutions:
File -> Single tab mode
or in Server settings)Ah I think what I was missing was the 'single tab mode' for this problem. Thanks.
Does cutelog support logging from multiple threads? If I run each of these in two terminals:
I expect to see them in the same cutlog tab, but instead I get two tabs, one with fruit.apple and the other with fruit.banana. Am I missing something?