Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: common/cloudlogging/severity.go

Issue 2937693003: Make luci-go compile again after deps.lock roll. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « common/cloudlogging/entry.go ('k') | common/logging/cloudlog/logging.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package cloudlogging
6
7 import (
8 "errors"
9 "strings"
10 )
11
12 // Severity defines how important a message is.
13 type Severity string
14
15 // All severity types understood by Cloud Logging.
16 const (
17 Default Severity = "DEFAULT"
18 Debug Severity = "DEBUG"
19 Info Severity = "INFO"
20 Notice Severity = "NOTICE"
21 Warning Severity = "WARNING"
22 Error Severity = "ERROR"
23 Critical Severity = "CRITICAL"
24 Alert Severity = "ALERT"
25 Emergency Severity = "EMERGENCY"
26 )
27
28 var knownSeverity = []Severity{
29 Default,
30 Debug,
31 Info,
32 Notice,
33 Warning,
34 Error,
35 Critical,
36 Alert,
37 Emergency,
38 }
39
40 // Validate returns a error if the severity is not recognized.
41 func (sev Severity) Validate() error {
42 for _, k := range knownSeverity {
43 if sev == k {
44 return nil
45 }
46 }
47 return errors.New("cloudlog: unknown severity")
48 }
49
50 // String is used by 'flag' package.
51 func (sev Severity) String() string {
52 return string(sev)
53 }
54
55 // Set is called by 'flag' package when parsing command line options.
56 func (sev *Severity) Set(value string) error {
57 val := Severity(strings.ToUpper(value))
58 if err := val.Validate(); err != nil {
59 return err
60 }
61 *sev = val
62 return nil
63 }
OLDNEW
« no previous file with comments | « common/cloudlogging/entry.go ('k') | common/logging/cloudlog/logging.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698