fix: Use debug config from default

Use debug config from default. Set INFO as default level.

Change-Id: I03834f5a69d9f5b6b87d9c4c08296a4589952a92
This commit is contained in:
zhu.boxiang 2022-05-30 15:27:08 +08:00
parent 193f2ed6c7
commit 2d978cc755
3 changed files with 8 additions and 5 deletions

View File

@ -54,7 +54,7 @@ def setup(
backtrace = True backtrace = True
diagnose = True diagnose = True
else: else:
default_level = "WARNING" default_level = "INFO"
backtrace = False backtrace = False
diagnose = True diagnose = True
if level is None: if level is None:

View File

@ -31,7 +31,10 @@ API_PREFIX = "/api/v1"
async def on_startup() -> None: async def on_startup() -> None:
configure("skyline") configure("skyline")
log_setup(Path(CONF.default.log_dir).joinpath("skyline", "skyline-apiserver.log")) log_setup(
Path(CONF.default.log_dir).joinpath("skyline", "skyline-apiserver.log"),
debug=CONF.default.debug,
)
policies_setup() policies_setup()
await db_setup() await db_setup()

View File

@ -87,7 +87,7 @@ class TestLog:
log = getattr(LOG, level) log = getattr(LOG, level)
log(content) log(content)
file_content = file_sink_captor.read_text() file_content = file_sink_captor.read_text()
if debug is False and level in ["debug", "info"]: if debug is False and level in ["debug"]:
assert f"| {level.upper():<8} |" not in file_content assert f"| {level.upper():<8} |" not in file_content
assert content not in file_content assert content not in file_content
else: else:
@ -159,7 +159,7 @@ class TestLog:
log = getattr(LOG, level) log = getattr(LOG, level)
log(content) log(content)
std_out, std_err = stream_sink_captor.readouterr() std_out, std_err = stream_sink_captor.readouterr()
if debug is False and level in ["debug", "info"]: if debug is False and level in ["debug"]:
assert f"| {level.upper():<8} |" not in std_err assert f"| {level.upper():<8} |" not in std_err
assert content not in std_err assert content not in std_err
else: else:
@ -219,7 +219,7 @@ class TestLog:
log = getattr(std_logger, level) log = getattr(std_logger, level)
log(content) log(content)
file_content = file_sink_captor.read_text() file_content = file_sink_captor.read_text()
if debug is False and level in ["debug", "info"]: if debug is False and level in ["debug"]:
assert f"| {level.upper():<8} |" not in file_content assert f"| {level.upper():<8} |" not in file_content
assert content not in file_content assert content not in file_content
else: else: