[core] Add debugging capabilities
* If an exception is thrown, catch it and show a (somewhat) nice error message in the i3bar instead of the normal content * Add a flag "-d" for debugging into a debug log. Currently, this only logs commandline calls as they occur and their return values, as well as exceptions. fixes #58
This commit is contained in:
parent
11235d6883
commit
251f8d2e9f
5 changed files with 80 additions and 9 deletions
|
@ -1,6 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
import bumblebee.theme
|
||||
import bumblebee.engine
|
||||
import bumblebee.config
|
||||
|
@ -8,17 +10,42 @@ import bumblebee.output
|
|||
import bumblebee.input
|
||||
|
||||
def main():
|
||||
logging.basicConfig(
|
||||
level=logging.DEBUG,
|
||||
format="[%(asctime)s] %(levelname)-8s %(message)s",
|
||||
filename="{}/debug.log".format(os.path.dirname(os.path.realpath(__file__)))
|
||||
)
|
||||
config = bumblebee.config.Config(sys.argv[1:])
|
||||
theme = bumblebee.theme.Theme(config.theme())
|
||||
output = bumblebee.output.I3BarOutput(theme=theme)
|
||||
inp = bumblebee.input.I3BarInput()
|
||||
engine = bumblebee.engine.Engine(
|
||||
config=config,
|
||||
output=output,
|
||||
inp=inp,
|
||||
)
|
||||
engine = None
|
||||
|
||||
engine.run()
|
||||
try:
|
||||
engine = bumblebee.engine.Engine(
|
||||
config=config,
|
||||
output=output,
|
||||
inp=inp,
|
||||
)
|
||||
engine.run()
|
||||
except BaseException as e:
|
||||
logging.exception(e)
|
||||
if output.started():
|
||||
output.flush()
|
||||
output.end()
|
||||
else:
|
||||
output.start()
|
||||
import time
|
||||
while True:
|
||||
output.begin()
|
||||
error = bumblebee.modules.error.Module(engine, config)
|
||||
error.set("exception occurred: {}".format(e))
|
||||
widget = error.widgets()[0]
|
||||
widget.link_module(error)
|
||||
output.draw(widget, error)
|
||||
output.flush()
|
||||
output.end()
|
||||
time.sleep(1)
|
||||
# try:
|
||||
# except KeyboardInterrupt as error:
|
||||
# inp.stop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue