projects
/
pysvrt.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
212e14e
)
Minor changes in the logging.
author
Francois Fleuret
<francois@fleuret.org>
Wed, 21 Jun 2017 17:55:04 +0000
(19:55 +0200)
committer
Francois Fleuret
<francois@fleuret.org>
Wed, 21 Jun 2017 17:55:04 +0000
(19:55 +0200)
cnn-svrt.py
patch
|
blob
|
history
diff --git
a/cnn-svrt.py
b/cnn-svrt.py
index
f3d350e
..
a41d42c
100755
(executable)
--- a/
cnn-svrt.py
+++ b/
cnn-svrt.py
@@
-25,6
+25,7
@@
import time
import argparse
import math
import distutils.util
import argparse
import math
import distutils.util
+import re
from colorama import Fore, Back, Style
from colorama import Fore, Back, Style
@@
-94,13
+95,15
@@
args = parser.parse_args()
log_file = open(args.log_file, 'a')
pred_log_t = None
log_file = open(args.log_file, 'a')
pred_log_t = None
+last_tag_t = time.time()
print(Fore.RED + 'Logging into ' + args.log_file + Style.RESET_ALL)
# Log and prints the string, with a time stamp. Does not log the
# remark
print(Fore.RED + 'Logging into ' + args.log_file + Style.RESET_ALL)
# Log and prints the string, with a time stamp. Does not log the
# remark
+
def log_string(s, remark = ''):
def log_string(s, remark = ''):
- global pred_log_t
+ global pred_log_t
, last_tag_t
t = time.time()
t = time.time()
@@
-111,10
+114,14
@@
def log_string(s, remark = ''):
pred_log_t = t
pred_log_t = t
- log_file.write('[' + time.ctime() + '] ' + elapsed + ' ' + s + '\n')
+ if t > last_tag_t + 3600:
+ last_tag_t = t
+ print(Fore.RED + time.ctime() + Style.RESET_ALL)
+
+ log_file.write(re.sub(' ', '_', time.ctime()) + ' ' + elapsed + ' ' + s + '\n')
log_file.flush()
log_file.flush()
- print(Fore.BLUE +
'[' + time.ctime() + ']
' + Fore.GREEN + elapsed + Style.RESET_ALL + ' ' + s + Fore.CYAN + remark + Style.RESET_ALL)
+ print(Fore.BLUE +
time.ctime() + '
' + Fore.GREEN + elapsed + Style.RESET_ALL + ' ' + s + Fore.CYAN + remark + Style.RESET_ALL)
######################################################################
######################################################################