Skip to content

Commit

Permalink
Correct log level
Browse files Browse the repository at this point in the history
Signed-off-by: Viet Anh Duong <[email protected]>
  • Loading branch information
vietanhduong committed Dec 30, 2023
1 parent 5144be0 commit 1bbda0b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion module.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func (m *Module) AttachXDP(ifname, prog string, flags uint64) error {
if err != nil {
return fmt.Errorf("net interface by name: %w", err)
}
log.Debugf("found interface %s at index: %d", i.Name, i.Index)
log.Tracef("Found interface %s at index: %d", i.Name, i.Index)

l, err := link.AttachXDP(link.XDPOptions{
Program: p,
Expand Down
2 changes: 1 addition & 1 deletion pkg/syms/kern_sym.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func (s *KernSym) Refresh() {
}
symbols, err := parseKallsyms(s.path)
if err != nil {
log.Warnf("KernSym refresh: failed to parse kallsym(path=%s): %v", s.path, err)
log.WithError(err).Warnf("KernSym refresh: failed to parse kallsym(path=%s)", s.path)
return
}
s.symbols = symbols
Expand Down
10 changes: 5 additions & 5 deletions pkg/syms/proc_module.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (m *ProcModule) load() {
if m.typ == SO || m.typ == EXEC {
mf, err := elf.NewMMapedElfFile(m.path.GetPath())
if err != nil {
log.Errorf("Failed to open mmaped file %s: %v", m.path.GetPath(), err)
log.WithError(err).Tracef("Failed to open mmaped file %s", m.path.GetPath())
return
}
defer mf.Close()
Expand All @@ -128,7 +128,7 @@ func (m *ProcModule) load() {
if debugfile := m.findDebugFile(mf); debugfile != "" {
debugmf, err := elf.NewMMapedElfFile(debugfile)
if err != nil {
log.Errorf("Failed to open mmaped debug file %s: %v", debugfile, err)
log.WithError(err).Tracef("Failed to open mmaped debug file %s", debugfile)
return
}
defer debugmf.Close()
Expand All @@ -144,7 +144,7 @@ func (m *ProcModule) load() {
var err error
m.table, err = buildVDSOResolver()
if err != nil {
log.Warnf("Failed to create vDSO resolver: %v", err)
log.WithError(err).Trace("Failed to create vDSO resolver")
}
}
}
Expand Down Expand Up @@ -203,10 +203,10 @@ func createSymbolTable(mf *elf.MMapedElfFile, opts *elf.SymbolOptions) SymbolTab

symtbl, err := mf.NewSymbolTable(opts)
if err != nil {
log.WithError(err).Debugf("Failed to create Symbol Table (ELF: %s)", mf.FilePath())
log.WithError(err).Tracef("Failed to create Symbol Table (ELF: %s)", mf.FilePath())
}
if symtbl == nil && gotbl == nil {
log.Errorf("No symbol resolver available for ELF file %s", mf.FilePath())
log.Warnf("No symbol resolver available for ELF file %s", mf.FilePath())
return &emptyTable{}
}
if gotbl != nil {
Expand Down
14 changes: 7 additions & 7 deletions pkg/syms/vdso.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func buildVDSOResolver() (SymbolTable, error) {
if err != nil {
return nil, fmt.Errorf("open mmaped filed %s: %w, image, err", vstatus.image, err)
}
log.Debugf("Loaded vDSO (image=%s)", vstatus.image)
log.Tracef("Loaded vDSO (image=%s)", vstatus.image)
return createSymbolTable(mf, &elf.SymbolOptions{
DemangleOpts: DemangleFull.ToOptions(),
}), nil
Expand Down Expand Up @@ -65,30 +65,30 @@ func buildVDSOImage(procmap *proc.Map, pid int) string {
procmem := proc.HostProcPath(fmt.Sprintf("%d/mem", pid))
mem, err := os.OpenFile(procmem, os.O_RDONLY, 0)
if err != nil {
log.Warnf("Build vDSO Image: Failed to open file %s: %v", procmem, err)
log.WithError(err).Tracef("Build vDSO Image: Failed to open file %s", procmem)
return ""
}
defer mem.Close()

if _, err = mem.Seek(int64(procmap.StartAddr), 0); err != nil {
log.Warnf("Build vDSO Image: Failed to seek to address: %v", err)
log.WithError(err).Tracef("Build vDSO Image: Failed to seek to address")
return ""
}

buf := make([]byte, size)
if _, err = mem.Read(buf); err != nil {
log.Warnf("Build vDSO Image: Failed read mem: %v", err)
log.WithError(err).Tracef("Build vDSO Image: Failed read mem")
return ""
}
tmpfile, err := os.CreateTemp("", fmt.Sprintf("wbpf_%d_vdso_image_*", pid))
if err != nil {
log.Warnf("Build vDSO Image: Failed to create vsdo temp file: %v", err)
log.WithError(err).Tracef("Build vDSO Image: Failed to create vsdo temp file")
return ""
}
defer tmpfile.Close()

if _, err = tmpfile.Write(buf); err != nil {
log.Errorf("failed to write to vDSO image: %v", err)
log.WithError(err).Trace("failed to write to vDSO image")
}
return tmpfile.Name()
}
Expand All @@ -97,7 +97,7 @@ func (s *vdsoStatus) Cleanup() {
if s == nil || s.image == "" {
return
}
log.Debugf("Remove vDSO image: %s", s.image)
log.Tracef("Remove vDSO image: %s", s.image)
os.Remove(s.image)
s.err = nil
}
4 changes: 2 additions & 2 deletions stack_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (t *StackTable) GetStackAddr(stackid int64, clear bool) []uint64 {

if clear {
if err := t.Delete(id); err != nil {
log.Tracef("Failed to delete key 0x%08x: %v", stackid, err)
log.WithError(err).Tracef("Failed to delete key 0x%08x", stackid)
return nil
}
}
Expand All @@ -58,7 +58,7 @@ func (t *StackTable) ClearStackId(stackid int64) {
return
}
if err := t.Delete(uint32(stackid)); err != nil {
log.Tracef("Failed to delete key 0x%08x: %v", stackid, err)
log.WithError(err).Tracef("Failed to delete key 0x%08x", stackid)
}
}

Expand Down

0 comments on commit 1bbda0b

Please sign in to comment.