logfire
v2.5.0
從Pydantic背後的團隊中, LogFire是一個基於與我們的開源庫相同信念的可觀察性平台 - 最強大的工具可以易於使用。
是什麼設置了logfire:
有關更多信息,請參見文檔。
隨時報告問題,並在此存儲庫中詢問有關logfire的任何問題!
此存儲庫包含用於logfire
和文檔的Python SDK;用於錄製和顯示數據的服務器應用程序已關閉源。
這是關於如何使用LogFire的非常簡短的概述,該文檔具有更多的詳細信息。
pip install logfire
(了解更多)
logfire auth
(了解更多)
這是一個簡單的手動跟踪(又名記錄)示例:
import logfire
from datetime import date
logfire . info ( 'Hello, {name}!' , name = 'world' )
with logfire . span ( 'Asking the user their {question}' , question = 'age' ):
user_input = input ( 'How old are you [YYYY-mm-dd]? ' )
dob = date . fromisoformat ( user_input )
logfire . debug ( '{dob=} {age=!r}' , dob = dob , age = date . today () - dob )
(了解更多)
或者,您也可以避免手動儀器,並與許多流行的軟件包集成在一起,這是與FastApi集成的示例:
import logfire
from pydantic import BaseModel
from fastapi import FastAPI
app = FastAPI ()
logfire . configure ()
logfire . instrument_fastapi ( app )
# next, instrument your database connector, http library etc. and add the logging handler
class User ( BaseModel ):
name : str
country_code : str
@ app . post ( '/' )
async def add_user ( user : User ):
# we would store the user here
return { 'message' : f' { user . name } added' }
(了解更多)
logFire使您可以了解您的代碼如何運行:
我們希望任何有興趣為LogFire SDK和文檔做出貢獻的人,請參閱《貢獻指南》。
請參閱我們的安全政策。