dabeaz / sly

Sly Lex Yacc
Other
817 stars 108 forks source link

Silencing sly warnings? #36

Closed MonliH closed 5 years ago

MonliH commented 5 years ago

Is there a way to disable the sly warnings? Here is an exmaple of one:

WARNING: Token 'EQEQ' defined, but not used

I have tried the ply way to diable (using NullLogger) but that doesn't work. Disabling the warnings isn't really documented and I can't find anything online.

Any help would be appreciated.

dabeaz commented 5 years ago

All warning messages are routed through a 'log' class attribute on the Parser class. You can change it to something else using Python's logging module:

import logging
class MyParser(sly.Parser):
    log = logging.getLogger('whatever')

The output would then be controlled by logging configuration. To silence it completely, you could use some kind of null-logger or other object for the log.

MonliH commented 5 years ago

I found a way to diable the logging. You have to set the level of the logger to ERROR:

import logging
class MyParser(sly.Parser):
    log = logging.getLogger()
    log.setLevel(logging.ERROR)