6
6
Objects for controlling the configuration of the HTTP/2 stack.
7
7
"""
8
8
9
+ import sys
10
+
9
11
10
12
class _BooleanConfigOption :
11
13
"""
@@ -27,7 +29,7 @@ def __set__(self, instance, value):
27
29
28
30
class DummyLogger :
29
31
"""
30
- An Logger object that does not actual logging, hence a DummyLogger.
32
+ A Logger object that does not actual logging, hence a DummyLogger.
31
33
32
34
For the class the log operation is merely a no-op. The intent is to avoid
33
35
conditionals being sprinkled throughout the h2 code for calls to
@@ -49,6 +51,29 @@ def trace(self, *vargs, **kwargs):
49
51
pass
50
52
51
53
54
+ class OutputLogger :
55
+ """
56
+ A Logger object that prints to stderr or any other file-like object.
57
+
58
+ This class is provided for convinience and not part of the stable API.
59
+
60
+ :param file: A file-like object passed to the print function.
61
+ Defaults to ``sys.stderr``.
62
+ :param trace: Enables trace-level output. Defaults to ``False``.
63
+ """
64
+ def __init__ (self , file = sys .stderr , trace = False ):
65
+ super ().__init__ ()
66
+ self .file = file
67
+ self .trace = trace
68
+
69
+ def debug (self , fmtstr , * args ):
70
+ print (f"h2 (debug): { fmtstr % args } " , file = self .file )
71
+
72
+ def trace (self , fmtstr , * args ):
73
+ if self .trace :
74
+ print (f"h2 (trace): { fmtstr % args } " , file = self .file )
75
+
76
+
52
77
class H2Configuration :
53
78
"""
54
79
An object that controls the way a single HTTP/2 connection behaves.
0 commit comments