Skip to content

Commit

Permalink
Change default of --fatal command line arg to terminate on error
Browse files Browse the repository at this point in the history
  • Loading branch information
boxydog committed May 31, 2024
1 parent ccb4e58 commit d8e4563
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
3 changes: 3 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Release type: major

Change default of `--fatal` command line switch to terminate on error.
10 changes: 5 additions & 5 deletions pelican/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,12 +438,12 @@ def parse_arguments(argv=None):

parser.add_argument(
"--fatal",
metavar="errors|warnings",
choices=("errors", "warnings"),
default="",
metavar="errors|warnings|ignore",
choices=("errors", "warnings", "ignore"),
default="errors",
help=(
"Exit the program with non-zero status if any "
"errors/warnings encountered."
"errors/warnings encountered, or ignore any errors."
),
)

Expand Down Expand Up @@ -634,7 +634,7 @@ def main(argv=None):
logs_dedup_min_level = getattr(logging, args.logs_dedup_min_level)
init_logging(
level=args.verbosity,
fatal=args.fatal,
fatal=args.fatal if args.fatal != "ignore" else "",
name=__name__,
handler=args.log_handler,
logs_dedup_min_level=logs_dedup_min_level,
Expand Down
2 changes: 1 addition & 1 deletion pelican/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def error(self, *args, stacklevel=1, **kwargs):

def init(
level=None,
fatal="",
fatal="errors",
handler=DEFAULT_LOG_HANDLER,
name=None,
logs_dedup_min_level=None,
Expand Down
20 changes: 20 additions & 0 deletions pelican/tests/test_init.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import unittest
from unittest.mock import MagicMock, patch

from pelican import DEFAULT_LOG_HANDLER, main


class TestLog(unittest.TestCase):
@patch("pelican.get_instance")
@patch("pelican.init_logging")
def test_main_fatal_default(self, init_logging_mock, get_instance):
get_instance.side_effect = lambda *args, **kwargs: (MagicMock(), MagicMock())
main()
init_logging_mock.assert_called_once_with(
level=None,
# default is "errors"
fatal="errors",
name="pelican",
handler=DEFAULT_LOG_HANDLER,
logs_dedup_min_level=30,
)

0 comments on commit d8e4563

Please sign in to comment.