gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-bank] branch master updated: Logging.


From: gnunet
Subject: [taler-bank] branch master updated: Logging.
Date: Tue, 29 Sep 2020 18:12:32 +0200

This is an automated email from the git hooks/post-receive script.

ms pushed a commit to branch master
in repository bank.

The following commit(s) were added to refs/heads/master by this push:
     new b5824b2  Logging.
b5824b2 is described below

commit b5824b2aea107e284828be13df42d18985c110c0
Author: MS <ms@taler.net>
AuthorDate: Tue Sep 29 18:11:48 2020 +0200

    Logging.
    
    Tests log to a file, and remove print() statements
    in tests.
---
 talerbank/app/tests.py | 18 +++++++-----------
 talerbank/app/views.py |  2 +-
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/talerbank/app/tests.py b/talerbank/app/tests.py
index ada3ed6..7597b63 100644
--- a/talerbank/app/tests.py
+++ b/talerbank/app/tests.py
@@ -43,11 +43,13 @@ from taler.util.amount import (
 
 LOGGER = logging.getLogger()
 LOGGER.setLevel(logging.DEBUG)
-
-# logging.disable(logging.CRITICAL)
-# re-enable: logging.disable(logging.NOTSET)
-#logging.disable(logging.NOTSET)
-
+LOGGER.handlers = [] # disable default console output.
+fileHandler = logging.FileHandler("tests.log") # put salt in filename.
+fileHandler.setLevel(logging.DEBUG)
+fileHandler.setFormatter(
+    logging.Formatter(fmt="%(asctime)-15s %(module)s %(levelname)s 
%(message)s")
+)
+LOGGER.addHandler(fileHandler)
 
 def make_auth_line(username, password):
     credentials = "%s:%s" % (username, password)
@@ -116,7 +118,6 @@ class WireGatewayTestCase(TestCase):
             HTTP_AUTHORIZATION=make_auth_line("RandomExchange", "XYZ"),
         )
         self.assertEqual(r.status_code, 200)
-        print(r.content.decode("utf-8"))
 
 # Testing the "Integration API":
 #      has three operations: 1) /config, 2,3) create, see status of withdrawal.
@@ -212,7 +213,6 @@ class AccessAndIntegrationApiWithdrawTestCase(TestCase):
             content_type="application/json"
         )
         self.assertEqual(r.status_code, 200)
-        print(r.content.decode("utf-8"))
 
 class AccessApiBalanceTestCase(TestCase):
     def setUp(self):
@@ -229,7 +229,6 @@ class AccessApiBalanceTestCase(TestCase):
             HTTP_AUTHORIZATION=make_auth_line("RandomUser", "XYZ"),
         )
         self.assertEqual(r.status_code, 200)
-        print(r.content.decode("utf-8"))
 
 class AccessApiTestingRegistrationTestCase(TestCase):
     def setUp(self):
@@ -711,15 +710,12 @@ class BalanceTestCase(TestCase):
         entries = json.loads(data)
 
         acc_bal = SignedAmount(True, Amount(settings.TALER_CURRENCY, 10, 0))
-        print("acc_bal start", acc_bal)
 
         for entry in reversed(entries["data"]):
-            print("entry", entry)
             if entry["sign"] == "-":
                 acc_bal += SignedAmount.parse(entry["amount"])
             if entry["sign"] == "+":
                 acc_bal -= SignedAmount.parse(entry["amount"])
-            print("acc_bal after", acc_bal)
 
         expected_amount = SignedAmount.parse(f"{settings.TALER_CURRENCY}:16.0")
         self.assertEqual(acc_bal, expected_amount)
diff --git a/talerbank/app/views.py b/talerbank/app/views.py
index 689b395..8e8d9a9 100644
--- a/talerbank/app/views.py
+++ b/talerbank/app/views.py
@@ -852,7 +852,7 @@ def twg_add_incoming(request, user_account, acct_id):
     amount = expect_json_body_amount(request, "amount")
 
     debit_account_name = get_acct_from_payto(debit_account_payto)
-    print(
+    LOGGER.info(
         f"adding incoming balance to exchange ({acct_id}) from account 
{debit_account_payto} ({debit_account_name})"
     )
     debit_user = User.objects.get(username=debit_account_name)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]