本文整理汇总了Python中sentry.constants.LOG_LEVELS.keys方法的典型用法代码示例。如果您正苦于以下问题:Python LOG_LEVELS.keys方法的具体用法?Python LOG_LEVELS.keys怎么用?Python LOG_LEVELS.keys使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sentry.constants.LOG_LEVELS
的用法示例。
在下文中一共展示了LOG_LEVELS.keys方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_group_generator
# 需要导入模块: from sentry.constants import LOG_LEVELS [as 别名]
# 或者: from sentry.constants.LOG_LEVELS import keys [as 别名]
def make_group_generator(random, project):
epoch = to_timestamp(datetime(2016, 6, 1, 0, 0, 0, tzinfo=timezone.utc))
for id in itertools.count(1):
first_seen = epoch + random.randint(0, 60 * 60 * 24 * 30)
last_seen = random.randint(first_seen, first_seen + (60 * 60 * 24 * 30))
culprit = make_culprit(random)
level = random.choice(LOG_LEVELS.keys())
message = make_message(random)
group = Group(
id=id,
project=project,
culprit=culprit,
level=level,
message=message,
first_seen=to_datetime(first_seen),
last_seen=to_datetime(last_seen),
status=random.choice((GroupStatus.UNRESOLVED, GroupStatus.RESOLVED, )),
data={
'type': 'default',
'metadata': {
'title': message,
}
}
)
if random.random() < 0.8:
group.data = make_group_metadata(random, group)
yield group
示例2: make_group_generator
# 需要导入模块: from sentry.constants import LOG_LEVELS [as 别名]
# 或者: from sentry.constants.LOG_LEVELS import keys [as 别名]
def make_group_generator(random, project):
epoch = to_timestamp(datetime(2016, 6, 1, 0, 0, 0, tzinfo=timezone.utc))
for id in itertools.count(1):
first_seen = epoch + random.randint(0, 60 * 60 * 24 * 30)
last_seen = random.randint(first_seen, first_seen + (60 * 60 * 24 * 30))
group = Group(
id=id,
project=project,
culprit=make_culprit(random),
level=random.choice(LOG_LEVELS.keys()),
message=make_message(random),
first_seen=to_datetime(first_seen),
last_seen=to_datetime(last_seen),
)
if random.random() < 0.8:
group.data = make_group_metadata(random, group)
yield group
示例3: digest
# 需要导入模块: from sentry.constants import LOG_LEVELS [as 别名]
# 或者: from sentry.constants.LOG_LEVELS import keys [as 别名]
def digest(request):
seed = request.GET.get('seed', str(time.time()))
logger.debug('Using random seed value: %s')
random = Random(seed)
now = datetime.utcnow().replace(tzinfo=pytz.utc)
# TODO: Refactor all of these into something more manageable.
org = Organization(
id=1,
slug='example',
name='Example Organization',
)
team = Team(
id=1,
slug='example',
name='Example Team',
organization=org,
)
project = Project(
id=1,
slug='example',
name='Example Project',
team=team,
organization=org,
)
rules = {i: Rule(
id=i,
project=project,
label="Rule #%s" % (i,),
) for i in xrange(1, random.randint(2, 4))}
state = {
'project': project,
'groups': {},
'rules': rules,
'event_counts': {},
'user_counts': {},
}
records = []
group_sequence = itertools.count(1)
event_sequence = itertools.count(1)
for i in xrange(random.randint(1, 30)):
group_id = next(group_sequence)
culprit = '{module} in {function}'.format(
module='.'.join(
''.join(random.sample(WORDS, random.randint(1, int(random.paretovariate(2.2))))) for word in xrange(1, 4)
),
function=random.choice(WORDS)
)
group = state['groups'][group_id] = Group(
id=group_id,
project=project,
message=words(int(random.weibullvariate(8, 4)), common=False),
culprit=culprit,
level=random.choice(LOG_LEVELS.keys()),
)
offset = timedelta(seconds=0)
for i in xrange(random.randint(1, 10)):
offset += timedelta(seconds=random.random() * 120)
event = Event(
id=next(event_sequence),
event_id=uuid.uuid4().hex,
project=project,
group=group,
message=group.message,
data=load_data('python'),
datetime=now - offset,
)
records.append(
Record(
event.event_id,
Notification(
event,
random.sample(state['rules'], random.randint(1, len(state['rules']))),
),
to_timestamp(event.datetime),
)
)
state['event_counts'][group_id] = random.randint(10, 1e4)
state['user_counts'][group_id] = random.randint(10, 1e4)
digest = build_digest(project, records, state)
start, end, counts = get_digest_metadata(digest)
return MailPreview(
html_template='sentry/emails/digests/body.html',
text_template='sentry/emails/digests/body.txt',
context={
'project': project,
#.........这里部分代码省略.........
示例4: digest
# 需要导入模块: from sentry.constants import LOG_LEVELS [as 别名]
# 或者: from sentry.constants.LOG_LEVELS import keys [as 别名]
def digest(request):
seed = request.GET.get('seed', str(time.time()))
logger.debug('Using random seed value: %s')
random = Random(seed)
now = datetime.utcnow().replace(tzinfo=pytz.utc)
# TODO: Refactor all of these into something more manageable.
org = Organization(
id=1,
slug='example',
name='Example Organization',
)
team = Team(
id=1,
slug='example',
name='Example Team',
organization=org,
)
project = Project(
id=1,
slug='example',
name='Example Project',
team=team,
organization=org,
)
rules = {i: Rule(
id=i,
project=project,
label="Rule #%s" % (i,),
) for i in xrange(1, random.randint(2, 4))}
state = {
'project': project,
'groups': {},
'rules': rules,
'event_counts': {},
'user_counts': {},
}
records = []
group_sequence = itertools.count(1)
event_sequence = itertools.count(1)
for i in xrange(random.randint(1, 30)):
group_id = next(group_sequence)
group = state['groups'][group_id] = Group(
id=group_id,
project=project,
message=words(int(random.paretovariate(1.05)), common=False),
culprit=words(int(random.paretovariate(1)), common=False),
level=random.choice(LOG_LEVELS.keys()),
)
offset = timedelta(seconds=0)
for i in xrange(random.randint(1, 10)):
offset += timedelta(seconds=random.random() * 120)
event = Event(
id=next(event_sequence),
event_id=uuid.uuid4().hex,
project=project,
group=group,
message=group.message,
data=load_data('python'),
datetime=now - offset,
)
records.append(
Record(
event.event_id,
Notification(
event,
random.sample(state['rules'], random.randint(1, len(state['rules']))),
),
to_timestamp(event.datetime),
)
)
state['event_counts'][group_id] = random.randint(10, 1e4)
state['user_counts'][group_id] = random.randint(10, 1e4)
digest = build_digest(project, records, state)
# TODO(tkaemming): This duplication from ``MailPlugin.notify_digest`` is a code smell
counts = Counter()
for rule, groups in digest.iteritems():
counts.update(groups.keys())
return MailPreview(
html_template='sentry/emails/digests/body.html',
text_template='sentry/emails/digests/body.txt',
context={
'project': project,
'counts': counts,
'digest': digest,
#.........这里部分代码省略.........