Skip to content

Commit

Permalink
Stop wsgiref.simple_server from logging to stderr by default. (#14)
Browse files Browse the repository at this point in the history
### Changed

- Update logging format to include file name and line number for easier troubleshooting; update format for readability.
- Update logger for WSGI to use the built-in Python logger (and not log out to stderr, thanks @jruby411!).
  • Loading branch information
jruby411 authored Mar 30, 2024
1 parent cb6bb29 commit 85b9ccb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/builder-publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:

- name: Build ${{ matrix.addon }} add-on
if: steps.check.outputs.build_arch == 'true'
uses: home-assistant/builder@2024.01.0
uses: home-assistant/builder@2024.03.5
with:
args: |
${{ env.BUILD_ARGS }} \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:

- name: Build ${{ matrix.addon }} add-on
if: steps.check.outputs.build_arch == 'true'
uses: home-assistant/builder@2024.01.0
uses: home-assistant/builder@2024.03.5
with:
args: |
${{ env.BUILD_ARGS }} \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ jobs:
uses: actions/[email protected]

- name: 🚀 Run Home Assistant Add-on Lint
uses: frenck/action-addon-linter@v2.11
uses: frenck/action-addon-linter@main
with:
path: "./${{ matrix.path }}"
7 changes: 7 additions & 0 deletions awnet/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

All notable changes to this project will be documented in this file.

## [1.1.1] - 2024-03-30

### Changed

- Update logging format to include file name and line number for easier troubleshooting; update format for readability.
- Update logger for WSGI to use the built-in Python logger (and not log out to stderr, thanks @jruby411!).

## [1.1.0] - 2024-01-27

### Changed
Expand Down
2 changes: 1 addition & 1 deletion awnet/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: AWNET to HASS
version: 1.1.0
version: 1.1.1
slug: awnet_to_hass
description: Addon to capture local Ambient Weather data in Home Assistant
arch:
Expand Down
6 changes: 5 additions & 1 deletion awnet/rootfs/awnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,15 @@ def parse_request(self):
_LOGGER.debug("new raw_requestline: %s", self.raw_requestline)
return super().parse_request()

# Use the built-in log handler rather than outputting to stderr
def log_message(self, format, *args):
_LOGGER.info(format, *args)

if __name__ == "__main__":
from wsgiref.simple_server import make_server

logging.basicConfig(stream = sys.stdout,
format = '%(asctime)s %(levelname)8s : %(message)s',
format = '[%(asctime)s] [%(levelname)-8s] %(message)s (%(filename)s:%(lineno)d)',
level = sys.argv[1])

# probably shouldn't run on port 80 but that's what I specified in the ambient weather console
Expand Down

0 comments on commit 85b9ccb

Please sign in to comment.