Skip to content

Commit 63ae9fa

Browse files
committed
docs: add section about logging
1 parent 4504cab commit 63ae9fa

1 file changed

Lines changed: 58 additions & 10 deletions

File tree

README.md

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,64 @@ confidence.track("event_name", {
5959
})
6060
```
6161

62+
## OpenFeature
63+
64+
The library includes a `Provider` for
65+
the [OpenFeature Python SDK](https://openfeature.dev/docs/tutorials/getting-started/python), that can be
66+
used to resolve feature flag values from the Confidence platform.
67+
68+
To learn more about the basic concepts (flags, targeting key, evaluation contexts),
69+
the [OpenFeature reference documentation](https://openfeature.dev/docs/reference/intro) can be
70+
useful.
71+
72+
73+
## Logging
74+
75+
The SDK includes built-in logging functionality to help with debugging and monitoring. By default, the SDK creates a logger named `confidence_logger` that outputs to the console with DEBUG level logging enabled.
76+
77+
### Default logging behavior
78+
79+
When you create a Confidence client without specifying a logger, debug-level logging is automatically enabled:
80+
81+
```python
82+
from confidence.confidence import Confidence
83+
84+
# Debug logging is enabled by default
85+
confidence = Confidence("CLIENT_TOKEN")
86+
```
87+
88+
This will output log messages such as flag resolution details, error messages, and debug information to help troubleshoot issues.
89+
90+
### Using a custom logger
91+
92+
You can provide your own logger instance to customize the logging behavior:
93+
94+
```python
95+
import logging
96+
from confidence.confidence import Confidence
97+
98+
# Create a custom logger with INFO level (less verbose)
99+
custom_logger = logging.getLogger("my_confidence_logger")
100+
custom_logger.setLevel(logging.INFO)
101+
102+
confidence = Confidence("CLIENT_TOKEN", logger=custom_logger)
103+
```
104+
105+
### Disabling debug logging
106+
107+
To reduce log verbosity, you can configure a logger with a higher log level:
108+
109+
```python
110+
import logging
111+
from confidence.confidence import Confidence
112+
113+
# Create a logger that only shows warnings and errors
114+
quiet_logger = logging.getLogger("quiet_confidence_logger")
115+
quiet_logger.setLevel(logging.WARNING)
116+
117+
confidence = Confidence("CLIENT_TOKEN", logger=quiet_logger)
118+
```
119+
62120
## Telemetry
63121

64122
The SDK includes telemetry functionality that helps monitor SDK performance and usage. By default, telemetry is enabled and collects metrics (anonymously) such as resolve latency and request status. This data is used by the Confidence team to improve the product, and in certain cases it is also available to the SDK adopters.
@@ -70,13 +128,3 @@ confidence = Confidence("CLIENT_TOKEN",
70128
disable_telemetry=True
71129
)
72130
```
73-
74-
## OpenFeature
75-
76-
The library includes a `Provider` for
77-
the [OpenFeature Python SDK](https://openfeature.dev/docs/tutorials/getting-started/python), that can be
78-
used to resolve feature flag values from the Confidence platform.
79-
80-
To learn more about the basic concepts (flags, targeting key, evaluation contexts),
81-
the [OpenFeature reference documentation](https://openfeature.dev/docs/reference/intro) can be
82-
useful.

0 commit comments

Comments
 (0)