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

Option to compact log output #504

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 4 additions & 0 deletions default.cfg.example
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ hideCoins = True
#Limits the amount of log lines to save.
#jsonlogsize = 200

#If True some frequent log messages (e.g. "Not lending ... due to rate below ..." will not append to log list.
#Last equal log message will be shown in currency web page section. Default is false
#jsonlogcompact = true

#Enables a webserver for the www folder, in order to easily use the lendingbot.html with the .json log.
#startWebServer = true

Expand Down
6 changes: 6 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ Advanced logging and Web Display
- Format: ``200``
- Reasons to lower this include: you are conscious of bandwidth when hosting your webserver, you prefer (slightly) faster loading times and less RAM usage of bot.

- ``jsonlogcompact`` enables to log frequent repeated log messages (like "Not lending due to rate below ...") to
currency web page section instead of appending to log list. If enabled only last message is displayed.

- Default value: Commented out, compacting of log is disabled (false)
- Allowed values: true, false

- ``startWebServer`` if true, this enables a webserver on the www/ folder.

- Default value: Commented out, uncomment to enable.
Expand Down
3 changes: 1 addition & 2 deletions modules/Lending.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,7 @@ def lend_cur(active_cur, total_lent, lending_balances, ticker):
below_min = Decimal(orders['rates'][i]) < Decimal(cur_min_daily_rate)

if hide_coins and below_min:
log.log("Not lending {:s} due to rate below {:.4f}% (actual: {:.4f}%)"
.format(active_cur, (cur_min_daily_rate * 100), (orders['rates'][i] * 100)))
log.notLending(active_cur, cur_min_daily_rate, orders['rates'][i])
return 0
elif below_min:
rate = str(cur_min_daily_rate)
Expand Down
15 changes: 15 additions & 0 deletions modules/Logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ class Logger(object):
def __init__(self, json_file='', json_log_size=-1, exchange=''):
self._lent = ''
self._daysRemaining = ''
self.compactLog = False
if json_file != '' and json_log_size != -1:
self.output = JsonOutput(json_file, json_log_size, exchange)
self.compactLog = bool(Config.get('BOT', 'jsonlogcompact', False))
else:
self.output = ConsoleOutput()
self.refreshStatus()
Expand All @@ -117,13 +119,26 @@ def offer(self, amt, cur, rate, days, msg):
line = self.timestamp() + ' Placing ' + str(amt) + ' ' + str(cur) + ' at ' + str(
float(rate) * 100) + '% for ' + days + ' days... ' + self.digestApiMsg(msg)
self.output.printline(line)
if self.compactLog:
self.output.statusValue(cur, 'log', '')
self.refreshStatus()

def cancelOrder(self, cur, msg):
line = self.timestamp() + ' Canceling ' + str(cur) + ' order... ' + self.digestApiMsg(msg)
self.output.printline(line)
self.refreshStatus()

def notLending(self, cur, minRate, actRate):
if self.compactLog:
self.output.statusValue(cur, 'log',
'{:s} Not lending due to rate below {:.4f}% (actual: {:.4f}%)'
.format(self.timestamp(), (minRate * 100), (actRate * 100)))
else:
self.log('Not lending {:s} due to rate below {:.4f}% (actual: {:.4f}%)'
.format(cur, (minRate * 100), (actRate * 100)))

self.refreshStatus()

def refreshStatus(self, lent='', days_remaining=''):
if lent != '':
self._lent = lent
Expand Down
11 changes: 10 additions & 1 deletion www/lendingbot.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ function updateRawValues(rawData){
var totalCoins = parseFloat(rawData[currency]['totalCoins']);
var maxToLend = parseFloat(rawData[currency]['maxToLend']);
var highestBidBTC = parseFloat(rawData[currency]['highestBid']);
var compactLog = 'log' in rawData[currency] ? rawData[currency]['log'] : ''

if (currency == 'BTC') {
// no bids for BTC provided by poloniex
Expand Down Expand Up @@ -208,12 +209,20 @@ function updateRawValues(rawData){
}
$(row).find('[data-toggle="tooltip"]').tooltip();

if (compactLog.length > 0) {
table.insertRow()
row = table.insertRow()
var cell = row.appendChild(document.createElement("td"))
cell.setAttribute("colspan", rowValues.length)
cell.innerHTML = "<div class='inlinediv' >" + compactLog + "</div>"
}

var earningsColspan = rowValues.length - 1;
// print coin earnings
var row = table.insertRow();
if (lentSum > 0) {
var cell1 = row.appendChild(document.createElement("td"));
cell1.innerHTML = "<span class='hidden-xs'>"+ displayCurrency +"<br/></span>Est. "+ compoundRateText +"<br/>Earnings";
cell1.innerHTML = "Est. "+ compoundRateText +"<br/>Earnings"
var cell2 = row.appendChild(document.createElement("td"));
cell2.setAttribute("colspan", earningsColspan);
if (earningsSummaryCoin != '') {
Expand Down