Skip to content

Commit 8a85a40

Browse files
committed
feat(Logs): allow configuration of logging levels
1 parent 0ea560b commit 8a85a40

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
![build](https://github.com/stax-labs/lib-stax-python-sdk/workflows/build/badge.svg)
66
![deploy](https://github.com/stax-labs/lib-stax-python-sdk/workflows/deploy/badge.svg)
77
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/staxapp)
8+
![Python - Logging Levels](https://docs.python.org/3/library/logging.html#levels)
89
## Authentication
910
In order to use the Stax SDK for Python, you will need a valid [Stax API Token](https://www.stax.io/developer/api-tokens/).
1011

@@ -31,6 +32,22 @@ Allows configuration of the threshold to when the Auth library should re-cache t
3132
export TOKEN_EXPIRY_THRESHOLD_IN_MINS=2 # Type: Integer representing minutes
3233
~~~
3334

35+
##### Logging levels
36+
37+
As the logging levels are set on the import of the `Config` module, the below configuration is available on the presense of following environment variables:
38+
39+
- LOG_LEVEL: Default logger level
40+
- LOG_LEVEL_BOTO3: `boto3` logger level
41+
- LOG_LEVEL_BOTOCORE: `botocore` logger level
42+
- LOG_LEVEL_NOSE: `nose` logger level
43+
- LOG_LEVEL_URLLIB3: `urllib3` logger level
44+
45+
Example:
46+
~~~bash
47+
export LOG_LEVEL=INFO LOG_LEVEL_BOTO3=WARNING
48+
python run_example.py
49+
~~~
50+
3451
## Usage
3552

3653
### Read Accounts

staxapp/config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import staxapp
88
from staxapp.exceptions import ApiException
99

10-
logging.getLogger().setLevel(logging.DEBUG)
11-
logging.getLogger("boto3").setLevel(logging.WARNING)
12-
logging.getLogger("botocore").setLevel(logging.WARNING)
13-
logging.getLogger("nose").setLevel(logging.WARNING)
14-
logging.getLogger("urllib3").setLevel(logging.WARNING)
10+
logging.getLogger().setLevel(os.environ.get("LOG_LEVEL", logging.DEBUG))
11+
logging.getLogger("boto3").setLevel(os.environ.get("LOG_LEVEL_BOTO3", logging.WARNING))
12+
logging.getLogger("botocore").setLevel(os.environ.get("LOG_LEVEL_BOTOCORE", logging.WARNING))
13+
logging.getLogger("nose").setLevel(os.environ.get("LOG_LEVEL_NOSE", logging.WARNING))
14+
logging.getLogger("urllib3").setLevel(os.environ.get("LOG_LEVEL_URLLIB3", logging.WARNING))
1515

1616

1717
class Config:

0 commit comments

Comments
 (0)