@@ -45,23 +45,18 @@ def from_str(cls, value: str):
45
45
return cls .TEXT .value
46
46
47
47
48
- _FRAME_TYPES = {
49
- (LogFormat .JSON , logging .NOTSET ): 0xA55A0002 .to_bytes (4 , "big" ),
50
- (LogFormat .JSON , logging .DEBUG ): 0xA55A000A .to_bytes (4 , "big" ),
51
- (LogFormat .JSON , logging .INFO ): 0xA55A000E .to_bytes (4 , "big" ),
52
- (LogFormat .JSON , logging .WARNING ): 0xA55A0012 .to_bytes (4 , "big" ),
53
- (LogFormat .JSON , logging .ERROR ): 0xA55A0016 .to_bytes (4 , "big" ),
54
- (LogFormat .JSON , logging .CRITICAL ): 0xA55A001A .to_bytes (4 , "big" ),
55
- (LogFormat .TEXT , logging .NOTSET ): 0xA55A0003 .to_bytes (4 , "big" ),
56
- (LogFormat .TEXT , logging .DEBUG ): 0xA55A000B .to_bytes (4 , "big" ),
57
- (LogFormat .TEXT , logging .INFO ): 0xA55A000F .to_bytes (4 , "big" ),
58
- (LogFormat .TEXT , logging .WARNING ): 0xA55A0013 .to_bytes (4 , "big" ),
59
- (LogFormat .TEXT , logging .ERROR ): 0xA55A0017 .to_bytes (4 , "big" ),
60
- (LogFormat .TEXT , logging .CRITICAL ): 0xA55A001B .to_bytes (4 , "big" ),
48
+ _JSON_FRAME_TYPES = {
49
+ logging .NOTSET : 0xA55A0002 .to_bytes (4 , "big" ),
50
+ logging .DEBUG : 0xA55A000A .to_bytes (4 , "big" ),
51
+ logging .INFO : 0xA55A000E .to_bytes (4 , "big" ),
52
+ logging .WARNING : 0xA55A0012 .to_bytes (4 , "big" ),
53
+ logging .ERROR : 0xA55A0016 .to_bytes (4 , "big" ),
54
+ logging .CRITICAL : 0xA55A001A .to_bytes (4 , "big" ),
61
55
}
62
- _DEFAULT_FRAME_TYPE = _FRAME_TYPES [( LogFormat . TEXT , logging . NOTSET )]
56
+ _DEFAULT_FRAME_TYPE = 0xA55A0003 . to_bytes ( 4 , "big" )
63
57
64
- _encode_json = json .JSONEncoder (ensure_ascii = False ).encode
58
+ _json_encoder = json .JSONEncoder (ensure_ascii = False )
59
+ _encode_json = _json_encoder .encode
65
60
66
61
67
62
class JsonFormatter (logging .Formatter ):
@@ -102,9 +97,8 @@ def format_log_level(record: logging.LogRecord):
102
97
103
98
def format (self , record : logging .LogRecord ) -> str :
104
99
self .format_log_level (record )
105
- record ._frame_type = _FRAME_TYPES .get (
106
- (LogFormat .JSON , record .levelno ),
107
- _FRAME_TYPES [(LogFormat .JSON , logging .NOTSET )],
100
+ record ._frame_type = _JSON_FRAME_TYPES .get (
101
+ record .levelno , _JSON_FRAME_TYPES [logging .NOTSET ]
108
102
)
109
103
110
104
result = {
0 commit comments