|
18 | 18 |
|
19 | 19 | def gather_log_files(): |
20 | 20 | """ |
21 | | - Gather a list of the standard Kodi log files (Kodi.log, Kodi.old.log) and the latest crash log, if there is one. |
22 | | -
|
23 | | - @return: list of log files in form [type, path], where type is log, oldlog, or crashlog |
| 21 | + Return a list of Kodi-related log files to copy: the main log, optional old log, and recent crash log(s). |
| 22 | + |
| 23 | + The function inspects the configured LOG_PATH for kodi.log and kodi.old.log and attempts to locate platform-specific crash logs |
| 24 | + (if present) in known crash-report directories. Crash logs are filtered to those modified within the last 3 days; the most |
| 25 | + recent crash file is included (Windows may include the two most recent files because crash dumps come with accompanying stack traces). |
| 26 | + |
| 27 | + Returns: |
| 28 | + list: A list of entries [type, path], where `type` is one of 'log', 'oldlog', or 'crashlog' and `path` is the full filesystem path. |
24 | 29 | """ |
25 | 30 |
|
26 | 31 | # Basic log files |
@@ -90,10 +95,19 @@ def gather_log_files(): |
90 | 95 |
|
91 | 96 | def copy_log_files(log_files: List) -> bool: |
92 | 97 | """ |
93 | | - Actually copy the log files to the path in the addon settings |
94 | | -
|
95 | | - @param log_files: List list of log files to copy |
96 | | - @return bool: indicating success or failure |
| 98 | + Copy the provided Kodi log files into a timestamped destination folder under the configured addon destination. |
| 99 | + |
| 100 | + Detailed behavior: |
| 101 | + - Expects log_files as a list of 2-element entries [type, path], where `type` is e.g. 'log', 'oldlog', or 'crashlog' and `path` is the source filesystem path. |
| 102 | + - Creates a destination directory at Store.destination_path named "<hostname>_Kodi_Logs_<YYYY-MM-DD_HH-MM-SS>". |
| 103 | + - For entries with type 'log' or 'oldlog', reads the source, sanitizes the content with clean_log(), and writes the sanitized content to a file with the same basename in the destination folder. |
| 104 | + - For other types (e.g., crash logs), copies the source file to the destination folder unchanged. |
| 105 | + |
| 106 | + Parameters: |
| 107 | + log_files (List): list of log descriptors [type, path] to copy. |
| 108 | + |
| 109 | + Returns: |
| 110 | + bool: True if all files were copied (and sanitized when applicable) successfully; False if the input list is empty or an error occurred during processing. |
97 | 111 | """ |
98 | 112 | if not log_files: |
99 | 113 | Logger.error(LANGUAGE(32025)) |
@@ -128,6 +142,17 @@ def copy_log_files(log_files: List) -> bool: |
128 | 142 |
|
129 | 143 | # This is 'main'... |
130 | 144 | def run(): |
| 145 | + """ |
| 146 | + Run the log collection and copying flow: initialize logging, load configuration, gather Kodi log files, copy them to the configured destination, notify the user, and stop logging. |
| 147 | + |
| 148 | + This function performs the module's main orchestration. It: |
| 149 | + - Starts the logger and loads addon configuration from settings. |
| 150 | + - If no destination path is configured, shows an error notification and skips copying. |
| 151 | + - Otherwise, notifies the user, gathers available log files, attempts to copy them to the configured destination, and notifies success (including number of files copied) or failure. |
| 152 | + - Stops the logger before returning. |
| 153 | + |
| 154 | + Side effects: starts/stops the logger, reads configuration, performs filesystem operations (reading, sanitizing, and copying log files), and shows user notifications. Returns None. |
| 155 | + """ |
131 | 156 | Logger.start() |
132 | 157 | Store.load_config_from_settings() |
133 | 158 |
|
|
0 commit comments