MCPcopy Create free account
hub / github.com/SpaceNetLab/StarryNet / emit

Method emit

starrynet/log.py:34–55  ·  view source on GitHub ↗

Emit a record. If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline [ N.B. this may be removed depending on feedback ]. If exception information is present, it is formatted using

(self, record)

Source from the content-addressed store, hash-verified

32 for running unit tests."""
33
34 def emit(self, record):
35 """Emit a record.
36 If a formatter is specified, it is used to format the record.
37 The record is then written to the stream with a trailing newline
38 [ N.B. this may be removed depending on feedback ]. If exception
39 information is present, it is formatted using
40 traceback.printException and appended to the stream."""
41 try:
42 msg = self.format(record)
43 fs = '%s' # was '%s\n'
44 if not hasattr(types, 'UnicodeType'): # if no unicode support...
45 self.stream.write(fs % msg)
46 else:
47 try:
48 self.stream.write(fs % msg)
49 except UnicodeError:
50 self.stream.write(fs % msg.encode('UTF-8'))
51 self.flush()
52 except (KeyboardInterrupt, SystemExit):
53 raise
54 except:
55 self.handleError(record)
56
57
58class Singleton(type):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected