8000 Move example script to "extra" directory, update README · imcf/jython-scijava-logging@571c011 · GitHub
[go: up one dir, main page]

Skip to content

Commit 571c011

Browse files
committed
Move example script to "extra" directory, update README
1 parent 7c85648 commit 571c011

File tree

3 files changed

+17
-31
lines changed

3 files changed

+17
-31
lines changed

README.md

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,16 @@ A very thin Python package (mavenized for [ImageJ2][imagej]) to use the
88
Developed and provided by the [Imaging Core Facility (IMCF)][imcf] of the
99
Biozentrum, University of Basel, Switzerland.
1010

11-
# Example usage
11+
## Example usage
1212

13-
The snippet below demonstrates how to use the handler in an ImageJ2 Python
14-
script utilizing the fabulous [Script Parameters][ij_script_params] for
15-
retrieving the LogService instance.
16-
17-
```Python
18-
#@ LogService sjlogservice
19-
20-
from sjlogging.logger import setup_scijava_logger
21-
from sjlogging.setter import set_loglevel
22-
23-
24-
def log_messages(level):
25-
log.critical("+++ new round of messages (level %s) +++" % level)
26-
set_loglevel(level)
27-
log.debug('debug log message')
28-
log.info('info log message')
29-
log.warn('warn log message')
30-
log.error('error log message')
31-
log.critical('critical log message')
32-
log.critical("--- finished round of messages (level %s) ---" % level)
33-
34-
35-
log = setup_scijava_logger(sjlogservice)
36-
37-
log_messages('WARNING')
38-
log_messages('INFO')
39-
log_messages('DEBUG')
40-
log_messages('WARNING')
41-
```
13+
The code in [extra/scripts/example.py](extra/scripts/example.py) demonstrates
14+
how to use the handler in an ImageJ2 Python script utilizing the fabulous
15+
[Script Parameters][ij_script_params] for retrieving the LogService instance.
4216

4317
Running this code from ImageJ will result in the following messages being
4418
printed to the console or the *Log* window, depending on how you launch ImageJ:
4519

46-
```
20+
```log
4721
[Fri Jan 5 12:25:15 CET 2018] [ERROR] +++ new round of messages (level WARNING) +++
4822
[Fri Jan 5 12:25:15 CET 2018] [WARNING] warn log message
4923
[Fri Jan 5 12:25:15 CET 2018] [ERROR] error log message

extra/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Supplementary stuff
2+
3+
This directory contains additional scripts and stuff that can't or shouldn't be
4+
packaged in the `.jar` file by Maven but is rather meant as an example, to be
5+
run manually or copied over to a specific location inside a Fiji installation.
6+
7+
## Logger usage example
8+
9+
The script [`example.py`](scripts/example.py) shows how to use the scijava
10+
logging adapter from Jython code and demonstrates its behaviour in the
11+
*Console/Log* window. To use it, simply open it with the Script Editor and hit
12+
the `Run` button.
File renamed without changes.

0 commit comments

Comments
 (0)
0