Closed m7pr closed 2 months ago
@pawelru do we really want this functionality in teal.slice
. There is so much inputs, typically not treated as regular inputs by users :) below you can see the logging info appearing just on a startup of a simple app. Very very long.
I added functionality of logging the input in each moduleServer()
that uses input$
The main reason for doing this is that this will help you in case of debugging user issues where demo is not possible due to some reasons. Presumably - the only data you can get. If this is helpful - you tell me :)
When I analysed the logs you provided I noticed something - please help me finding how this could be improved.
There are multiple log init message ("Default Shiny inputs initialized: {}") and in general I am seeing repetitions. That makes me think that you added a few log cards and entries it produces are essentially the same. Is there a way to add info which card it relates to? We have the same issue for modules as well - we don't know if a change of input ID "XYZ" occured for module A or B. I think that this will make the logs more readable and informative.
That would be great to have a function name, or module name appended to the logger, but I dont think it takes custom messages
We would need to overwrite the function so it takes custom input in log_level
I think this should be log_level(level, "Shiny input change detected in {ns} on {name}: {old} -> {new}", namespace = namespace)
and ns <- session$ns("")
beforehand. This plus test condition you discovered elsewhere. I think it's enough to propose the change.
@pawelru I created a PR in logger https://github.com/daroczig/logger/pull/154 that allows for a custom message as I imagine there's gonna be multiple various needs to those logging messages.
With namespace added to the logout, it is clear which function throws the log-message, despite the fact our namespaces names are pretty long
[INFO] 2024-05-14 13:54:24.6364 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-data_source-module_filter_panel-overview- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.6737 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-data_source-module_filter_panel-active- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.6795 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-data_source-module_filter_panel-active-available_filters- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.7332 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-data_source-module_filter_panel-add- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.7403 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-data_source-module_filter_panel-add-new_iris-filter- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.7518 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-data_source-module_filter_panel-add-new_mtcars-filter- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.7902 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-example_teal_module-module_filter_panel-overview- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.8002 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-example_teal_module-module_filter_panel-active- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.8049 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-example_teal_module-module_filter_panel-active-available_filters- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.8563 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-example_teal_module-module_filter_panel-add- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.8645 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-example_teal_module-module_filter_panel-add-new_iris-filter- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.8746 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-example_teal_module-module_filter_panel-add-new_mtcars-filter- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.8963 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-iris_sepal_length_histogram-module_filter_panel-overview- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.9195 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-iris_sepal_length_histogram-module_filter_panel-active- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.9254 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-iris_sepal_length_histogram-module_filter_panel-active-available_filters- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.9651 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-iris_sepal_length_histogram-module_filter_panel-add- - Default Shiny inputs initialized: {}
[INFO] 2024-05-14 13:54:24.9736 pid:6264 token:[43d51a90] teal.slice teal-main_ui-root-iris_sepal_length_histogram-module_filter_panel-add-new_iris-filter- - Default Shiny inputs initialized: {}
Maybe we can limit logging just to -overview
parts
I think this is correct. We are expecting long IDs here. Please just try session$ns(character(0)
to remove the trailing -
char.
Created an alternative PR that handles modules' namespaces based on session
object https://github.com/daroczig/logger/pull/155
1 files 29 suites 22s :stopwatch: 362 tests 362 :white_check_mark: 0 :zzz: 0 :x: 830 runs 830 :white_check_mark: 0 :zzz: 0 :x:
Results for commit c6dd07df.
:recycle: This comment has been updated with latest results.
Filename Stmts Miss Cover Missing
---------------------------- ------- ------ ------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
R/FilterPanelAPI.R 10 0 100.00%
R/FilterState-utils.R 101 2 98.02% 264, 294
R/FilterState.R 363 63 82.64% 89, 210, 213, 231-235, 242-243, 257-258, 264-265, 312, 314, 316, 368, 412, 640, 683-706, 716-735, 749, 771-777, 786-792
R/FilterStateChoices.R 355 111 68.73% 301, 368-375, 379-396, 415, 425-428, 441-452, 464-472, 476-505, 526-529, 532-535, 546-572, 583, 588, 599
R/FilterStateDate.R 216 130 39.81% 230, 282-440
R/FilterStateDatettime.R 310 200 35.48% 266, 318-550
R/FilterStateEmpty.R 53 31 41.51% 89, 99-104, 117, 129-169
R/FilterStateExpr.R 76 63 17.11% 149-273
R/FilterStateLogical.R 197 145 26.40% 136, 158, 218, 222-407
R/FilterStateRange.R 409 106 74.08% 262, 384, 510-514, 517-527, 530, 542-548, 559-571, 575-585, 589-591, 605-632, 647, 650, 664-681, 695, 717-722, 732-734
R/FilterStates-utils.R 70 9 87.14% 108, 127, 188-194, 216, 245
R/FilterStates.R 365 31 91.51% 78-82, 191, 314-323, 411-414, 434, 458, 543-547, 592, 713-716
R/FilterStatesDF.R 5 0 100.00%
R/FilterStatesMAE.R 10 1 90.00% 40
R/FilterStatesMatrix.R 3 0 100.00%
R/FilterStatesSE.R 212 158 25.47% 36, 71-73, 83-85, 109-116, 124-131, 154-303
R/FilteredData-utils.R 68 25 63.24% 21-24, 27-30, 52-57, 153, 175-184
R/FilteredData.R 566 231 59.19% 110, 184, 326, 398, 501-510, 533, 554-595, 609, 614-617, 633, 674-707, 721, 723-725, 729-735, 764-792, 813, 816-818, 822-824, 827-841, 845-855, 858-901, 942, 965-987, 995
R/FilteredDataset-utils.R 23 1 95.65% 125
R/FilteredDataset.R 170 61 64.12% 52, 152, 191, 216-273, 312-314
R/FilteredDatasetDataframe.R 121 8 93.39% 87, 148, 158, 234-238
R/FilteredDatasetDefault.R 18 4 77.78% 103-116
R/FilteredDatasetMAE.R 134 37 72.39% 56, 117-122, 161-166, 170-171, 189-211
R/calls_combine_by.R 7 0 100.00%
R/choices_labeled.R 49 14 71.43% 25, 36, 41, 51-56, 68, 72-76
R/count_labels.R 102 0 100.00%
R/filter_panel_api.R 29 1 96.55% 132
R/include_css_js.R 5 5 0.00% 12-16
R/teal_slice.R 107 4 96.26% 131, 195-196, 206
R/teal_slices.R 84 5 94.05% 150-155
R/test_utils.R 21 0 100.00%
R/utils.R 18 0 100.00%
R/variable_types.R 15 8 46.67% 44-51
R/zzz.R 17 17 0.00% 3-47
TOTAL 4309 1471 65.86%
Filename Stmts Miss Cover
------------------------ ------- ------ -------
R/FilterState.R +2 +2 -0.46%
R/FilterStateChoices.R +1 +1 -0.19%
R/FilterStateDate.R +1 +1 -0.19%
R/FilterStateDatettime.R +1 +1 -0.11%
R/FilterStateExpr.R +1 +1 -0.23%
R/FilterStateLogical.R +1 +1 -0.13%
R/FilterStateRange.R +1 +1 -0.18%
R/FilterStates.R +1 +1 -0.25%
R/FilterStatesSE.R +1 +1 -0.12%
R/FilteredData.R +4 +4 -0.42%
TOTAL +14 +14 -0.21%
Results for commit: c6dd07dfc2f9b7e5d916b790a38d5562e2534fe9
Minimum allowed coverage is 80%
:recycle: This comment has been updated with latest results
Similar to https://github.com/insightsengineering/teal.modules.general/issues/239 and motivated by https://github.com/insightsengineering/teal.modules.general/issues/239#issuecomment-2106902891