Skip to content

Commit

Permalink
Merge pull request #9 from brainelectronics/feature/allow-custom-logg…
Browse files Browse the repository at this point in the history
…er-for-picoweb

Allow custom logger for picoweb
  • Loading branch information
brainelectronics authored Mar 7, 2022
2 parents c1f8035 + fa6e0a6 commit 8e8d334
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
12 changes: 11 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-->

## [Unreleased]
## [1.2.0] - 2022-03-06
### Added
- Custom logger can be provided to `run` function to enable different logging
levels of Picoweb other than `DEBUG`

### Changed
- Neopixel is no longer fading while scan thread is running to reduce CPU load
- `gc.collect()` is no longer called on `latest_scan` property access

## [1.1.0] - 2022-02-27
### Added
- Property `connection_timeout` to control WiFi connection timeout instead of
Expand Down Expand Up @@ -112,8 +121,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `sendfile` function implemented in same way as on Micropythons PicoWeb

<!-- Links -->
[Unreleased]: https://github.com/brainelectronics/Micropython-ESP-WiFi-Manager/compare/1.1.0...develop
[Unreleased]: https://github.com/brainelectronics/Micropython-ESP-WiFi-Manager/compare/1.2.0...develop

[1.2.0]: https://github.com/brainelectronics/Micropython-ESP-WiFi-Manager//tree/1.2.0
[1.1.0]: https://github.com/brainelectronics/Micropython-ESP-WiFi-Manager//tree/1.1.0
[1.0.0]: https://github.com/brainelectronics/Micropython-ESP-WiFi-Manager//tree/1.0.0
[0.1.1]: https://github.com/brainelectronics/Micropython-ESP-WiFi-Manager//tree/0.1.1
Expand Down
3 changes: 2 additions & 1 deletion wifi_manager/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
__version__ = '1.1.0'
__version_info__ = ('1', '2', '0')
__version__ = '.'.join(__version_info__)
__author__ = 'brainelectronics'
14 changes: 7 additions & 7 deletions wifi_manager/wifi_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ def _scan(self,
:param lock: The lock object
:type lock: _thread.lock
"""
pixel.fading = True
# pixel.fading = True

while lock.locked():
try:
Expand All @@ -459,7 +459,7 @@ def _scan(self,
except KeyboardInterrupt:
break

pixel.fading = False
# pixel.fading = False
print('Finished scanning')

@property
Expand Down Expand Up @@ -527,9 +527,6 @@ def scanning(self, value: int) -> None:

@property
def latest_scan(self) -> Union[List[dict], str]:
gc.collect()
free = gc.mem_free()
self.logger.debug('Free memory: {}'.format(free))
latest_scan_result = self._scan_net_msg.value()
self.logger.info('Requested latest scan result: {}'.
format(latest_scan_result))
Expand Down Expand Up @@ -850,7 +847,8 @@ def styles(self, req, resp) -> None:
def run(self,
host: str = '0.0.0.0',
port: int = 80,
debug: bool = False) -> None:
debug: bool = False,
log=None) -> None:
"""
Run the web application
Expand All @@ -861,14 +859,16 @@ def run(self,
:param debug: Flag to automatically reload for code changes and
show debugger content
:type debug: bool, optional
:param log: Logger of Picoweb
:type log: logging.Logger
"""
self.logger.debug('Run app on {}:{} with debug: {}'.format(host,
port,
debug))
try:
# self.app.run()
# self.app.run(debug=debug)
self.app.run(host=host, port=port, debug=debug)
self.app.run(host=host, port=port, debug=debug, log=log)
except KeyboardInterrupt:
self.logger.debug('Catched KeyboardInterrupt at run of web app')
except Exception as e:
Expand Down

0 comments on commit 8e8d334

Please sign in to comment.