From 8bccc2867485aad86555aba865b451aab9e8527a Mon Sep 17 00:00:00 2001 From: Ryan Blunden Date: Thu, 8 Dec 2022 15:47:32 -0800 Subject: [PATCH] Make logging configurable and disabled by default (#9) --- CHANGELOG.md | 6 +++++- README.md | 9 +++++++++ setup.py | 2 +- src/doppler_env/__init__.py | 5 ++++- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d90004b..0c3cd88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,4 +27,8 @@ - Check that Doppler CLI is installed - Add support for CLI and Personal tokens - Improved README -- Fix paths issue preventing wheel build on Windows \ No newline at end of file +- Fix paths issue preventing wheel build on Windows + +## 0.3.1 December 8, 2022 + +- Logging is now disabled by default and can be enabled by setting the `DOPPLER_ENV_LOGGING` environment variable. \ No newline at end of file diff --git a/README.md b/README.md index 9554c02..7695f4b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # doppler-env The doppler-env package automates the injection of Doppler secrets as environment variables into any Python application and works in the terminal, PyCharm, and Visual Studio Code. + ## Motivation The Doppler CLI provides the easiest method of injecting secrets into your application: @@ -35,6 +36,12 @@ First, define the `DOPPLER_ENV` environment variable in your IDE, editor, or ter export DOPPLER_ENV=1 ``` +You can enable logging for troubleshooting purposes by setting the `DOPPLER_ENV_LOGGING` environment variable: + +```sh +export DOPPLER_ENV_LOGGING=1 +``` + Then configure which secrets to fetch for your application by either using the CLI in the root directory of your application: ```sh @@ -55,6 +62,8 @@ In restrictive environments where the use of the Doppler CLI isn't possible, set ```sh +export DOPPLER_TOKEN='dp.st.dev.xxxxxxx' + python app.py # >> [doppler-env]: DOPPLER_ENV and DOPPLER_TOKEN environment variable set. Fetching secrets from Doppler API diff --git a/setup.py b/setup.py index d6d90c5..31b4281 100755 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ setup( name='doppler_env', - version='0.3.0', + version='0.3.1', python_requires='>=3.6', description='Inject Doppler secrets as environment variables into your Python application during local development with debugging support for PyCharm and Visual Studio Code.', long_description=open('README.md').read(), diff --git a/src/doppler_env/__init__.py b/src/doppler_env/__init__.py index ec930b5..2dffabf 100644 --- a/src/doppler_env/__init__.py +++ b/src/doppler_env/__init__.py @@ -12,9 +12,12 @@ from dotenv import load_dotenv +LOGGING_ENABLED = True if os.environ.get('DOPPLER_ENV_LOGGING') is not None else False + def log(message): - print('[doppler-env]: {}'.format(message)) + if LOGGING_ENABLED: + print('[doppler-env]: {}'.format(message)) def print_debug_info(doppler_token=None, project=None, config=None):