Skip to content

consumer add support custom logger #293

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

Merged
merged 1 commit into from
Nov 25, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions consumer/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"net/http"

sls "github.com/aliyun/aliyun-log-go-sdk"
"github.com/go-kit/kit/log"
)

type LogHubConfig struct {
Expand Down Expand Up @@ -65,6 +66,7 @@ type LogHubConfig struct {
MaxFetchLogGroupCount int
CursorStartTime int64 // Unix time stamp; Units are seconds.
InOrder bool
Logger log.Logger
AllowLogLevel string
LogFileName string
IsJsonType bool
Expand Down
8 changes: 6 additions & 2 deletions consumer/worker.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package consumerLibrary

import (
"os"
"io"
"os"
"sync"
"time"

Expand Down Expand Up @@ -53,7 +53,11 @@ func InitConsumerWorkerWithCheckpointTracker(option LogHubConfig, do func(int, *
// InitConsumerWorkerWithProcessor
// you need save checkpoint by yourself and can do something after consumer shutdown
func InitConsumerWorkerWithProcessor(option LogHubConfig, processor Processor) *ConsumerWorker {
logger := logConfig(option)
logger := option.Logger
if logger == nil {
logger = logConfig(option)
}

consumerClient := initConsumerClient(option, logger)
consumerHeatBeat := initConsumerHeatBeat(consumerClient, logger)
consumerWorker := &ConsumerWorker{
Expand Down