Files
loggerx/loggerc.go
T

43 lines
747 B
Go
Raw Normal View History

2024-04-21 12:23:26 +08:00
package loggerx
2024-05-28 09:30:57 +08:00
import (
"context"
"fmt"
)
2024-04-21 12:23:26 +08:00
var loggerc *Logger
func init() {
loggerc = NewLogger(context.Background())
}
func NewLoggerc(ctx context.Context, opts ...Option) {
for _, apply := range opts {
apply(&loggerc.option)
}
}
func Channel(ch string) (r *Logger) {
rr := *loggerc
rr.channel = ch
return &rr
}
func Info(ctx context.Context, v ...any) {
2024-05-28 09:30:57 +08:00
loggerc.logger(ctx, "info", v...)
2024-04-21 12:23:26 +08:00
}
func Infof(ctx context.Context, format string, v ...any) {
2024-05-28 09:30:57 +08:00
s := fmt.Sprintf(format, v...)
loggerc.logger(ctx, "info", s)
2024-04-21 12:23:26 +08:00
}
func Error(ctx context.Context, v ...any) {
2024-05-28 09:30:57 +08:00
loggerc.logger(ctx, "error", v...)
2024-04-21 12:23:26 +08:00
}
func Errorf(ctx context.Context, format string, v ...any) {
2024-05-28 09:30:57 +08:00
s := fmt.Sprintf(format, v...)
loggerc.logger(ctx, "error", s)
2024-04-21 12:23:26 +08:00
}