Skip to content

Commit

Permalink
Logger - Write to file before printing out the errors to command line
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Roth committed Aug 1, 2017
1 parent 9ce96d2 commit 1fb2e2e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/lokilogger.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import socket
from helpers import removeNonAsciiDrop

__version__ = '0.23.2'
__version__ = '0.23.3'

# Logger Class -----------------------------------------------------------------
class LokiLogger():
Expand Down Expand Up @@ -78,17 +78,17 @@ def log(self, mes_type, message):
if mes_type not in ('ALERT', 'WARNING'):
return

# to file
if not self.no_log_file:
self.log_to_file(message, mes_type)

# to stdout
try:
self.log_to_stdout(message.encode('ascii', errors='replace'), mes_type)
except Exception, e:
print "Cannot print certain characters to command line - see log file for full unicode encoded log line"
self.log_to_stdout(removeNonAsciiDrop(message), mes_type)

# to file
if not self.no_log_file:
self.log_to_file(message, mes_type)

# to syslog server
if self.remote_logging:
self.log_to_remotesys(message, mes_type)
Expand Down

0 comments on commit 1fb2e2e

Please sign in to comment.