@@ -6,19 +6,19 @@ package process
66import (
77 "bufio"
88 "bytes"
9+ "context"
910 "encoding/json"
1011 "errors"
1112 "fmt"
1213 "io/ioutil"
14+ "log/slog"
1315 "os"
1416 "path/filepath"
1517 "strconv"
1618 "strings"
1719 "syscall"
1820 "time"
1921
20- log "github.com/cihub/seelog"
21-
2222 "github.com/DataDog/gopsutil/cpu"
2323 "github.com/DataDog/gopsutil/host"
2424 "github.com/DataDog/gopsutil/internal/common"
@@ -961,63 +961,63 @@ func AllProcesses() (map[int32]*FilledProcess, error) {
961961 for _ , pid := range pids {
962962 p , err := NewProcess (pid )
963963 if err != nil {
964- log . Debugf ("Unable to create new process %d , it may have gone away: %s" , pid , err )
964+ slog . Debug ("Unable to create new process, it may have gone away" , "pid" , pid , "error" , err )
965965 // Skip the rest of the processing because we have no real process.
966966 continue
967967 }
968968 cmdline , err := p .fillSliceFromCmdline ()
969969 if err != nil {
970- log . Debugf ("Unable to read process command line for %d: %s" , pid , err )
970+ slog . Debug ("Unable to read process command line" , "pid" , pid , "error" , err )
971971 cmdline = []string {}
972972 }
973973 if err := p .fillFromStatus (); err != nil {
974- log . Debugf ("Unable to fill from /proc/%d /status: %s" , pid , err )
974+ slog . Debug ("Unable to fill from /proc/PID /status" , "pid" , pid , "error" , err )
975975 }
976976 memInfo , memInfoEx , err := p .readFromStatm ()
977977 if err != nil {
978- log . Debugf ("Unable to fill from /proc/%d /statm: %s" , pid , err )
978+ slog . Debug ("Unable to fill from /proc/PID /statm" , "pid" , pid , "error" , err )
979979 memInfo = & MemoryInfoStat {}
980980 memInfoEx = & MemoryInfoExStat {}
981981 }
982982 ioStat , err := p .fillFromIO (user )
983983 if os .IsPermission (err ) {
984- log . Tracef ( "Unable to access /proc/%d /io, permission denied" , pid )
984+ slog . Log ( context . Background (), slog . LevelDebug - 4 , "Unable to access /proc/PID /io, permission denied" , "pid " , pid )
985985 // Without root permissions we can't read for other processes.
986986 ioStat = & IOCountersStat {}
987987 } else if err != nil {
988- log . Debugf ("Unable to access /proc/%d /io: %s" , pid , err )
988+ slog . Debug ("Unable to access /proc/PID /io" , "pid" , pid , "error" , err )
989989 ioStat = & IOCountersStat {}
990990 }
991991 ppid , _ , t1 , createTime , nice , err := p .fillFromStat ()
992992 if err != nil {
993- log . Debugf ("Unable to fill from /proc/%d /stat: %s" , pid , err )
993+ slog . Debug ("Unable to fill from /proc/PID /stat" , "pid" , pid , "error" , err )
994994 t1 = & cpu.TimesStat {}
995995 }
996996 cwd , err := p .fillFromCwd (user )
997997 if os .IsPermission (err ) {
998998
999- log . Tracef ( "Unable to access /proc/%d /cwd, permission denied" , pid )
999+ slog . Log ( context . Background (), slog . LevelDebug - 4 , "Unable to access /proc/PID /cwd, permission denied" , "pid " , pid )
10001000 cwd = ""
10011001 } else if err != nil {
1002- log . Debugf ("Unable to access /proc/%d /cwd: %s" , pid , err )
1002+ slog . Debug ("Unable to access /proc/PID /cwd" , "pid" , pid , "error" , err )
10031003 cwd = ""
10041004 }
10051005 exe , err := p .fillFromExe (user )
10061006 if os .IsPermission (err ) {
10071007 // Without root permissions we can't read for other processes.
1008- log . Tracef ( "Unable to access /proc/%d /exe, permission denied" , pid )
1008+ slog . Log ( context . Background (), slog . LevelDebug - 4 , "Unable to access /proc/PID /exe, permission denied" , "pid " , pid )
10091009 exe = ""
10101010 } else if err != nil {
1011- log . Debugf ("Unable to access /proc/%d /exe: %s" , pid , err )
1011+ slog . Debug ("Unable to access /proc/PID /exe" , "pid" , pid , "error" , err )
10121012 exe = ""
10131013 }
10141014 openFdCount := int32 (- 1 )
10151015 _ , fds , err := p .fillFromfdList (user )
10161016 if os .IsPermission (err ) {
10171017 // Without root permissions we can't read for other processes.
1018- log . Tracef ( "Unable to access /proc/%d /fd, permission denied" , pid )
1018+ slog . Log ( context . Background (), slog . LevelDebug - 4 , "Unable to access /proc/PID /fd, permission denied" , "pid " , pid )
10191019 } else if err != nil {
1020- log . Debugf ("Unable to access /proc/%d /fd: %s" , pid , err )
1020+ slog . Debug ("Unable to access /proc/PID /fd" , "pid" , pid , "error" , err )
10211021 } else {
10221022 openFdCount = int32 (len (fds ))
10231023 }
0 commit comments