rua!
This commit is contained in:
parent
2ed3bdce68
commit
0efdbf36b1
@ -7,10 +7,9 @@ A python lib came from [Difficult Rocket](https://github.com/shenjackyuanjie/Dif
|
|||||||
## Information/信息
|
## Information/信息
|
||||||
|
|
||||||
- Version / 版本: 0.1.8
|
- Version / 版本: 0.1.8
|
||||||
|
- Author / 作者: shenjackyuanjie 3695888@qq.com
|
||||||
|
|
||||||
### Author/作者
|
> [shenjackyuanjie](https://github/shenjackyuanjie)
|
||||||
|
|
||||||
[shenjackyuanjie](https://github/shenjackyuanjie)
|
|
||||||
|
|
||||||
### License/许可证
|
### License/许可证
|
||||||
|
|
||||||
|
1
example/logger/.gitignore
vendored
Normal file
1
example/logger/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
logs
|
@ -5,6 +5,7 @@
|
|||||||
# -------------------------------
|
# -------------------------------
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
from string import Template
|
from string import Template
|
||||||
from typing import List, Union, Optional, Dict, Tuple, TYPE_CHECKING
|
from typing import List, Union, Optional, Dict, Tuple, TYPE_CHECKING
|
||||||
|
|
||||||
@ -180,7 +181,7 @@ class TraceFormatter(BaseFormatter):
|
|||||||
def _format(self, message: FormattingMessage) -> FormattingMessage:
|
def _format(self, message: FormattingMessage) -> FormattingMessage:
|
||||||
if message[0].stack_trace is None:
|
if message[0].stack_trace is None:
|
||||||
return message
|
return message
|
||||||
message[1]['log_source'] = message[0].stack_trace.f_code.co_filename
|
message[1]['log_source'] = Path(message[0].stack_trace.f_code.co_filename)
|
||||||
message[1]['log_line'] = message[0].stack_trace.f_lineno
|
message[1]['log_line'] = message[0].stack_trace.f_lineno
|
||||||
message[1]['log_function'] = message[0].stack_trace.f_code.co_name
|
message[1]['log_function'] = message[0].stack_trace.f_code.co_name
|
||||||
return message
|
return message
|
||||||
|
@ -120,6 +120,7 @@ class FileCacheOutputStream(BaseOutputStream):
|
|||||||
if self.text_cache is None:
|
if self.text_cache is None:
|
||||||
self.text_cache = io.StringIO()
|
self.text_cache = io.StringIO()
|
||||||
self.flush_lock = threading.Lock()
|
self.flush_lock = threading.Lock()
|
||||||
|
self.get_file_path()
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _write(self, message: LogMessage) -> None:
|
def _write(self, message: LogMessage) -> None:
|
||||||
@ -220,7 +221,7 @@ class FileCacheOutputStream(BaseOutputStream):
|
|||||||
current_file = self.check_flush()
|
current_file = self.check_flush()
|
||||||
if not current_file.exists():
|
if not current_file.exists():
|
||||||
current_file.parent.mkdir(parents=True, exist_ok=True)
|
current_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
current_file.touch()
|
current_file.touch(exist_ok=True)
|
||||||
with current_file.open('a', encoding=self.file_encoding) as f:
|
with current_file.open('a', encoding=self.file_encoding) as f:
|
||||||
f.write(text)
|
f.write(text)
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user