Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix broken log format #171

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions bit/logger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import logging

logger = logging.getLogger("Bit")
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("%(asctime)s|%(levelname)s|%(name)s|%(message)s"))
10 changes: 5 additions & 5 deletions bit/network/fees.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import logging
from bit.logger import logger
from functools import wraps
from time import time

Expand Down Expand Up @@ -57,12 +57,12 @@ def wrapper(fast=True):
fast_last_update = now
except (ConnectionError, HTTPError, Timeout): # pragma: no cover
if cached_fee_fast is None:
logging.warning(
logger.warning(
'Connection to fee API failed, returning default fee (fast) of {}'.format(DEFAULT_FEE_FAST)
)
return DEFAULT_FEE_FAST
else:
logging.warning('Connection to fee API failed, returning cached fee (fast).')
logger.warning('Connection to fee API failed, returning cached fee (fast).')
return cached_fee_fast

return cached_fee_fast
Expand All @@ -81,12 +81,12 @@ def wrapper(fast=True):
hour_last_update = now
except (ConnectionError, HTTPError, Timeout): # pragma: no cover
if cached_fee_hour is None:
logging.warning(
logger.warning(
'Connection to fee API failed, returning default fee (hour) of {}'.format(DEFAULT_FEE_HOUR)
)
return DEFAULT_FEE_HOUR
else:
logging.warning('Connection to fee API failed, returning cached fee (hour).')
logger.warning('Connection to fee API failed, returning cached fee (hour).')
return cached_fee_hour

return cached_fee_hour
Expand Down
4 changes: 2 additions & 2 deletions bit/network/services.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import requests
import json
import logging
from bit.logger import logger
from decimal import Decimal, getcontext

from bit.constants import BTC
Expand Down Expand Up @@ -73,7 +73,7 @@ def broadcast_tx(self, tx_hex):
try:
_ = self.sendrawtransaction(tx_hex)
except BitcoinNodeException as e:
logging.warning(e)
logger.warning(e)
return False
return True

Expand Down
4 changes: 2 additions & 2 deletions bit/transaction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import logging
from bit.logger import logger
from collections import namedtuple
from itertools import islice
import math
Expand Down Expand Up @@ -194,7 +194,7 @@ def estimate_tx_fee(in_size, n_in, out_size, n_out, satoshis, segwit=False):

estimated_fee = estimated_size * satoshis

logging.debug('Estimated fee: {} satoshis for {} bytes'.format(estimated_fee, estimated_size))
logger.debug('Estimated fee: {} satoshis for {} bytes'.format(estimated_fee, estimated_size))

return estimated_fee

Expand Down