-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_log.py
37 lines (25 loc) · 1.06 KB
/
_log.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# A grammar file that sets up logging in Dragonfly.
# Obtained from "https://groups.google.com/forum/m/#!topic/dragonflyspeech/UQncfE-Jv5I"
import logging
from dragonfly import log, CompoundRule, Grammar
log.setup_log()
# log.setup_tracing()
class LoggingRule(CompoundRule):
spec = "is logging enabled" # Spoken form of command.
def _process_recognition(self, node, extras): # Callback when command is spoken.
print node.words()
print 'Yes, looging should be enabled.'
testlog = logging.getLogger("dfly.test")
testlog.debug("Test the dragonfly test log.")
engine_log = logging.getLogger("engine")
engine_log.info("The file log should see this, but not stdout.")
engine_log.warning("Both file and stdout logs should see this.")
# Create a grammar which contains and loads the command rule.
logging_rule = LoggingRule()
grammar = Grammar("example grammar")
grammar.add_rule(logging_rule)
grammar.load()
def unload():
global grammar
if grammar: grammar.unload()
grammar = None