Logging Web Interface
**Work in progress**
This commit is contained in:
1 parent
c5e8a30e68
commit
45f2789048
10 files changed
+117
-23
No files matched your search
+18
-1
@@ -9,7 +9,7 @@ const (
|
||||
CategoryUSER = Category(iota)
|
||||
)
|
||||
|
||||
func FormatCategory(cat Category) (result string) {
|
||||
func (cat Category) Format() (result string) {
|
||||
switch cat {
|
||||
case CategoryBUSINESS:
|
||||
result = `C:BUSINESS`
|
||||
@@ -25,3 +25,20 @@ func FormatCategory(cat Category) (result string) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func ParseCategory(cat string) (value Category) {
|
||||
switch cat {
|
||||
case `C:BUSINESS`:
|
||||
value = CategoryBUSINESS
|
||||
case `C:APP`:
|
||||
value = CategoryAPP
|
||||
case `C:SYSTEM`:
|
||||
value = CategorySYSTEM
|
||||
case `C:USER`:
|
||||
value = CategoryUSER
|
||||
default:
|
||||
value = CategoryAPP
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
+1
-1
@@ -29,7 +29,7 @@ func (entry Entry) Format() (result string) {
|
||||
messageDescription = strings.Replace(messageDescription, "\t", ` `, -1)
|
||||
messageDescription = strings.Replace(messageDescription, "\r", ` `, -1)
|
||||
|
||||
result = fmt.Sprintf(` [■] P:%10s [■] %s [■] %10s [■] %11s [■] %10s [■] %10s [■] sender: %-40s [■] name: %-26s [■] %s [■]`, entry.Project[:lenProject], formatTime(entry.Time), FormatCategory(entry.Category), FormatLevel(entry.Level), FormatSeverity(entry.Severity), FormatImpact(entry.Impact), entry.Sender[:lenSender], entry.MessageName[:lenMessageName], messageDescription)
|
||||
result = fmt.Sprintf(` [■] P:%10s [■] %s [■] %10s [■] %11s [■] %10s [■] %10s [■] sender: %-40s [■] name: %-26s [■] %s [■]`, entry.Project[:lenProject], formatTime(entry.Time), entry.Category.Format(), entry.Level.Format(), entry.Severity.Format(), entry.Impact.Format(), entry.Sender[:lenSender], entry.MessageName[:lenMessageName], messageDescription)
|
||||
|
||||
for _, param := range entry.Parameters {
|
||||
|
||||
|
||||
+22
-1
@@ -11,7 +11,7 @@ const (
|
||||
ImpactUnknown = Impact(iota)
|
||||
)
|
||||
|
||||
func FormatImpact(pri Impact) (result string) {
|
||||
func (pri Impact) Format() (result string) {
|
||||
switch pri {
|
||||
case ImpactCritical:
|
||||
result = `I:CRITICAL`
|
||||
@@ -31,3 +31,24 @@ func FormatImpact(pri Impact) (result string) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func ParseImpact(pri string) (value Impact) {
|
||||
switch pri {
|
||||
case `I:CRITICAL`:
|
||||
value = ImpactCritical
|
||||
case `I:HIGH`:
|
||||
value = ImpactHigh
|
||||
case `I:LOW`:
|
||||
value = ImpactLow
|
||||
case `I:MIDDLE`:
|
||||
value = ImpactMiddle
|
||||
case `I:NONE`:
|
||||
value = ImpactNone
|
||||
case `I:UNKNOWN`:
|
||||
value = ImpactUnknown
|
||||
default:
|
||||
value = ImpactUnknown
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
+22
-1
@@ -11,7 +11,7 @@ const (
|
||||
LevelSECURITY = Level(iota)
|
||||
)
|
||||
|
||||
func FormatLevel(lvl Level) (result string) {
|
||||
func (lvl Level) Format() (result string) {
|
||||
switch lvl {
|
||||
case LevelDEBUG:
|
||||
result = `L:DEBUG`
|
||||
@@ -31,3 +31,24 @@ func FormatLevel(lvl Level) (result string) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func ParseLevel(lvl string) (value Level) {
|
||||
switch lvl {
|
||||
case `L:DEBUG`:
|
||||
value = LevelDEBUG
|
||||
case `L:ERROR`:
|
||||
value = LevelERROR
|
||||
case `L:INFO`:
|
||||
value = LevelINFO
|
||||
case `L:SECURITY`:
|
||||
value = LevelSECURITY
|
||||
case `L:TALKATIVE`:
|
||||
value = LevelTALKATIVE
|
||||
case `L:WARN`:
|
||||
value = LevelWARN
|
||||
default:
|
||||
value = LevelERROR
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
+22
-1
@@ -11,7 +11,7 @@ const (
|
||||
SeverityUnknown = Severity(iota)
|
||||
)
|
||||
|
||||
func FormatSeverity(pri Severity) (result string) {
|
||||
func (pri Severity) Format() (result string) {
|
||||
switch pri {
|
||||
case SeverityCritical:
|
||||
result = `S:CRITICAL`
|
||||
@@ -31,3 +31,24 @@ func FormatSeverity(pri Severity) (result string) {
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func ParseSeverity(pri string) (value Severity) {
|
||||
switch pri {
|
||||
case `S:CRITICAL`:
|
||||
value = SeverityCritical
|
||||
case `S:HIGH`:
|
||||
value = SeverityHigh
|
||||
case `S:LOW`:
|
||||
value = SeverityLow
|
||||
case `S:MIDDLE`:
|
||||
value = SeverityMiddle
|
||||
case `S:NONE`:
|
||||
value = SeverityNone
|
||||
case `S:UNKNOWN`:
|
||||
value = SeverityUnknown
|
||||
default:
|
||||
value = SeverityUnknown
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
Reference in new issue
Block a user