Skip to content

Commit b2fc776

Browse files
committed
Moved supressLogging to posix version only.
1 parent 62bfdb0 commit b2fc776

2 files changed

Lines changed: 15 additions & 16 deletions

File tree

pkg/pjrt/dynamiclib_base.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import (
3030
"slices"
3131
"strings"
3232
"sync"
33-
"syscall"
3433

3534
"github.com/pkg/errors"
3635
"k8s.io/klog/v2"
@@ -262,21 +261,6 @@ func checkPlugin(name, pluginPath string) (err error) {
262261
return
263262
}
264263

265-
func suppressLogging() (newFd int, err error) {
266-
newFd, err = syscall.Dup(2)
267-
if err != nil {
268-
err = errors.Wrap(err, "failed to duplicate (syscall.Dup) file descriptor 2 (stderr) in order to silence abseil logging")
269-
return
270-
}
271-
err = syscall.Close(2)
272-
if err != nil {
273-
klog.Errorf("failed to syscall.Close(2): %v", err)
274-
err = nil // Report, but continue.
275-
}
276-
os.Stderr = os.NewFile(uintptr(newFd), "stderr")
277-
return
278-
}
279-
280264
// FreeAll frees all plugins resources.
281265
// You should call this only if you are no longer going to use PJRT.
282266
// Useful for debugging memory leaks, this should release the plugins resources -- for these cases

pkg/pjrt/dynamiclib_posix.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,18 @@ func SuppressAbseilLoggingHack(fn func()) {
244244

245245
fn()
246246
}
247+
248+
func suppressLogging() (newFd int, err error) {
249+
newFd, err = syscall.Dup(2)
250+
if err != nil {
251+
err = errors.Wrap(err, "failed to duplicate (syscall.Dup) file descriptor 2 (stderr) in order to silence abseil logging")
252+
return
253+
}
254+
err = syscall.Close(2)
255+
if err != nil {
256+
klog.Errorf("failed to syscall.Close(2): %v", err)
257+
err = nil // Report, but continue.
258+
}
259+
os.Stderr = os.NewFile(uintptr(newFd), "stderr")
260+
return
261+
}

0 commit comments

Comments
 (0)