Skip to content

Commit

Permalink
Added godoc for all publics
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Sklyar committed Nov 8, 2017
1 parent 57b8b70 commit 8b27d93
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apex/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import (
"github.com/teris-io/log"
)

// NewFactory creates a new log Factory instance for the implementation based
// on apex/log.
func NewFactory(root *alog.Logger) log.Factory {
return &factory{root: root, min: log.UnsetLevel}
}

// Use activates the logger implementation (based on apex/log) to be
// used for static logging via the log package static functions.
func Use(root *alog.Logger) log.Factory {
factory := NewFactory(root)
log.SetFactory(factory)
Expand Down
4 changes: 4 additions & 0 deletions std/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ import (
"github.com/teris-io/log"
)

// NewFactory creates a new log Factory instance for the implementation based
// on the Go standard log.
func NewFactory(std *stdlog.Logger, min log.LoggerLevel, fmt FmtFun) log.Factory {
return &factory{std: std, min: min, fmt: fmt}
}

// Use activates the logger implementation (based on the Go standard log) to be
// used for static logging via the log package static functions.
func Use(out io.Writer, min log.LoggerLevel, fmt FmtFun) {
std := stdlog.New(out, "", 0)
log.SetFactory(NewFactory(std, min, fmt))
Expand Down
2 changes: 2 additions & 0 deletions std/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import (
"github.com/teris-io/log"
)

// FmtFun defines the log formatter type for the logger implementation based on the Go standard log.
type FmtFun func(start time.Time, level log.LoggerLevel, msg string, fields []Field) string

// DefaultFmtFun defines the default formatter.
var DefaultFmtFun = func(start time.Time, lvl log.LoggerLevel, msg string, fields []Field) string {
timestr := color.CyanString(start.Format("02 15:04:05.000000"))
lvlstr := ""
Expand Down
1 change: 1 addition & 0 deletions std/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/teris-io/log"
)

// Field defines a name-value placeholder for field information passed to the formatter.
type Field struct {
Name string
Value interface{}
Expand Down

0 comments on commit 8b27d93

Please sign in to comment.