Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix logging #47

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/gather/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def dunder_main(globals_dct, command_data, logger=logging.getLogger()):
formatter = logging.Formatter("%(asctime)s:%(levelname)s:%(name)s:%(message)s")
ch.setFormatter(formatter)
logger.addHandler(ch)
logger.setLevel(logging.INFO)
commandslib.run_maybe_dry(
parser=commandslib.set_parser(collected=command_data.collector.collect()),
is_subcommand=globals_dct.get("IS_SUBCOMMAND", False),
Expand Down
16 changes: 9 additions & 7 deletions src/gather/example/breakfast.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
"""Breakfast plugins"""
import sys
import logging

import gather

from . import ENTRY_DATA

BREAKFAST = gather.Collector()

LOGGER = logging.getLogger(__name__)


@ENTRY_DATA.register()
def breakfast(args):
Expand All @@ -25,11 +27,11 @@ class Eggs(object):

def prepare(self):
"""Prepare eggs by scrambling"""
sys.stdout.write("Scrambling eggs\n")
LOGGER.info("Scrambling eggs")

def eat(self):
"""Eat the eggs by devouring"""
sys.stdout.write("Devouring eggs\n")
LOGGER.info("Devouring eggs")


@BREAKFAST.register()
Expand All @@ -39,11 +41,11 @@ class Cereal(object):

def prepare(self):
"""Prepare cereal by mixing it with milk"""
sys.stdout.write("Mixing cereal and milk\n")
LOGGER.info("Mixing cereal and milk")

def eat(self):
"""Eat cereal with a spoon"""
sys.stdout.write("Eating cereal with a spoon\n")
LOGGER.info("Eating cereal with a spoon")


@BREAKFAST.register()
Expand All @@ -53,8 +55,8 @@ class OrangeJuice(object):

def prepare(self):
"""Prepare juice by squeezing it"""
sys.stdout.write("Squeezing orange juice\n")
LOGGER.info("Squeezing orange juice")

def eat(self):
"""Consume the juice by drinking it"""
sys.stdout.write("Drinking orange juice\n")
LOGGER.info("Drinking orange juice")
Loading