MCPcopy Create free account
hub / github.com/battlecode/battlecode-2018 / Logger

Class Logger

battlecode-manager/battlecode_cli.py:25–46  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23PORT = 16147
24
25class Logger(object):
26 def __init__(self, prefix, print=True, limit=2**63):
27 self.logs = io.StringIO()
28 self.prefix = prefix
29 self.print = print
30 self.limit = limit
31 self.len = 0
32 self.out_of_log_errored = False
33
34 def __call__(self, v):
35 if self.len < self.limit:
36 data = v.decode()
37 self.logs.write(data)
38 if self.print:
39 print(self.prefix, data, end='')
40 self.len += len(data)
41 elif not self.out_of_log_errored:
42 self.out_of_log_errored = True
43 msg = '=== Out of log space! Used {} bytes of log. Further logs will not be recorded. ==='.format(self.len)
44 self.logs.write(msg)
45 if self.print:
46 print(self.prefix, msg, end='')
47
48def working_dir_message(working_dir):
49 print('Working directory:', working_dir)

Callers 1

run_gameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected