Forgive me, still learning how to use the logging
module. So, I have two handlers, one to log everything to a file and one specifically to log the message when triggered into Hipchat.
I don't quite understand what it means to have root vs non-root loggers. As it is below, it will write what I want to my log file AND displays both messages into the hipchat room. So I found another stack post that says to create two multiple "non root loggers." So I tried it with logger = logging.getLogger('test1')
and hipchat_logger = logging.getLogger('test2')
but there's no message in Hipchat (it does write to the log file).
logger = logging.getLogger()
hipchat_logger = logging.getLogger()
# File handler
file_handler = logging.FileHandler("mylog.log", "a")
logger.addHandler(file_handler)
logger.setLevel(logging.DEBUG)
# Hipchat handler
hipchat_handler = hiplogging.HipChatHandler(MY_TOKEN, CHATROOM)
hipchat_handler.setLevel(logging.DEBUG)
hipchat_logger.addHandler(hipchat_handler)
# Testing
logger.info("Hi, this is a test. I should not see this in Hipchat")
hipchat_logger.info("Hi, display me in Hipchat")