aboutsummaryrefslogtreecommitdiff
path: root/grs
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2015-07-14 18:37:26 -0400
committerAnthony G. Basile <blueness@gentoo.org>2015-07-14 18:37:26 -0400
commite1386f9d15e72b02b4da5f8d8b5e3615df5da1c2 (patch)
treed374720720fba9ea78d4edd531649211bcd6f1c2 /grs
parentgrs/MountDirectories.py: add documentation. (diff)
downloadgrss-e1386f9d15e72b02b4da5f8d8b5e3615df5da1c2.tar.gz
grss-e1386f9d15e72b02b4da5f8d8b5e3615df5da1c2.tar.bz2
grss-e1386f9d15e72b02b4da5f8d8b5e3615df5da1c2.zip
grs/Log.py: add documentation.
Diffstat (limited to 'grs')
-rw-r--r--grs/Log.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/grs/Log.py b/grs/Log.py
index 5a87a92..7bca4f4 100644
--- a/grs/Log.py
+++ b/grs/Log.py
@@ -10,14 +10,16 @@ from grs.Constants import CONST
from grs.Rotator import Rotator
class Log(Rotator):
+ """ Initilize logs, log messages, or rotate logs. """
def __init__(self, logfile = CONST.LOGFILE):
self.logfile = logfile
+ # Make sure the log directory exists
os.makedirs(os.path.dirname(self.logfile), exist_ok=True)
open(self.logfile, 'a').close()
-
def log(self, msg, stamped = True):
+ # If requested, stamp a log message with the unix time.
if stamped:
current_time = datetime.datetime.now(datetime.timezone.utc)
unix_timestamp = current_time.timestamp()
@@ -27,5 +29,6 @@ class Log(Rotator):
def rotate_logs(self, upper_limit = 20):
+ # Rotate all the previous logs
self.full_rotate(self.logfile, upper_limit=upper_limit)
- open('%s' % self.logfile, 'a').close()
+ open(self.logfile, 'a').close()