Skip to content

Commit

Permalink
Fixed tm_log
Browse files Browse the repository at this point in the history
  • Loading branch information
yurivict committed May 16, 2015
1 parent 6efb9a1 commit 10a70da
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion tiny-dhcp-server.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def logfile():
return arg_log_file if arg_log_file is not None else '/var/log/tiny-dhcp-server.log'
def log(s):
with open(logfile(), "a") as myfile:
myfile.write('%s %s\n' % (tm_log(), s))
myfile.write('%s %s\n' % (tu.tm_log(), s))
def log_discard(what):
if arg_daemonize:
with open(logfile(), "a") as myfile:
Expand Down
2 changes: 1 addition & 1 deletion tiny-udp-anti-nat.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def logfile():

def log(s):
with open(logfile(), "a") as myfile:
myfile.write('%s %s\n' % (tm_log(), s))
myfile.write('%s %s\n' % (tu.tm_log(), s))

def unpack_ip(pkt, off):
return pkt[off:off+4]
Expand Down
6 changes: 2 additions & 4 deletions tiny-udp-proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,13 @@ def logfile():
return '/var/log/tiny-udp-proxy.log'
def logfile_pkt():
return '/var/log/tiny-udp-proxy-pkts.log'
def tm_log():
return datetime.datetime.now().strftime('[%Y-%m-%d %H:%M:%S]')
def tm_ms():
global timer_process_start
return '%0.3f' % (timer() - timer_process_start)
def log(s):
print("LOG %s" % (s))
with open(logfile(), "a") as myfile:
myfile.write('%s %s %s\n' % (tm_ms(), tm_log(), s))
myfile.write('%s %s %s\n' % (tm_ms(), tu.tm_log(), s))
def log_pkt(is_req, ip, port, data):
if do_log_packets:
with open(logfile_pkt(), "a") as myfile:
Expand All @@ -155,7 +153,7 @@ def log_pkt(is_req, ip, port, data):
def log_discard(s):
print("DISCARDED %s" % (s))
with open(logfile(), "a") as myfile:
myfile.write('%s packet discarded: %s %s\n' % (tm_ms(), tm_log(), s))
myfile.write('%s packet discarded: %s %s\n' % (tm_ms(), tu.tm_log(), s))

###
### BEGIN Packet generator
Expand Down

0 comments on commit 10a70da

Please sign in to comment.