Skip to content

Commit

Permalink
Rename LOG_LEVEL to MISTRAL_LOG_LEVEL
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonsilva committed May 23, 2024
1 parent a5dc85a commit 3c33c93
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Get this from https://console.mistral.ai/api-keys/
MISTRAL_API_KEY=
LOG_LEVEL=ERROR
MISTRAL_LOG_LEVEL=ERROR
11 changes: 11 additions & 0 deletions PYTHON_CLIENT_COMPARISON.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,14 @@ coverage and using RSpec, which is usually what I do.

The `function_calling.rb` example omits the unnecessary `n_rows = data['transaction_id'].length` line present in
the Python version.

## Logging

Python has a global logger:

```python
self._logger = logging.getLogger(__name__)
```

Ruby doesn't. Thus, in order to allow users to customize the logging level, they can set the environment variable
`MISTRAL_LOG_LEVEL` to `DEBUG`, `INFO`, `WARN`, `ERROR` or `FATAL`.
3 changes: 1 addition & 2 deletions lib/mistral/client_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ def initialize(endpoint:, api_key: nil, max_retries: 5, timeout: 120)
@api_key = api_key
@max_retries = max_retries
@timeout = timeout

@logger = config_logger

# For azure endpoints, we default to the mistral model
Expand Down Expand Up @@ -115,7 +114,7 @@ def process_line(line)

def config_logger
Logger.new($stdout).tap do |logger|
logger.level = ENV.fetch('LOG_LEVEL', 'ERROR')
logger.level = ENV.fetch('MISTRAL_LOG_LEVEL', 'ERROR')

logger.formatter = proc do |severity, datetime, progname, msg|
"#{datetime.strftime("%Y-%m-%d %H:%M:%S")} #{severity} #{progname}: #{msg}\n"
Expand Down

0 comments on commit 3c33c93

Please sign in to comment.