Skip to content

Commit

Permalink
Refactor position of helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Lekuruu committed Oct 10, 2024
1 parent f0d2c99 commit ace6338
Showing 1 changed file with 76 additions and 76 deletions.
152 changes: 76 additions & 76 deletions common/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,82 @@ func (c *Logger) GetName() string {
return c.name
}

func (c *Logger) Info(msg ...any) {
if c.level > INFO {
return
}

c.logger.Println(c.formatLogMessage("INFO", concatMessage(msg...)))
}

func (c *Logger) Infof(format string, msg ...any) {
if c.level > INFO {
return
}

c.logger.Println(c.formatLogMessage("INFO", fmt.Sprintf(format, msg...)))
}

func (c *Logger) Error(msg ...any) {
if c.level > ERROR {
return
}
c.logger.Println(c.formatLogMessage("ERROR", concatMessage(msg...)))
}

func (c *Logger) Errorf(format string, msg ...any) {
if c.level > ERROR {
return
}

c.logger.Println(c.formatLogMessage("ERROR", fmt.Sprintf(format, msg...)))
}

func (c *Logger) Warning(msg ...any) {
if c.level > WARNING {
return
}
c.logger.Println(c.formatLogMessage("WARNING", concatMessage(msg...)))
}

func (c *Logger) Warningf(format string, msg ...any) {
if c.level > WARNING {
return
}

c.logger.Println(c.formatLogMessage("WARNING", fmt.Sprintf(format, msg...)))
}

func (c *Logger) Debug(msg ...any) {
if c.level > DEBUG {
return
}
c.logger.Println(c.formatLogMessage("DEBUG", concatMessage(msg...)))
}

func (c *Logger) Debugf(format string, msg ...any) {
if c.level > DEBUG {
return
}

c.logger.Println(c.formatLogMessage("DEBUG", fmt.Sprintf(format, msg...)))
}

func (c *Logger) Verbose(msg ...any) {
if c.level > VERBOSE {
return
}
c.logger.Println(c.formatLogMessage("VERBOSE", concatMessage(msg...)))
}

func (c *Logger) Verbosef(format string, msg ...any) {
if c.level > VERBOSE {
return
}

c.logger.Println(c.formatLogMessage("VERBOSE", fmt.Sprintf(format, msg...)))
}

func (c *Logger) formatLogMessage(level string, msg string) string {
color := getColor(level)
timestamp := time.Now().Format("2006-01-02 15:04:05")
Expand Down Expand Up @@ -184,79 +260,3 @@ func FormatValue(v reflect.Value) string {
return fmt.Sprintf("%v", v.Interface())
}
}

func (c *Logger) Info(msg ...any) {
if c.level > INFO {
return
}

c.logger.Println(c.formatLogMessage("INFO", concatMessage(msg...)))
}

func (c *Logger) Infof(format string, msg ...any) {
if c.level > INFO {
return
}

c.logger.Println(c.formatLogMessage("INFO", fmt.Sprintf(format, msg...)))
}

func (c *Logger) Error(msg ...any) {
if c.level > ERROR {
return
}
c.logger.Println(c.formatLogMessage("ERROR", concatMessage(msg...)))
}

func (c *Logger) Errorf(format string, msg ...any) {
if c.level > ERROR {
return
}

c.logger.Println(c.formatLogMessage("ERROR", fmt.Sprintf(format, msg...)))
}

func (c *Logger) Warning(msg ...any) {
if c.level > WARNING {
return
}
c.logger.Println(c.formatLogMessage("WARNING", concatMessage(msg...)))
}

func (c *Logger) Warningf(format string, msg ...any) {
if c.level > WARNING {
return
}

c.logger.Println(c.formatLogMessage("WARNING", fmt.Sprintf(format, msg...)))
}

func (c *Logger) Debug(msg ...any) {
if c.level > DEBUG {
return
}
c.logger.Println(c.formatLogMessage("DEBUG", concatMessage(msg...)))
}

func (c *Logger) Debugf(format string, msg ...any) {
if c.level > DEBUG {
return
}

c.logger.Println(c.formatLogMessage("DEBUG", fmt.Sprintf(format, msg...)))
}

func (c *Logger) Verbose(msg ...any) {
if c.level > VERBOSE {
return
}
c.logger.Println(c.formatLogMessage("VERBOSE", concatMessage(msg...)))
}

func (c *Logger) Verbosef(format string, msg ...any) {
if c.level > VERBOSE {
return
}

c.logger.Println(c.formatLogMessage("VERBOSE", fmt.Sprintf(format, msg...)))
}

0 comments on commit ace6338

Please sign in to comment.