"logfile" accepts environment variables
This commit is contained in:
parent
2eba2fd9ac
commit
33764e349e
@ -212,7 +212,7 @@ Setting a specific logfile
|
|||||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
When instantiating your ``Status`` object, the path to a log file can be
|
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-<pid-of-thread>`` file in your home directory. This is
|
to an ``.i3pystatus-<pid-of-thread>`` file in your home directory. This is
|
||||||
useful in that it helps keep your home directory from becoming cluttered with
|
useful in that it helps keep your home directory from becoming cluttered with
|
||||||
files containing errors.
|
files containing errors.
|
||||||
@ -221,7 +221,7 @@ files containing errors.
|
|||||||
|
|
||||||
from i3pystatus import Status
|
from i3pystatus import Status
|
||||||
|
|
||||||
status = Status(logfile='/home/username/var/i3pystatus.log')
|
status = Status(logfile='$HOME/var/i3pystatus.log')
|
||||||
|
|
||||||
Changing log format
|
Changing log format
|
||||||
~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -70,6 +70,7 @@ class Status:
|
|||||||
if logfile:
|
if logfile:
|
||||||
for handler in logger.handlers:
|
for handler in logger.handlers:
|
||||||
logger.removeHandler(handler)
|
logger.removeHandler(handler)
|
||||||
|
logfile = os.path.expandvars(logfile)
|
||||||
handler = logging.FileHandler(logfile, delay=True)
|
handler = logging.FileHandler(logfile, delay=True)
|
||||||
logger.addHandler(handler)
|
logger.addHandler(handler)
|
||||||
logger.setLevel(logging.CRITICAL)
|
logger.setLevel(logging.CRITICAL)
|
||||||
|
Loading…
Reference in New Issue
Block a user