66Objects for controlling the configuration of the HTTP/2 stack.
77"""
88
9+ import sys
10+
911
1012class _BooleanConfigOption :
1113 """
@@ -27,7 +29,7 @@ def __set__(self, instance, value):
2729
2830class DummyLogger :
2931 """
30- An Logger object that does not actual logging, hence a DummyLogger.
32+ A Logger object that does not actual logging, hence a DummyLogger.
3133
3234 For the class the log operation is merely a no-op. The intent is to avoid
3335 conditionals being sprinkled throughout the h2 code for calls to
@@ -49,6 +51,29 @@ def trace(self, *vargs, **kwargs):
4951 pass
5052
5153
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+
5277class H2Configuration :
5378 """
5479 An object that controls the way a single HTTP/2 connection behaves.
0 commit comments