home-assistant / home-assistant/cli

`--log-level` flag doesn't behave as [originally/incorrectly] assumed on `ha core logs`

Đang mở
#653 3 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Go
Star
263
Fork
121
Merge trung bình
20 giờ 51 phút
Pull request đã merge (30 ngày)
6

Mô tả

## Describe the problem

When running a command such as:

```
ha core logs --log-level=ERROR
ha supervisor logs --log-level=WARNING
```

the flag is silently ignored, all log entries are returned regardless of severity.

**Example Command and Response**
```
ha supervisor logs --log-level=ERROR
2026-05-19 09:27:44.620 INFO (MainThread) [supervisor.api.middleware.security] /core/info access from a0d7b954_ssh
2026-05-19 09:28:02.494 INFO (MainThread) [supervisor.api.middleware.security] /core/logs access from a0d7b954_ssh
2026-05-19 09:28:54.568 INFO (MainThread) [supervisor.api.middleware.security] /supervisor/logs access from a0d7b954_ssh
```

## Debug information

1. SSH App type

- [ ] Community
- [ ] Core
- [ ] Custom

2. Version of the CLI

```
ha cli info
update_available: false
version: 2026.05.0
version_latest: 2026.05.0
```

3. Version of Home Assistant Core & the Home Assistant Supervisor

Home Assistant Core: `2026.5.1`
Home Assistant Supervisor: `2026.05.0`

4. Output from executing the command with debug info

e.g., `ha hardware info` should be run as `ha --log-level debug hardware info`
```txt

```
_Provided above_

On review of the suggested command above, I'm questoning whether `--log-level` is as I originally assumed it was to be used. The above leads me to believe its the log level of the CLI itself, rather than the output for `ha core|supervisor logs`

## Expected behavior

As stated above, my assumption was that `log-level` would control the output of logs returened on `ha .. logs`. On review of the flag being a Global Flag, I believe my assumption was incorrect.

Rather than a bug (if indeed it's not a bug), would the maintainers be open to a new flag as a feature (or re-using the existing flag in some form)? I'm open to driving any enhancement myself.

The alternative to this enhacement would be that the consumer of the logs (client-side) is responsible for filtering as part of any scripting/log consumption.

My use-case is that I wish to on a daily basis, fetch only errors or warnings from the previous 24 hours. By using a log-level flag, I could return a much smaller subset of logs to be parsed. Similarly, to help in this endeavour, new flags such as `--from DATETIME` and `--to DATETIME` would also greatly help. [I realise this bug report has now become a feature request 😄 ]

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Hướng nghiên cứu

Start with the command handling for `ha core logs` and `ha supervisor logs`, then compare it with the global `--log-level` behavior shown by `ha --log-level debug hardware info`. Determine how log severity filtering should apply to returned entries and whether time bounds are part of the feature; done means the requested filters work without changing the global CLI logging semantics.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
go
Lĩnh vực
cli
Loại issue
Tính năng
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Ít trao đổi
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
48/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.