trading debug and ship logs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from .base import Base
|
||||
from time import time
|
||||
from time import time, strftime
|
||||
from nullptr.util import *
|
||||
from nullptr.models import Waypoint
|
||||
import os
|
||||
@@ -22,15 +22,18 @@ class Ship(Base):
|
||||
self.frame = ''
|
||||
self.speed = "CRUISE"
|
||||
self._log_file = None
|
||||
self._log_level = 5
|
||||
|
||||
def log(self, m):
|
||||
def log(self, m, l=3):
|
||||
if self._log_file is None:
|
||||
fn = os.path.join(self.store.data_dir, f'{self.symbol}.{self.ext()}.log')
|
||||
self._log_file = open(fn, 'a')
|
||||
ts = int(time())
|
||||
ts = strftime('%Y%m%d %H%M%S')
|
||||
m = m.strip()
|
||||
self._log_file.write(f'{ts} {m}\n')
|
||||
self._log_file.flush()
|
||||
if l <= self._log_level:
|
||||
print(f'{self} {ts} {m}')
|
||||
|
||||
@classmethod
|
||||
def ext(self):
|
||||
|
||||
Reference in New Issue
Block a user