[core] Make logging work in (hopefully) all situations
* Unless debugging has been enabled, log to stderr (i.e. do *not* try to open a file) * When debugging into a file, choose a location that is likely to be writeable by the user (i.e. the user's home directory) * Location of the logfile can also be specified fixes #62
This commit is contained in:
parent
e5db3d825d
commit
fd448972df
1 changed files with 14 additions and 5 deletions
|
@ -11,12 +11,21 @@ import bumblebee.input
|
||||||
import bumblebee.modules.error
|
import bumblebee.modules.error
|
||||||
|
|
||||||
def main():
|
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:])
|
config = bumblebee.config.Config(sys.argv[1:])
|
||||||
|
|
||||||
|
if config.debug():
|
||||||
|
logging.basicConfig(
|
||||||
|
level=logging.DEBUG,
|
||||||
|
format="[%(asctime)s] %(levelname)-8s %(message)s",
|
||||||
|
filename=os.path.expanduser(config.logfile())
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
logging.basicConfig(
|
||||||
|
level=logging.DEBUG,
|
||||||
|
format="[%(asctime)s] %(levelname)-8s %(message)s",
|
||||||
|
stream=sys.stderr
|
||||||
|
)
|
||||||
|
|
||||||
theme = bumblebee.theme.Theme(config.theme())
|
theme = bumblebee.theme.Theme(config.theme())
|
||||||
output = bumblebee.output.I3BarOutput(theme=theme)
|
output = bumblebee.output.I3BarOutput(theme=theme)
|
||||||
inp = bumblebee.input.I3BarInput()
|
inp = bumblebee.input.I3BarInput()
|
||||||
|
|
Loading…
Reference in a new issue