diff --git a/supervisor/api/host.py b/supervisor/api/host.py index 6be405e2877..0ba4295329b 100644 --- a/supervisor/api/host.py +++ b/supervisor/api/host.py @@ -239,11 +239,13 @@ async def advanced_logs_handler( # return 2 lines at minimum. lines = max(2, lines) # entries=cursor[[:num_skip]:num_entries] - range_header = f"entries=:-{lines-1}:{lines}" + range_header = f"entries=:-{lines-1}:{'' if follow else lines}" elif RANGE in request.headers: range_header = request.headers.get(RANGE) else: - range_header = f"entries=:-{DEFAULT_LINES-1}:{DEFAULT_LINES}" + range_header = ( + f"entries=:-{DEFAULT_LINES-1}:{'' if follow else DEFAULT_LINES}" + ) async with self.sys_host.logs.journald_logs( params=params, range_header=range_header, accept=LogFormat.JOURNAL diff --git a/tests/api/__init__.py b/tests/api/__init__.py index 50b8d859a64..4a32171ffeb 100644 --- a/tests/api/__init__.py +++ b/tests/api/__init__.py @@ -7,6 +7,7 @@ from supervisor.host.const import LogFormat DEFAULT_LOG_RANGE = "entries=:-99:100" +DEFAULT_LOG_RANGE_FOLLOW = "entries=:-99:" async def common_test_api_advanced_logs( @@ -34,7 +35,7 @@ async def common_test_api_advanced_logs( journald_logs.assert_called_once_with( params={"SYSLOG_IDENTIFIER": syslog_identifier, "follow": ""}, - range_header=DEFAULT_LOG_RANGE, + range_header=DEFAULT_LOG_RANGE_FOLLOW, accept=LogFormat.JOURNAL, ) @@ -62,6 +63,6 @@ async def common_test_api_advanced_logs( "_BOOT_ID": "ccc", "follow": "", }, - range_header=DEFAULT_LOG_RANGE, + range_header=DEFAULT_LOG_RANGE_FOLLOW, accept=LogFormat.JOURNAL, ) diff --git a/tests/api/test_host.py b/tests/api/test_host.py index b2312fae820..92064373122 100644 --- a/tests/api/test_host.py +++ b/tests/api/test_host.py @@ -15,6 +15,7 @@ from tests.dbus_service_mocks.systemd import Systemd as SystemdService DEFAULT_RANGE = "entries=:-99:100" +DEFAULT_RANGE_FOLLOW = "entries=:-99:" # pylint: disable=protected-access @@ -233,7 +234,7 @@ async def test_advanced_logs( "SYSLOG_IDENTIFIER": coresys.host.logs.default_identifiers, "follow": "", }, - range_header=DEFAULT_RANGE, + range_header=DEFAULT_RANGE_FOLLOW, accept=LogFormat.JOURNAL, )