netboot/pixiecore/logging.go
David Anderson 4aa8885728 pixiecore: rework logging to provide less verbose, more useful logs by default.
Also adds a debug channel with the full line noise.
2016-08-15 21:33:57 -07:00

42 lines
1.1 KiB
Go

// Copyright 2016 Google Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package pixiecore
import (
"encoding/base64"
"fmt"
)
func (s *Server) log(subsystem, format string, args ...interface{}) {
if s.Log == nil {
return
}
s.Log(subsystem, fmt.Sprintf(format, args...))
}
func (s *Server) debug(subsystem, format string, args ...interface{}) {
if s.Debug == nil {
return
}
s.Debug(subsystem, fmt.Sprintf(format, args...))
}
func (s *Server) debugPacket(subsystem string, layer int, packet []byte) {
if s.Debug == nil {
return
}
s.Debug(subsystem, fmt.Sprintf("PKT %d %s END", layer, base64.StdEncoding.EncodeToString(packet)))
}