django sentry的配置

本篇文章介紹sentry在django中的基本配置django

  • settingcode

INSTALLED_APPS = [
     'raven.contrib.django.raven_compat',
]
RAVEN_CONFIG = {
    'dsn': '',
}
  • 引入io

from raven.contrib.django.raven_compat.models import client
  • 基礎寫法import

clint.captureException()
  • 指定user基礎

clint.user_context({
    'id': user.id,
    'username': user.username,
})
clint.captureException()
  • 其它拓展cli

clint.captureException(
    level='warning', #指定錯誤等級 默認爲error
    tags={'message': message}, #追加tags
    fingerprint=[code, message], # 相同fingerprint歸爲一類
)
相關文章
相關標籤/搜索