Add documentation
This commit is contained in:
1 parent
69d0bdabf4
commit
6dab89a1d4
144 files changed
+1107
-549
No files matched your search
@@ -3,12 +3,13 @@ package Meta
|
||||
type Category byte
|
||||
|
||||
const (
|
||||
CategoryBUSINESS = Category(iota)
|
||||
CategorySYSTEM = Category(iota)
|
||||
CategoryAPP = Category(iota)
|
||||
CategoryUSER = Category(iota)
|
||||
CategoryBUSINESS = Category(iota) // Business category
|
||||
CategorySYSTEM = Category(iota) // System category
|
||||
CategoryAPP = Category(iota) // Application category
|
||||
CategoryUSER = Category(iota) // User category
|
||||
)
|
||||
|
||||
// Formats a category as string.
|
||||
func (cat Category) Format() (result string) {
|
||||
switch cat {
|
||||
case CategoryBUSINESS:
|
||||
@@ -26,6 +27,7 @@ func (cat Category) Format() (result string) {
|
||||
return
|
||||
}
|
||||
|
||||
// Parse a category from a string.
|
||||
func ParseCategory(cat string) (value Category) {
|
||||
switch cat {
|
||||
case `C:BUSINESS`:
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Type for a log entry.
|
||||
type Entry struct {
|
||||
Project string
|
||||
Time time.Time
|
||||
|
||||
+8
-2
@@ -7,18 +7,22 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Formats a log entry as string.
|
||||
func (entry Entry) Format() (result string) {
|
||||
|
||||
// Force the maximum length for a sender:
|
||||
lenSender := len(entry.Sender)
|
||||
if lenSender > 40 {
|
||||
lenSender = 40
|
||||
}
|
||||
|
||||
// Force the maximum length for the message name:
|
||||
lenMessageName := len(entry.MessageName)
|
||||
if lenMessageName > 26 {
|
||||
lenMessageName = 26
|
||||
}
|
||||
|
||||
// Force the maximum length for the project name:
|
||||
lenProject := len(entry.Project)
|
||||
if lenProject > 10 {
|
||||
lenProject = 10
|
||||
@@ -29,21 +33,23 @@ func (entry Entry) Format() (result string) {
|
||||
messageDescription = strings.Replace(messageDescription, "\t", ` `, -1)
|
||||
messageDescription = strings.Replace(messageDescription, "\r", ` `, -1)
|
||||
|
||||
// Format the basic fields of the log message:
|
||||
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)
|
||||
|
||||
// Formats the parameters:
|
||||
for _, param := range entry.Parameters {
|
||||
|
||||
paramText := param
|
||||
paramText = strings.Replace(paramText, "\n", ` `, -1)
|
||||
paramText = strings.Replace(paramText, "\t", ` `, -1)
|
||||
paramText = strings.Replace(paramText, "\r", ` `, -1)
|
||||
|
||||
result = fmt.Sprintf(`%s %s [■]`, result, paramText)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
// Formats the given time as YYYYMMdd HHmmss.fff! This function is necessary
|
||||
// to prevent a import cycle.
|
||||
func formatTime(t1 time.Time) (result string) {
|
||||
var year int = t1.Year()
|
||||
var month int = int(t1.Month())
|
||||
|
||||
+8
-6
@@ -3,14 +3,15 @@ package Meta
|
||||
type Impact byte
|
||||
|
||||
const (
|
||||
ImpactNone = Impact(iota)
|
||||
ImpactLow = Impact(iota)
|
||||
ImpactMiddle = Impact(iota)
|
||||
ImpactHigh = Impact(iota)
|
||||
ImpactCritical = Impact(iota)
|
||||
ImpactUnknown = Impact(iota)
|
||||
ImpactNone = Impact(iota) // None impact
|
||||
ImpactLow = Impact(iota) // Low impact
|
||||
ImpactMiddle = Impact(iota) // Middle impact
|
||||
ImpactHigh = Impact(iota) // High impact
|
||||
ImpactCritical = Impact(iota) // Critical impact
|
||||
ImpactUnknown = Impact(iota) // Unknown impact
|
||||
)
|
||||
|
||||
// Formats a impact as string.
|
||||
func (pri Impact) Format() (result string) {
|
||||
switch pri {
|
||||
case ImpactCritical:
|
||||
@@ -32,6 +33,7 @@ func (pri Impact) Format() (result string) {
|
||||
return
|
||||
}
|
||||
|
||||
// Parse a impact from a string.
|
||||
func ParseImpact(pri string) (value Impact) {
|
||||
switch pri {
|
||||
case `I:CRITICAL`:
|
||||
|
||||
+8
-6
@@ -3,14 +3,15 @@ package Meta
|
||||
type Level byte
|
||||
|
||||
const (
|
||||
LevelWARN = Level(iota)
|
||||
LevelDEBUG = Level(iota)
|
||||
LevelERROR = Level(iota)
|
||||
LevelINFO = Level(iota)
|
||||
LevelTALKATIVE = Level(iota)
|
||||
LevelSECURITY = Level(iota)
|
||||
LevelWARN = Level(iota) // Level: Warning
|
||||
LevelDEBUG = Level(iota) // Level: Debug
|
||||
LevelERROR = Level(iota) // Level: Error
|
||||
LevelINFO = Level(iota) // Level: Information
|
||||
LevelTALKATIVE = Level(iota) // Level: Talkative (even more events as debug)
|
||||
LevelSECURITY = Level(iota) // Level: Security
|
||||
)
|
||||
|
||||
// Formats a level as string.
|
||||
func (lvl Level) Format() (result string) {
|
||||
switch lvl {
|
||||
case LevelDEBUG:
|
||||
@@ -32,6 +33,7 @@ func (lvl Level) Format() (result string) {
|
||||
return
|
||||
}
|
||||
|
||||
// Parse a level from a string.
|
||||
func ParseLevel(lvl string) (value Level) {
|
||||
switch lvl {
|
||||
case `L:DEBUG`:
|
||||
|
||||
+33
-32
@@ -2,37 +2,38 @@ package Meta
|
||||
|
||||
type MessageName string
|
||||
|
||||
// Some pre-defined message names:
|
||||
const (
|
||||
MessageNameSTARTUP = `Startup`
|
||||
MessageNameINIT = `Init`
|
||||
MessageNameSHUTDOWN = `Shutdown`
|
||||
MessageNameEXECUTE = `Execute`
|
||||
MessageNameDATABASE = `Database`
|
||||
MessageNameNETWORK = `Network`
|
||||
MessageNameLOGIN = `Login`
|
||||
MessageNameLOGOUT = `Logout`
|
||||
MessageNameSESSION = `Session`
|
||||
MessageNameTIMEOUT = `Timeout`
|
||||
MessageNameFILESYSTEM = `Filesystem`
|
||||
MessageNameCOMMUNICATION = `Communication`
|
||||
MessageNameWRITE = `Write`
|
||||
MessageNameREAD = `Read`
|
||||
MessageNameALGORITHM = `Algorithm`
|
||||
MessageNameCONFIGURATION = `Configuration`
|
||||
MessageNameTIMER = `Timer`
|
||||
MessageNameINPUT = `Input`
|
||||
MessageNameOUTPUT = `Output`
|
||||
MessageNameBROWSER = `Browser`
|
||||
MessageNameSECURITY = `Security`
|
||||
MessageNameNOTFOUND = `NotFound`
|
||||
MessageNameANALYSIS = `Analysis`
|
||||
MessageNameSTATE = `State`
|
||||
MessageNameGENERATOR = `Generator`
|
||||
MessageNamePRODUCER = `Producer`
|
||||
MessageNameCONSUMER = `Consumer`
|
||||
MessageNamePASSWORD = `Password`
|
||||
MessageNamePARSE = `Parse`
|
||||
MessageNameUSER = `User`
|
||||
MessageNameREQUEST = `Request`
|
||||
MessageNameRESPONSE = `Response`
|
||||
MessageNameSTARTUP = `Startup` // e.g. the server startup
|
||||
MessageNameINIT = `Init` // some kind of init event
|
||||
MessageNameSHUTDOWN = `Shutdown` // some kind of shutdown event
|
||||
MessageNameEXECUTE = `Execute` // some kind of execution context
|
||||
MessageNameDATABASE = `Database` // events which are related to database issues
|
||||
MessageNameNETWORK = `Network` // events which are related to network issues
|
||||
MessageNameLOGIN = `Login` // some kind of login event
|
||||
MessageNameLOGOUT = `Logout` // some kind of logout event
|
||||
MessageNameSESSION = `Session` // some kind of session event
|
||||
MessageNameTIMEOUT = `Timeout` // some kind of timeout event
|
||||
MessageNameFILESYSTEM = `Filesystem` // events which are related to the filesystem
|
||||
MessageNameCOMMUNICATION = `Communication` // events which are related to communication issues
|
||||
MessageNameWRITE = `Write` // some kind of write event
|
||||
MessageNameREAD = `Read` // some kind of read event
|
||||
MessageNameALGORITHM = `Algorithm` // some kind of algorithm event
|
||||
MessageNameCONFIGURATION = `Configuration` // some kind of configuration event
|
||||
MessageNameTIMER = `Timer` // some kind of timer event
|
||||
MessageNameINPUT = `Input` // some kind of input event
|
||||
MessageNameOUTPUT = `Output` // some kind of output event
|
||||
MessageNameBROWSER = `Browser` // some kind of browser event
|
||||
MessageNameSECURITY = `Security` // some kind of security event
|
||||
MessageNameNOTFOUND = `NotFound` // something was not found
|
||||
MessageNameANALYSIS = `Analysis` // some kind of analysis event
|
||||
MessageNameSTATE = `State` // some kind of state-related event
|
||||
MessageNameGENERATOR = `Generator` // some kind of generator event
|
||||
MessageNamePRODUCER = `Producer` // some kind of producer event
|
||||
MessageNameCONSUMER = `Consumer` // some kind of consumer event
|
||||
MessageNamePASSWORD = `Password` // some kind of password event
|
||||
MessageNamePARSE = `Parse` // some kind of parser-related event
|
||||
MessageNameUSER = `User` // some kind of user event
|
||||
MessageNameREQUEST = `Request` // some kind of request-related event
|
||||
MessageNameRESPONSE = `Response` // some kind of response-related event
|
||||
)
|
||||
@@ -1,3 +1,4 @@
|
||||
package Meta
|
||||
|
||||
// Type for the sender name
|
||||
type Sender string
|
||||
@@ -3,14 +3,15 @@ package Meta
|
||||
type Severity byte
|
||||
|
||||
const (
|
||||
SeverityNone = Severity(iota)
|
||||
SeverityLow = Severity(iota)
|
||||
SeverityMiddle = Severity(iota)
|
||||
SeverityHigh = Severity(iota)
|
||||
SeverityCritical = Severity(iota)
|
||||
SeverityUnknown = Severity(iota)
|
||||
SeverityNone = Severity(iota) // None severity
|
||||
SeverityLow = Severity(iota) // Low severity
|
||||
SeverityMiddle = Severity(iota) // Middle severity
|
||||
SeverityHigh = Severity(iota) // High severity
|
||||
SeverityCritical = Severity(iota) // Critical severity
|
||||
SeverityUnknown = Severity(iota) // Unknown severity
|
||||
)
|
||||
|
||||
// Format the severity as string.
|
||||
func (pri Severity) Format() (result string) {
|
||||
switch pri {
|
||||
case SeverityCritical:
|
||||
@@ -32,6 +33,7 @@ func (pri Severity) Format() (result string) {
|
||||
return
|
||||
}
|
||||
|
||||
// Parse the severity from a string.
|
||||
func ParseSeverity(pri string) (value Severity) {
|
||||
switch pri {
|
||||
case `S:CRITICAL`:
|
||||
|
||||
Reference in new issue
Block a user