12
12
13
13
< div class ="header-container jumbotron ">
14
14
< div class ="container ">
15
- < h1 > Mondrian</ h1 >
16
- < h2 > Python's logging module on steroids</ h2 >
17
- < p > Mondrian configures the python standard logging module with reasonable defaults, and enhance its default
18
- output formatters for better readability.</ p >
15
+ < h1 > Whistle</ h1 >
16
+ < h2 > Event Dispatcher for Python</ h2 >
17
+
18
+ < p > Whistle is a simple tool that allow your application components to communicate with each other by dispatching
19
+ events and listening to them.</ p >
19
20
20
21
< p class ="text-center ">
21
- < a class ="btn btn-primary btn-lg " href ="https://pypi.org/project/mondrian / " target ="_blank "
22
+ < a class ="btn btn-primary btn-lg " href ="https://pypi.org/project/whistle / " target ="_blank "
22
23
role ="button "> Install</ a >
23
24
< a class ="btn btn-primary btn-outline-inverse btn-lg " href ="#documentation "
24
25
role ="button "> Documentation</ a >
@@ -31,35 +32,33 @@ <h2>Python's logging module on steroids</h2>
31
32
32
33
< div class ="row ">
33
34
< div class ="col-md-10 ">
34
- < h2 class ="header-light regular-pad "> What is Mondrian ?</ h2 >
35
+ < h2 class ="header-light regular-pad "> What is Whistle ?</ h2 >
35
36
< blockquote >
36
37
< p >
37
- Mondrian is a small library that will make you use python < code > logging</ code > module, once and for
38
- all.
38
+ Whistle is an Event Dispatcher library for the Python 3.5+ language.
39
39
</ p >
40
40
< p >
41
- Most python coders who avoids the systematic usage of < code > logging</ code > in their projects does
42
- so because it feels complicated to setup, but it's not.
41
+ It's largely inspired from Symfony's EventDispatcher component.
43
42
</ p >
44
43
< p >
45
- Mondrian provides a one-call interface to its configuration, with pretty formatters that makes you
46
- feel great .
44
+ Using an event dispatcher is a great way to write loosely coupled extensible code, having each part
45
+ only communicate using light events .
47
46
</ p >
48
47
</ blockquote >
49
48
</ div >
50
49
< div class ="col-md-2 text-center ">
51
50
< br >
52
51
< div class ="clearfix ">
53
52
< div class ="pull-left " style ="margin-right:0.5em ">
54
- < a class ="github-button " href ="https://github.com/python-mondrian/mondrian /fork "
55
- data-icon ="octicon-repo-forked " data-size ="large " aria-label ="Fork Mondrian on GitHub "> </ a >
53
+ < a class ="github-button " href ="https://github.com/python-whistle/whistle /fork "
54
+ data-icon ="octicon-repo-forked " data-size ="large " aria-label ="Fork Whistle on GitHub "> </ a >
56
55
</ div >
57
56
< div class ="pull-left ">
58
- < a class ="github-button " href ="https://github.com/python-mondrian/mondrian " data-icon ="octicon-star "
59
- data-size ="large " data-show-count ="true " aria-label ="Star Mondrian on GitHub "> Star</ a >
57
+ < a class ="github-button " href ="https://github.com/python-whistle/whistle " data-icon ="octicon-star "
58
+ data-size ="large " data-show-count ="true " aria-label ="Star Whistle on GitHub "> Star</ a >
60
59
</ div >
61
60
</ div >
62
- < img src ="img/mondrian -logo.png " alt ="Mondrian , python's logging on steroids . "
61
+ < img src ="img/whistle -logo.png " alt ="Whistle , python's event dispatcher . "
63
62
class ="img-responsive ">
64
63
< a name ="documentation "> </ a >
65
64
</ div >
@@ -70,61 +69,36 @@ <h2 class="header-light regular-pad">What is Mondrian?</h2>
70
69
< div class ="row ">
71
70
< h2 > Quick start</ h2 >
72
71
73
- < p > Install the < code > mondrian</ code > package:</ p >
74
-
75
- < pre > < code > $ pip install mondrian</ code > </ pre >
76
-
77
- < p > In your project's entrypoints (for example, < code > <yourpackage>/__main__.py</ code > , call
78
- < code > mondrian.setup()</ code > :</ p >
72
+ < p > Install the < code > whistle</ code > package:</ p >
79
73
80
- < pre > < code class ="python "> import mondrian
81
- import logging
74
+ < pre > < code > $ pip install whistle</ code > </ pre >
82
75
83
- logger = logging.getLogger()
76
+ < h3 > Create an event dispatcher </ h3 >
84
77
85
- def main():
86
- ...
87
- logger.info('Hello')
88
- ...
78
+ < pre > < code class ="python "> from whistle import EventDispatcher
89
79
90
- if __name__ == '__main__':
91
- mondrian.setup(excepthook=True)
92
- logger.setLevel(logging.INFO)
93
- main()</ code > </ pre >
80
+ dispatcher = EventDispatcher()</ code > </ pre >
94
81
82
+ < h3 > Add a listener to react to events</ h3 >
95
83
96
- < p >
97
- You can remove the < code > excepthook=True</ code > if you don't want mondrian to override the default exception
98
- handler for better formating. But it's nice, try it first.
99
- </ p >
100
-
101
- < p >
102
- Now, use python's < code > logging</ code > module in your project's files:
103
- </ p >
84
+ < pre > < code class ="python "> def on_spectacle_starts(event):
85
+ print('Please turn down your phones!')
104
86
105
- < pre > < code class =" python " > import logging
87
+ dispatcher.add_listener('spectacle.starts', on_spectacle_starts) </ code > </ pre >
106
88
107
- logger = logging.getLogger(__name__)
89
+ < h3 > Dispatch it! </ h3 >
108
90
109
- def some_very_nice_function():
110
- ...
111
- logger.warning('Ola amigo!')
112
- ...</ code > </ pre >
91
+ < pre > < code class ="python "> dispatcher.dispatch('spectacle.starts')</ code > </ pre >
113
92
114
- < p > That's all, folks!</ p >
115
93
116
- < div class ="text-center ">
117
- < img src ="img/example.png " style ="max-width: 718px; margin: auto; " alt ="Your python logger now looks like this "
118
- class ="img-responsive ">
119
- </ div >
120
94
</ div >
121
95
122
96
< hr >
123
97
124
98
< div class ="row ">
125
99
< h2 > License</ h2 >
126
100
< p >
127
- Mondrian and the surrounding material (like this website) is licensed under the Apache License, version 2.0.
101
+ Whistle and the surrounding material (like this website) is licensed under the Apache License, version 2.0.
128
102
</ p >
129
103
</ div >
130
104
0 commit comments