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和文档做出贡献的人,请参阅《贡献指南》。
请参阅我们的安全政策。