github.com/blend/go-sdk@v1.20220411.3/logger/background_errors.go (about) 1 /* 2 3 Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved 4 Use of this source code is governed by a MIT license that can be found in the LICENSE file. 5 6 */ 7 8 package logger 9 10 // BackgroundErrors reads errors from a channel and logs them as errors. 11 // 12 // You should call this method with it's own goroutine: 13 // 14 // go logger.BackgroundErrors(log, flushErrors) 15 func BackgroundErrors(log ErrorReceiver, errors <-chan error) { 16 if !IsLoggerSet(log) { 17 return 18 } 19 var err error 20 for { 21 err = <-errors 22 if err != nil { 23 log.Error(err) 24 } 25 } 26 }