Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement customized server logger #343

Merged
merged 1 commit into from Jul 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 0 additions & 5 deletions core/client.go
Expand Up @@ -280,11 +280,6 @@ func (c *Client) Close() (err error) {
return err
}

// EnableDebug enables the development model for logging.
// func (c *Client) EnableDebug() {
// logger.EnableDebug()
// }

// WriteFrame writes a frame to the connection, gurantee threadsafe.
func (c *Client) WriteFrame(frm frame.Frame) error {
// write on QUIC stream
Expand Down
2 changes: 1 addition & 1 deletion core/log/logger.go
Expand Up @@ -24,7 +24,7 @@ type Logger interface {
SetLevel(Level)
// SetEncoding sets the logger's encoding
SetEncoding(encoding string)
// Printf logs a message wihout level
// Printf logs a message without level
Printf(template string, args ...interface{})
// Debugf logs a message at DebugLevel
Debugf(template string, args ...interface{})
Expand Down
12 changes: 11 additions & 1 deletion pkg/logger/logger.go
Expand Up @@ -7,9 +7,19 @@ import (
"github.com/yomorun/yomo/core/log"
)

var logger = Default(isEnableDebug())
var logger log.Logger

func init() {
logger = Default(isEnableDebug())
}

// SetLogger allows developers to customize the logger instance.
func SetLogger(l log.Logger) {
logger = l
}

// EnableDebug enables the development model for logging.
// Deprecated
func EnableDebug() {
logger = Default(true)
}
Expand Down