提交 d362d28d 编写于 作者: K KP

Remove logging file in cli api.

上级 4d83ef70
......@@ -43,8 +43,7 @@ class Logger(object):
level)
self.format = logging.Formatter(
fmt='[%(asctime)-15s] [%(levelname)8s] [%(filename)s] [L%(lineno)d] - %(message)s'
)
fmt='[%(asctime)-15s] [%(levelname)8s] - %(message)s')
self.handler = logging.StreamHandler()
self.handler.setFormatter(self.format)
......
......@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import getpass
import inspect
import os
import socket
import sys
......@@ -94,15 +95,31 @@ def find_log_dir_and_names(program_name=None, log_dir=None):
class Log():
"""Default Logger for all."""
logger.remove()
logger.add(
sys.stdout,
level='INFO',
enqueue=True,
filter=lambda record: record['level'].no >= 20)
_, file_prefix, _ = find_log_dir_and_names()
sink_prefix = os.path.join("exp/log", file_prefix)
sink_path = sink_prefix[:-3] + "{time}.log"
logger.add(sink_path, level='DEBUG', enqueue=True, rotation="500 MB")
_call_from_cli = False
_frame = inspect.currentframe()
while _frame:
if 'paddlespeech/cli/__init__.py' in _frame.f_code.co_filename:
_call_from_cli = True
break
_frame = _frame.f_back
if _call_from_cli:
logger.add(
sys.stdout,
level='ERROR',
enqueue=True,
filter=lambda record: record['level'].no >= 20)
else:
logger.add(
sys.stdout,
level='INFO',
enqueue=True,
filter=lambda record: record['level'].no >= 20)
_, file_prefix, _ = find_log_dir_and_names()
sink_prefix = os.path.join("exp/log", file_prefix)
sink_path = sink_prefix[:-3] + "{time}.log"
logger.add(sink_path, level='DEBUG', enqueue=True, rotation="500 MB")
def __init__(self, name=None):
pass
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册