Skip to content

Commit

Permalink
Refine comments in parsesyslog.go code
Browse files Browse the repository at this point in the history
Enhanced the clarity and accuracy of method descriptions in the parsesyslog.go file. This includes detailing exact function purposes (such as for Register and New) and improving interface definitions (like Parser).
  • Loading branch information
wneessen committed Dec 14, 2023
1 parent 16b54c6 commit 239b20a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions parsesyslog.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var (
types = map[ParserType]func() (Parser, error){}
)

// Parser defines the interface for parsing different types of Syslog messages
// Parser is an interface for parsing log messages.
type Parser interface {
ParseReader(io.Reader) (LogMsg, error)
ParseString(s string) (LogMsg, error)
Expand All @@ -29,7 +29,8 @@ type Parser interface {
// ParserType is a type of parser for logs messages
type ParserType string

// Register does something
// Register registers a new ParserType with its corresponding
// Parser function.
func Register(t ParserType, fn func() (Parser, error)) {
lock.Lock()
defer lock.Unlock()
Expand All @@ -40,7 +41,13 @@ func Register(t ParserType, fn func() (Parser, error)) {
types[t] = fn
}

// New returns a new Parser based on the given parameter
// New returns a Parser of the specified ParserType and an error.
// It looks up the ParserType in the types map and if found,
// calls the corresponding Parser function to create a new Parser
// instance.
//
// If the ParserType is not found in the map, it returns nil
// and ErrParserTypeUnknown.
func New(t ParserType) (Parser, error) {
p, ok := types[t]
if !ok {
Expand Down

0 comments on commit 239b20a

Please sign in to comment.