Skip to content

Commit

Permalink
fix: improve logging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
pivoshenko committed Feb 8, 2025
1 parent ace87c5 commit 698025e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/poetry_plugin_dotenv/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,23 @@ def load(self, event: ConsoleCommandEvent, *args, **kwargs) -> None: # type: ig
return # pragma: nocover

if config.ignore:
logger.warning("Not loading environment variables.")
logger.warning("Not loading environment variables")
return

filepath = self._determine_filepath(config, working_dir)

if filepath == "":
logger.warning("Not loading environment variables")
return

if os.path.isfile(filepath):
logger.info(f"Loading environment variables from '{filepath}'.")
msg = f"Loading environment variables: <fg=green>{filepath}</>"
logger.info(msg)
dotenv.core.load(filepath)

else:
logger.error(f"File '{filepath}' doesn't exist.")
msg = f"Could not load environment variables. The file does not exist: {filepath}"
logger.error(msg)

def _determine_filepath(self, config: Config, working_dir: str) -> str:
"""Determine the appropriate filepath for the dotenv file."""
Expand Down

0 comments on commit 698025e

Please sign in to comment.