Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
xjasonlyu committed Aug 21, 2024
1 parent a519874 commit aefc33c
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 361 deletions.
3 changes: 0 additions & 3 deletions common/observable/iterable.go

This file was deleted.

65 changes: 0 additions & 65 deletions common/observable/observable.go

This file was deleted.

148 changes: 0 additions & 148 deletions common/observable/observable_test.go

This file was deleted.

33 changes: 0 additions & 33 deletions common/observable/subscriber.go

This file was deleted.

39 changes: 0 additions & 39 deletions log/event.go

This file was deleted.

16 changes: 7 additions & 9 deletions log/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package log
import (
"io"
"os"
"time"

"github.com/sirupsen/logrus"
"go.uber.org/atomic"
Expand Down Expand Up @@ -45,19 +46,16 @@ func Fatalf(format string, args ...any) {
}

func logf(level Level, format string, args ...any) {
event := newEvent(level, format, args...)
if uint32(event.Level) > _defaultLevel.Load() {
return
}

switch level {
case DebugLevel:
logrus.WithTime(event.Time).Debugln(event.Message)
logrus.WithTime(time.Now()).Debugf(format, args...)
case InfoLevel:
logrus.WithTime(event.Time).Infoln(event.Message)
logrus.WithTime(time.Now()).Infof(format, args...)
case WarnLevel:
logrus.WithTime(event.Time).Warnln(event.Message)
logrus.WithTime(time.Now()).Warnf(format, args...)
case ErrorLevel:
logrus.WithTime(event.Time).Errorln(event.Message)
logrus.WithTime(time.Now()).Errorf(format, args...)
default:
// nop
}
}
2 changes: 1 addition & 1 deletion restapi/connections.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
const defaultInterval = 1000

func init() {
registerMountPoint("/connections", connectionRouter())
registerEndpoint("/connections", connectionRouter())
}

func connectionRouter() http.Handler {
Expand Down
2 changes: 1 addition & 1 deletion restapi/debug.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func init() {
registerMountPoint("/debug/pprof/", pprofRouter())
registerEndpoint("/debug/pprof/", pprofRouter())
}

func pprofRouter() http.Handler {
Expand Down
2 changes: 1 addition & 1 deletion restapi/netstats.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func SetStatsFunc(s func() tcpip.Stats) {
}

func init() {
registerMountPoint("/netstats", http.HandlerFunc(getNetStats))
registerEndpoint("/netstats", http.HandlerFunc(getNetStats))
}

func getNetStats(w http.ResponseWriter, r *http.Request) {
Expand Down
Loading

0 comments on commit aefc33c

Please sign in to comment.