diff --git a/README.md b/README.md index 7341d10bd1d..9e04b721077 100644 --- a/README.md +++ b/README.md @@ -816,7 +816,7 @@ Configuration is assisted with auto-completion and validation in most commonly u | [**PRE_COMMANDS**](#pre-commands) | \[\] | Custom bash commands to run before linters | | **PRINT_ALPACA** | `true` | Enable printing alpaca image to console | | **PRINT_ALL_FILES** | `false` | Display all files analyzed by the linter instead of only the number | -| **REPORT_OUTPUT_FOLDER** | `${GITHUB_WORKSPACE}/megalinter-reports` | Directory for generating report files. Send `none` to not generate reports | +| **REPORT_OUTPUT_FOLDER** | `${GITHUB_WORKSPACE}/megalinter-reports` | Directory for generating report files. Set to `none` to not generate reports | | **SHOW_ELAPSED_TIME** | `false` | Displays elapsed time in reports | | **SHOW_SKIPPED_LINTERS** | `true` | Displays all disabled linters mega-linter could have run | | **SKIP_CLI_LINT_MODES** | \[\] | Comma-separated list of cli_lint_modes. To use if you want to skip linters with some CLI lint modes (ex: `file,project`). Available values: `file`,`cli_lint_mode`,`project`. | diff --git a/megalinter/MegaLinter.py b/megalinter/MegaLinter.py index 8f2e9862e84..0c6c7b37016 100644 --- a/megalinter/MegaLinter.py +++ b/megalinter/MegaLinter.py @@ -761,10 +761,10 @@ def initialize_logger(self): if logging_level_key in logging_level_list else logging.INFO ) - log_file = ( - self.report_folder + os.path.sep + config.get("LOG_FILE", "megalinter.log") - ) - if config.get("LOG_FILE", "") == "none": + + if config.get("LOG_FILE", "") == "none" or not utils.can_write_report_files( + self + ): # Do not log console output in a file logging.basicConfig( force=True, @@ -775,6 +775,11 @@ def initialize_logger(self): ], ) else: + log_file = ( + self.report_folder + + os.path.sep + + config.get("LOG_FILE", "megalinter.log") + ) # Log console output in a file if not os.path.isdir(os.path.dirname(log_file)): os.makedirs(os.path.dirname(log_file), exist_ok=True) diff --git a/megalinter/linters/CSpellLinter.py b/megalinter/linters/CSpellLinter.py index 6de9a5a6cce..57e2bccfe9d 100644 --- a/megalinter/linters/CSpellLinter.py +++ b/megalinter/linters/CSpellLinter.py @@ -52,7 +52,7 @@ def execute_lint_command(self, command): # noinspection PyMethodMayBeStatic def complete_text_reporter_report(self, reporter_self): # Collect detected words from logs - if self.stdout is None: + if self.stdout is None or not utils.can_write_report_files(self.master): return [] whitelisted_words = [] for log_line in self.stdout.split("\n"):