Skip to content
Permalink
Browse files

Use XDG Base Directory specification log path

Also discourage from using a hidden log file in $HOME for hacking
  • Loading branch information...
kynikos authored and flacjacket committed Mar 4, 2016
1 parent fd8686e commit 66d704bce83f631b3326f10a1bc9fc22f8e6a6fd
Showing with 17 additions and 5 deletions.
  1. +2 −0 CHANGELOG
  2. +4 −3 CONTRIBUTING.md
  3. +1 −1 docs/manual/hacking.rst
  4. +10 −1 libqtile/log_utils.py
@@ -1,5 +1,7 @@
qtile x.x.x, released xxxx-xx-xx:
* file path changes (XDG Base Directory specification)
- the default log file path changed from ~/.qtile.log to
~/.local/share/qtile/qtile.log
- the cache directory changed from ~/.cache to ~/.cache/qtile
* features
- wlan widget shows when you are disconnected and uses a configurable
@@ -19,9 +19,10 @@ has two qualities:
Do not combine multiple problems even they seem to be similar. Write
different reports for each problem.

To give more information about your bug you can append logs from `~/.qtile.log`
or on occasionally events you can capture bugs with `xtrace` for this have a deeper
look on the documentation about [capturing an xtrace](http://qtile.readthedocs.org/en/latest/manual/hacking.html#capturing-an-xtrace)
To give more information about your bug you can append logs from
`~/.local/share/qtile/qtile.log` or on occasionally events you can capture bugs
with `xtrace` for this have a deeper look on the documentation about
[capturing an xtrace](http://qtile.readthedocs.org/en/latest/manual/hacking.html#capturing-an-xtrace)

Writing code
============
@@ -89,7 +89,7 @@ Qtile's conversations with the X server. To capture one of these, create an

.. code-block:: bash
exec xtrace qtile >> ~/.qtile.log
exec xtrace qtile >> ~/qtile.log
This will put the xtrace output in Qtile's logfile as well. You can then
demonstrate the bug, and paste the contents of this file into the bug report.
@@ -66,7 +66,7 @@ def format(self, record):
return message + self.reset_seq


def init_log(log_level=WARNING, log_path='~/.%s.log', log_truncate=False,
def init_log(log_level=WARNING, log_path=True, log_truncate=False,
log_size=10000000, log_numbackups=1, log_color=True):
formatter = Formatter(
"%(asctime)s %(levelname)s %(name)s %(filename)s:%(funcName)s():L%(lineno)d %(message)s"
@@ -85,6 +85,15 @@ def init_log(log_level=WARNING, log_path='~/.%s.log', log_truncate=False,

# If we have a log path, we'll also setup a log file
if log_path:
if not isinstance(log_path, str):
data_directory = os.path.expandvars('$XDG_DATA_HOME')
if data_directory == '$XDG_DATA_HOME':
# if variable wasn't set
data_directory = os.path.expanduser("~/.local/share")
data_directory = os.path.join(data_directory, 'qtile')
if not os.path.exists(data_directory):
os.makedirs(data_directory)
log_path = os.path.join(data_directory, '%s.log')
try:
log_path %= 'qtile'
except TypeError: # Happens if log_path doesn't contain formatters.

0 comments on commit 66d704b

Please sign in to comment.
You can’t perform that action at this time.