aboutsummaryrefslogtreecommitdiff
path: root/ayatanasettings/logger.py
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2020-10-29 12:41:30 +0100
committerRobert Tari <robert@tari.in>2020-10-29 12:41:30 +0100
commitb8b236024af1e9daf7251414c80339293e1b10d9 (patch)
treeda06b1ba2174c53296dce610dee23908e5a22009 /ayatanasettings/logger.py
downloadayatana-settings-b8b236024af1e9daf7251414c80339293e1b10d9.tar.gz
ayatana-settings-b8b236024af1e9daf7251414c80339293e1b10d9.tar.bz2
ayatana-settings-b8b236024af1e9daf7251414c80339293e1b10d9.zip
Initial commit
Diffstat (limited to 'ayatanasettings/logger.py')
-rw-r--r--ayatanasettings/logger.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/ayatanasettings/logger.py b/ayatanasettings/logger.py
new file mode 100644
index 0000000..4b8763e
--- /dev/null
+++ b/ayatanasettings/logger.py
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+
+import logging
+from .appdata import APPNAME
+
+class Formatter(logging.Formatter):
+
+ def __init__(self):
+
+ logging.Formatter.__init__(self, '[%(asctime)s] %(levelname)s: %(message)s')
+ self.default_msec_format = '%s.%03d'
+
+ def format(self, record):
+
+ dColours = {'WARNING': '33', 'INFO': '32', 'DEBUG': '37', 'CRITICAL': '35', 'ERROR': '31'}
+ record.levelname = '\033[1;' + dColours[record.levelname] + 'm' + record.levelname + '\033[0m'
+
+ return logging.Formatter.format(self, record)
+
+logger = logging.getLogger(APPNAME)
+logger.setLevel(logging.DEBUG)
+pStreamHandler = logging.StreamHandler()
+pStreamHandler.setFormatter(Formatter())
+logger.addHandler(pStreamHandler)