diff --git a/docs/configuration.rst b/docs/configuration.rst index 00fe43d..628f579 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -212,7 +212,7 @@ Setting a specific logfile ~~~~~~~~~~~~~~~~~~~~~~~~~~ When instantiating your ``Status`` object, the path to a log file can be -specified. If this is done, then log messages will be sent to that file and not +specified (it accepts environment variables). If this is done, then log messages will be sent to that file and not to an ``.i3pystatus-`` file in your home directory. This is useful in that it helps keep your home directory from becoming cluttered with files containing errors. @@ -221,7 +221,7 @@ files containing errors. from i3pystatus import Status - status = Status(logfile='/home/username/var/i3pystatus.log') + status = Status(logfile='$HOME/var/i3pystatus.log') Changing log format ~~~~~~~~~~~~~~~~~~~ diff --git a/i3pystatus/core/__init__.py b/i3pystatus/core/__init__.py index 1c0a9d1..74967dc 100644 --- a/i3pystatus/core/__init__.py +++ b/i3pystatus/core/__init__.py @@ -70,6 +70,7 @@ class Status: if logfile: for handler in logger.handlers: logger.removeHandler(handler) + logfile = os.path.expandvars(logfile) handler = logging.FileHandler(logfile, delay=True) logger.addHandler(handler) logger.setLevel(logging.CRITICAL)