File tree Expand file tree Collapse file tree 6 files changed +43
-1
lines changed
Expand file tree Collapse file tree 6 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,20 @@ obj = pywavefront.Wavefront('something.obj')
7676visualization.draw(obj)
7777```
7878
79+ ## Logging
80+
81+ The default log level is ` ERROR ` . This is configurable including overriding the formatter.
82+
83+ ``` python
84+ import logging
85+ import pywavefront
86+
87+ pywavefront.configure_logging(
88+ logging.DEBUG ,
89+ formatter = logging.Formatter(' %(name)s -%(levelname)s : %(message)s ' )
90+ )
91+ ```
92+
7993### Example Scripts
8094
8195The ` example ` directory contains some basic examples using the ` visualization ` module
Original file line number Diff line number Diff line change 3131# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3232# POSSIBILITY OF SUCH DAMAGE.
3333# ----------------------------------------------------------------------------
34+ import logging
35+
3436from pywavefront .exceptions import PywavefrontException
3537from pywavefront .obj import ObjParser
3638from pywavefront .wavefront import Wavefront
39+
40+ logger = logging .getLogger ("pywavefront" )
41+ log_handler = logging .StreamHandler ()
42+ logger .addHandler (log_handler )
43+
44+
45+ def configure_logging (level , formatter = None ):
46+ logger .setLevel (level )
47+ log_handler .setLevel (level )
48+
49+ if formatter :
50+ log_handler .setFormatter (formatter )
51+
52+
53+ configure_logging (logging .ERROR , logging .Formatter ('%(name)s-%(levelname)s: %(message)s' ))
Original file line number Diff line number Diff line change 3131# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3232# POSSIBILITY OF SUCH DAMAGE.
3333# ----------------------------------------------------------------------------
34+ import logging
3435import os
3536
3637from pywavefront .parser import Parser , auto_consume
3738from pywavefront .texture import Texture
3839
40+ logger = logging .getLogger ("pywavefront" )
41+
3942
4043class Material (object ):
4144 def __init__ (self , name = None , is_default = False ):
Original file line number Diff line number Diff line change 1+ import logging
12import os
23
34from pywavefront .exceptions import PywavefrontException
45from pywavefront .parser import Parser , auto_consume
56from pywavefront .material import Material , MaterialParser
67from pywavefront .mesh import Mesh
78
9+ logger = logging .getLogger ("pywavefront" )
10+
811
912class ObjParser (Parser ):
1013 """This parser parses lines from .obj files."""
Original file line number Diff line number Diff line change 3939
4040from pywavefront .exceptions import PywavefrontException
4141
42+ logger = logging .getLogger ("pywavefront" )
43+
4244
4345def auto_consume (func ):
4446 """Decorator for auto consuming lines when leaving the function"""
@@ -141,7 +143,7 @@ def parse_fallback(self):
141143 raise PywavefrontException ("Unimplemented OBJ format statement '%s' on line '%s'"
142144 % (self .values [0 ], self .line .rstrip ()))
143145 else :
144- logging .warning ("Unimplemented OBJ format statement '%s' on line '%s'"
146+ logger .warning ("Unimplemented OBJ format statement '%s' on line '%s'"
145147 % (self .values [0 ], self .line .rstrip ()))
146148
147149 def _build_dispatch_map (self ):
Original file line number Diff line number Diff line change 1+ import logging
12from pywavefront import ObjParser
23
4+ logger = logging .getLogger ("pywavefront" )
5+
36
47class Wavefront (object ):
58 # Can be used to override the parser when extending the class
You can’t perform that action at this time.
0 commit comments