[tor-commits] [bridgedb/master] Add logging to crypto module.

isis at torproject.org isis at torproject.org
Sun Jan 12 06:06:31 UTC 2014


commit 6764b9cfeea5b221557a81e6111044bb0fe280ae
Author: Isis Lovecruft <isis at torproject.org>
Date:   Sat Oct 26 23:33:18 2013 +0000

    Add logging to crypto module.
---
 lib/bridgedb/crypto.py |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/lib/bridgedb/crypto.py b/lib/bridgedb/crypto.py
index 43b2b79..124d337 100644
--- a/lib/bridgedb/crypto.py
+++ b/lib/bridgedb/crypto.py
@@ -12,6 +12,9 @@
 from __future__ import absolute_import
 from __future__ import unicode_literals
 
+import logging
+log = logging.getLogger(__name__)
+
 import os
 
 import OpenSSL.rand
@@ -42,6 +45,7 @@ def getKey(filename):
     try:
         fh = open(filename, 'rb')
     except IOError:
+        log.debug("getKey(): Creating new secret key.")
         key = OpenSSL.rand.bytes(32)
         flags = os.O_WRONLY | os.O_TRUNC | os.O_CREAT | getattr(os, "O_BIN", 0)
         fd = os.open(filename, flags, 0400)
@@ -49,6 +53,7 @@ def getKey(filename):
         os.fsync(fd)
         fd.close()
     else:
+        log.debug("getKey(): Secret key file found. Loading...")
         key = fh.read()
         fh.close()
     return key





More information about the tor-commits mailing list