summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorIsis Lovecruft <isis@torproject.org>2013-01-25 11:13:12 +0000
committerIsis Lovecruft <isis@torproject.org>2013-01-25 11:13:12 +0000
commitfe1bd860aacc72028afbcdb90a6d800b72651518 (patch)
treecc1a2ae9ce4952362bfbbd248355045bb32296d8 /src/leap
parent383e614b3fc53ca2d59104988d8ec1a3a9cba14d (diff)
Cleaned up logging functions and added docstrings.
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/util/log.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/leap/util/log.py b/src/leap/util/log.py
index 62ac113..15db367 100644
--- a/src/leap/util/log.py
+++ b/src/leap/util/log.py
@@ -26,7 +26,6 @@ from twisted.python.failure import Failure
from leap.util import version, config
-## xxx TODO finish docstrings
class InvalidTimestampFormat(Exception):
pass
@@ -59,13 +58,21 @@ def prettyDateNow():
return datetime.now().ctime()
def utcPrettyDateNow():
- """Pretty string for utc time."""
+ """Pretty string for UTC."""
return datetime.utcnow().ctime()
def timeToPrettyDate(time_val):
+ """Convert seconds since epoch to date."""
return time.ctime(time_val)
def start(logfile=None, application_name=None):
+ """
+ Start logging to stdout, and optionally to a logfile as well.
+
+ @param logfile: The filename to store logs in, which is placed in
+ /leap_mx/logs/.
+ @param application_name: The name of the running application.
+ """
if not application_name:
application_name = version.name
print "application name: %s" % application_name
@@ -86,24 +93,28 @@ def start(logfile=None, application_name=None):
txlog.msg("Starting %s on %s (%s UTC)" % (application_name,
prettyDateNow(),
utcPrettyDateNow()))
- ## xxx need these functions! ^^
def msg(msg, *arg, **kwarg):
+ """Log a message at the INFO level."""
print "[*] %s" % msg
def debug(msg *arg, **kwarg):
+ """Log a message at the DEBUG level."""
if config.basic.debug:
print "[d] %s" % msg
def warn(msg, *arg, **kwarg):
+ """Log a message at the WARN level."""
if config.basic.show_warnings:
txlog.logging.captureWarnings('true')
print "[#] %s" % msg
def err(msg, *arg, **kwarg):
+ """Log a message at the ERROR level."""
print "[!] %s" % msg
def fail(*failure):
+ """Log a message at the CRITICAL level."""
logging.critical(failure)
## xxx should we take steps to exit here?