langchain/libs/community/langchain_community/utils
Enzo Poggio 8f019e91d7
community[patch]: Use Custom Logger Instead of Root Logger in get_user_agent Function (#22691)
## Description
This PR addresses a logging inconsistency in the `get_user_agent`
function. Previously, the function was using the root logger to log a
warning message when the "USER_AGENT" environment variable was not set.
This bypassed the custom logger `log` that was created at the start of
the module, leading to potential inconsistencies in logging behavior.

Changes:
- Replaced `logging.warning` with `log.warning` in the `get_user_agent`
function to ensure that the custom logger is used.

This change ensures that all logging in the `get_user_agent` function
respects the configurations of the custom logger, leading to more
consistent and predictable logging behavior.

## Dependencies

None

## Issue 

None

## Tests and docs

☝🏻 see description


## `make format`, `make lint` & `cd libs/community; make test`

```shell
> make format 
poetry run ruff format docs templates cookbook
1417 files left unchanged
poetry run ruff check --select I --fix docs templates cookbook
All checks passed!
```

```shell
> make lint
poetry run ruff check docs templates cookbook
All checks passed!
poetry run ruff format docs templates cookbook --diff
1417 files already formatted
poetry run ruff check --select I docs templates cookbook
All checks passed!
git grep 'from langchain import' docs/docs templates cookbook | grep -vE 'from langchain import (hub)' && exit 1 || exit 0
```

~cd libs/community; make test~ too much dependencies for integration ...

```shell
>  poetry run pytest tests/unit_tests   
....
==== 884 passed, 466 skipped, 4447 warnings in 15.93s ====
```

I choose you randomly : @ccurme
2024-06-08 02:33:07 +00:00
..
__init__.py refactor utils (#15432) 2024-01-02 14:56:38 -08:00
ernie_functions.py community[patch]: docstrings update (#20301) 2024-04-11 16:23:27 -04:00
google.py community[patch]: docstrings update (#20301) 2024-04-11 16:23:27 -04:00
math.py community, milvus, pinecone, qdrant, mongo: Broadcast operation failure while using simsimd beyond v3.7.7 (#22271) 2024-06-04 17:36:31 +00:00
openai_functions.py openai[minor]: implement langchain-openai package (#15503) 2024-01-05 15:03:28 -08:00
openai.py docs: docstrings langchain_community update (#14889) 2023-12-19 08:58:24 -05:00
user_agent.py community[patch]: Use Custom Logger Instead of Root Logger in get_user_agent Function (#22691) 2024-06-08 02:33:07 +00:00