diff --git a/channelutil/clone.go b/channelutil/clone.go index ca06bade..de6ddd59 100644 --- a/channelutil/clone.go +++ b/channelutil/clone.go @@ -2,9 +2,9 @@ package channelutil import ( "context" + "log" "sync" - "github.com/projectdiscovery/gologger" errorutil "github.com/projectdiscovery/utils/errors" ) @@ -18,6 +18,7 @@ type CloneOptions struct { type CloneChannels[T any] struct { // Options opts *CloneOptions + Log *log.Logger // Internal wg sync.WaitGroup @@ -125,11 +126,15 @@ func (s *CloneChannels[T]) cloneChanWorker(ctx context.Context, src chan T, sink s.wg.Done() }() if src == nil { - gologger.Error().Msgf("source channel is nil") + if s.Log != nil { + s.Log.Println("Error: source channel is nil") + } return } if len(sinkchans) != 5 { - gologger.Error().Msgf("expected total sinks 5 but got %v", len(sinkchans)) + if s.Log != nil { + s.Log.Printf("Error: expected total sinks 5 but got %v", len(sinkchans)) + } return } diff --git a/channelutil/join.go b/channelutil/join.go index 0dbaa429..4b970ea0 100644 --- a/channelutil/join.go +++ b/channelutil/join.go @@ -2,9 +2,9 @@ package channelutil import ( "context" + "log" "sync" - "github.com/projectdiscovery/gologger" errorutil "github.com/projectdiscovery/utils/errors" ) @@ -13,7 +13,8 @@ import ( // this is useful when you have multiple sources and you want to send data to one channel type JoinChannels[T any] struct { // internal - wg sync.WaitGroup + wg sync.WaitGroup + Log *log.Logger } // JoinChannels Joins Many Channels to Create One @@ -97,11 +98,16 @@ func (j *JoinChannels[T]) joinWorker(ctx context.Context, sink chan T, sources . j.wg.Done() }() if len(sources) != 5 { - gologger.Error().Msgf("worker only supports 5 sources got %v", len(sources)) + if j.Log != nil { + j.Log.Printf("Error: worker only supports 5 sources got %v", len(sources)) + } return } if sink == nil { - gologger.Error().Msgf("sink cannot be nil") + if j.Log != nil { + j.Log.Printf("Error: sink cannot be nil") + } + return } // recieve only channels