Skip to content

Commit

Permalink
Merge pull request #36 from tutorcruncher/minor-logging-changes
Browse files Browse the repository at this point in the history
Logging changes
  • Loading branch information
HenryTraill authored Oct 16, 2024
2 parents ca0715f + c9724d6 commit 84a6329
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
8 changes: 6 additions & 2 deletions chronos/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'default': {'()': 'uvicorn.logging.DefaultFormatter', 'fmt': '%(levelprefix)s %(message)s', 'use_colors': None},
'default': {
'defaults': 'uvicorn.logging.DefaultFormatter',
'fmt': '%(levelprefix)s %(message)s',
'use_colors': None,
},
'access': {
'()': 'uvicorn.logging.AccessFormatter',
'defaults': 'uvicorn.logging.AccessFormatter',
'fmt': "%(levelprefix)s %(client_addr)s - '%(request_line)s' %(status_code)s", # noqa: E501
},
},
Expand Down
15 changes: 6 additions & 9 deletions chronos/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import logfire
import sentry_sdk
from fastapi import FastAPI
from logfire import PydanticPlugin
from starlette.middleware.cors import CORSMiddleware

from chronos.logging import config
Expand Down Expand Up @@ -33,21 +32,19 @@


if bool(_app_settings.logfire_token):
logfire.instrument_fastapi(app)
logfire.instrument_celery()
logfire.configure(
send_to_logfire=True,
service_name='chronos',
token=_app_settings.logfire_token,
pydantic_plugin=PydanticPlugin(record='all'),
send_to_logfire=True,
console=False,
)
logfire.instrument_fastapi(app)
logfire.instrument_celery()
logfire.instrument_pydantic(record=_app_settings.logfire_log_level)
logfire.instrument_psycopg()
logfire.instrument_requests()

logging.config.dictConfig(config)

app.include_router(main_router, prefix='')
app.include_router(cronjob, prefix='')

COMMIT = os.getenv('HEROKU_SLUG_COMMIT', '-')[:7]
RELEASE_CREATED_AT = os.getenv('HEROKU_RELEASE_CREATED_AT', '-')
# logfire.info('starting app {commit=} {release_created_at=}', commit=COMMIT, release_created_at=RELEASE_CREATED_AT)
4 changes: 2 additions & 2 deletions chronos/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ class Settings(BaseSettings):
# Dev and Test settings
testing: bool = False
dev_mode: bool = False
log_level: str = 'INFO'
log_level: str = 'ERROR'
on_beta: bool = False

logfire_token: Optional[str] = None
logfire_ignore_no_config: int = 1
logfire_log_level: str = 'all'

# Postgres
pg_dsn: str = 'postgresql://postgres:postgres@localhost:5432/chronos'
Expand Down

0 comments on commit 84a6329

Please sign in to comment.