Skip to content

Commit 274d164

Browse files
committed
Work around an issue with info() when running on jython-slim-2.7.2
The call to `info()` fails when running on `jython-slim-2.7.2` as it seems to confuse a private field inherited from SciJava's `AbstractRichPlugin` with the actual method of the logger object. For details, see [Fiji issue 267][1] and [Jython issue 70][2]. [1]: fiji/fiji#267 [2]: jython/jython#70
1 parent 3d77066 commit 274d164

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/main/resources/sjlogging/handler.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,27 @@ def emit(self, record):
3939
Python logging filters etc., so once the emit() method is called we *do*
4040
know this message should actually be put out. Hence we first remember
4141
the current SciJava log level, adjust it according to the level of the
42-
given record, then we call the corresponding LogService method and
42+
given record, then we call the corresponding LogService `log()` method and
4343
finally we re-set the SciJava log level to the value it had when this
4444
method was called.
4545
"""
4646
# remember the current LogService level:
4747
sjlevel = self.sjlog.getLevel()
4848

49+
formatted = self.format(record)
50+
4951
if record.levelname == "DEBUG":
5052
self.sjlog.setLevel(4)
51-
self.sjlog.debug(self.format(record))
53+
self.sjlog.log(4, formatted)
5254
elif record.levelname == "INFO":
5355
self.sjlog.setLevel(3)
54-
self.sjlog.info(self.format(record))
56+
self.sjlog.log(3, formatted)
5557
elif record.levelname == "WARNING":
5658
self.sjlog.setLevel(2)
57-
self.sjlog.warn(self.format(record))
59+
self.sjlog.log(2, formatted)
5860
else: # everything else, including "ERROR" and "CRITICAL":
5961
self.sjlog.setLevel(1)
60-
self.sjlog.error(self.format(record))
62+
self.sjlog.log(1, formatted)
6163

6264
# reset the LogService level to its previous value:
6365
self.sjlog.setLevel(sjlevel)

0 commit comments

Comments
 (0)