- Improve debugging

- Resolves #2
This commit is contained in:
Ross Stewart
2022-11-19 16:24:13 +00:00
parent 9cbccb15f5
commit 70db7e802a
2 changed files with 53 additions and 10 deletions

View File

@@ -142,6 +142,36 @@ except NameError as err:
logger.debug('Configuration has been successfully loaded')
# Set log level based on config value
if 'NAVI_DEBUG' in os.environ:
navidrome_log_level = int(os.getenv('NAVI_DEBUG'))
if navidrome_log_level == 0:
# Warnings and higher
logger.setLevel(logging.WARNING)
logger.warning('Log level set to WARNING')
elif navidrome_log_level == 1:
# Info messages and higher
logger.setLevel(logging.INFO)
logger.info('Log level set to INFO')
elif navidrome_log_level == 2:
# Debug with request and response interceptors
logger.setLevel(logging.DEBUG)
logger.debug('Log level set to DEBUG')
elif navidrome_log_level == 3:
# Debug with request / response interceptors and Web GUI
logger.setLevel(logging.DEBUG)
logger.debug('Log level set to DEBUG')
else:
# Invalid value provided - set to WARNING
navidrome_log_level = 0
logger.setLevel(logging.WARNING)
logger.warning('Log level set to WARNING')
# Create a queue
play_queue = queue.MediaQueue()
logger.debug('MediaQueue object created...')
@@ -938,15 +968,16 @@ sb.add_request_handler(PlaybackFailedEventHandler())
sb.add_exception_handler(SystemExceptionHandler())
sb.add_exception_handler(GeneralExceptionHandler())
# Register Interceptors (log all requests)
# sb.add_global_request_interceptor(LoggingRequestInterceptor())
# sb.add_global_response_interceptor(LoggingResponseInterceptor())
if navidrome_log_level >= 2:
# Register Interceptors (log all requests)
sb.add_global_request_interceptor(LoggingRequestInterceptor())
sb.add_global_response_interceptor(LoggingResponseInterceptor())
sa = SkillAdapter(skill=sb.create(), skill_id='test', app=app)
sa.register(app=app, route='/')
# Enable queue and history diagnostics
if 'NAVI_DEBUG' in os.environ:
if navidrome_log_level == 3:
logger.warning('AskNavidrome debugging has been enabled, this should only be used when testing!')
logger.warning('The /buffer, /queue and /history http endpoints are available publicly!')

View File

@@ -357,7 +357,7 @@ information to run:
+----------------------+----------------------------------------------------------------+------------------------------------------------------+
| NAVI_API_VER | The version of the Subsonic API in use | 1.16.1 |
+----------------------+----------------------------------------------------------------+------------------------------------------------------+
| NAVI_DEBUG | Enable debugging, to disable to not set this variable | 1 |
| NAVI_DEBUG | Enable debugging, by setting this variable to 1, or 3. | 1 |
+----------------------+----------------------------------------------------------------+------------------------------------------------------+
@@ -378,7 +378,7 @@ Troubleshooting and debugging Alexa skills can be a little frustrating, here are
#. Enable debugging and look at the logs generated by the web service.
#. When debugging is enabled the following web pages are available from the web service
#. When level 3 debugging is enabled the following web pages are available from the web service
* url-to-web-service/queue
@@ -412,6 +412,18 @@ Troubleshooting and debugging Alexa skills can be a little frustrating, here are
* After you have entered a command you will get the Alexa response back, scroll down to the **Device Log** section and click through the entries
the entries will contain any errors that were thrown.
Debug Options
-------------
You can enable the following debug options by setting the NAVI_DEBUG environment variable.
* 0 = Logging set to WARNING and higher.
* 1 = Logging set to INFO and higher.
* 2 = Logging set to DEBUG and higher and request / response
interceptors are enabled.
* 3 = All features of level 2 and the web ui. Note the UI
will be **publicly** available while this is enabled.
Known Issues
------------
@@ -419,10 +431,10 @@ Known Issues
.. code-block:: bash
2022-11-19 13:16:45,478 - root - DEBUG - In PlaybackFailedHandler
2022-11-19 13:16:45,479 - root - ERROR - Playback Failed: {'message': 'Device playback error', 'object_type': 'MEDIA_ERROR_UNKNOWN'}
2022-11-19 13:16:45,480 - werkzeug - INFO - 10.44.17.62 - - [19/Nov/2022 13:16:45] "POST / HTTP/1.1" 200 -
2022-11-19 13:16:48,599 - root - DEBUG - In PlaybackFailedHandler
2022-11-19 13:16:45,478 - root - DEBUG - In PlaybackFailedHandler
2022-11-19 13:16:45,479 - root - ERROR - Playback Failed: {'message': 'Device playback error', 'object_type': 'MEDIA_ERROR_UNKNOWN'}
2022-11-19 13:16:45,480 - werkzeug - INFO - 10.44.17.62 - - [19/Nov/2022 13:16:45] "POST / HTTP/1.1" 200 -
2022-11-19 13:16:48,599 - root - DEBUG - In PlaybackFailedHandler
2022-11-19 13:16:48,600 - root - ERROR - Playback Failed: {'message': 'Device playback error','object_type': 'MEDIA_ERROR_INTERNAL_DEVICE_ERROR'}
* I have not found a reason as to why this happens from time to time, however it can be resolved by doing a hard reboot of your Echo device.