Merge pull request #11841 from runcom/11762-replace-aliased-logrus-imports

Replace aliased imports of logrus
This commit is contained in:
Brian Goff 2015-03-26 16:49:01 -07:00
commit bf8dd1f603
15 changed files with 80 additions and 80 deletions

View file

@ -18,7 +18,7 @@ import (
"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar" "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/fileutils" "github.com/docker/docker/pkg/fileutils"
"github.com/docker/docker/pkg/pools" "github.com/docker/docker/pkg/pools"
"github.com/docker/docker/pkg/promise" "github.com/docker/docker/pkg/promise"
@ -78,7 +78,7 @@ func DetectCompression(source []byte) Compression {
Xz: {0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00}, Xz: {0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00},
} { } {
if len(source) < len(m) { if len(source) < len(m) {
log.Debugf("Len too short") logrus.Debugf("Len too short")
continue continue
} }
if bytes.Compare(m, source[:len(m)]) == 0 { if bytes.Compare(m, source[:len(m)]) == 0 {
@ -331,7 +331,7 @@ func createTarFile(path, extractDir string, hdr *tar.Header, reader io.Reader, L
} }
case tar.TypeXGlobalHeader: case tar.TypeXGlobalHeader:
log.Debugf("PAX Global Extended Headers found and ignored") logrus.Debugf("PAX Global Extended Headers found and ignored")
return nil return nil
default: default:
@ -426,7 +426,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
for _, include := range options.IncludeFiles { for _, include := range options.IncludeFiles {
filepath.Walk(filepath.Join(srcPath, include), func(filePath string, f os.FileInfo, err error) error { filepath.Walk(filepath.Join(srcPath, include), func(filePath string, f os.FileInfo, err error) error {
if err != nil { if err != nil {
log.Debugf("Tar: Can't stat file %s to tar: %s", srcPath, err) logrus.Debugf("Tar: Can't stat file %s to tar: %s", srcPath, err)
return nil return nil
} }
@ -447,7 +447,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
if include != relFilePath { if include != relFilePath {
skip, err = fileutils.Matches(relFilePath, options.ExcludePatterns) skip, err = fileutils.Matches(relFilePath, options.ExcludePatterns)
if err != nil { if err != nil {
log.Debugf("Error matching %s", relFilePath, err) logrus.Debugf("Error matching %s", relFilePath, err)
return err return err
} }
} }
@ -474,7 +474,7 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
} }
if err := ta.addTarFile(filePath, relFilePath); err != nil { if err := ta.addTarFile(filePath, relFilePath); err != nil {
log.Debugf("Can't add file %s to tar: %s", filePath, err) logrus.Debugf("Can't add file %s to tar: %s", filePath, err)
} }
return nil return nil
}) })
@ -482,13 +482,13 @@ func TarWithOptions(srcPath string, options *TarOptions) (io.ReadCloser, error)
// Make sure to check the error on Close. // Make sure to check the error on Close.
if err := ta.TarWriter.Close(); err != nil { if err := ta.TarWriter.Close(); err != nil {
log.Debugf("Can't close tar writer: %s", err) logrus.Debugf("Can't close tar writer: %s", err)
} }
if err := compressWriter.Close(); err != nil { if err := compressWriter.Close(); err != nil {
log.Debugf("Can't close compress writer: %s", err) logrus.Debugf("Can't close compress writer: %s", err)
} }
if err := pipeWriter.Close(); err != nil { if err := pipeWriter.Close(); err != nil {
log.Debugf("Can't close pipe writer: %s", err) logrus.Debugf("Can't close pipe writer: %s", err)
} }
}() }()
@ -606,7 +606,7 @@ func Untar(archive io.Reader, dest string, options *TarOptions) error {
} }
func (archiver *Archiver) TarUntar(src, dst string) error { func (archiver *Archiver) TarUntar(src, dst string) error {
log.Debugf("TarUntar(%s %s)", src, dst) logrus.Debugf("TarUntar(%s %s)", src, dst)
archive, err := TarWithOptions(src, &TarOptions{Compression: Uncompressed}) archive, err := TarWithOptions(src, &TarOptions{Compression: Uncompressed})
if err != nil { if err != nil {
return err return err
@ -648,11 +648,11 @@ func (archiver *Archiver) CopyWithTar(src, dst string) error {
return archiver.CopyFileWithTar(src, dst) return archiver.CopyFileWithTar(src, dst)
} }
// Create dst, copy src's content into it // Create dst, copy src's content into it
log.Debugf("Creating dest directory: %s", dst) logrus.Debugf("Creating dest directory: %s", dst)
if err := os.MkdirAll(dst, 0755); err != nil && !os.IsExist(err) { if err := os.MkdirAll(dst, 0755); err != nil && !os.IsExist(err) {
return err return err
} }
log.Debugf("Calling TarUntar(%s, %s)", src, dst) logrus.Debugf("Calling TarUntar(%s, %s)", src, dst)
return archiver.TarUntar(src, dst) return archiver.TarUntar(src, dst)
} }
@ -665,7 +665,7 @@ func CopyWithTar(src, dst string) error {
} }
func (archiver *Archiver) CopyFileWithTar(src, dst string) (err error) { func (archiver *Archiver) CopyFileWithTar(src, dst string) (err error) {
log.Debugf("CopyFileWithTar(%s, %s)", src, dst) logrus.Debugf("CopyFileWithTar(%s, %s)", src, dst)
srcSt, err := os.Stat(src) srcSt, err := os.Stat(src)
if err != nil { if err != nil {
return err return err

View file

@ -13,7 +13,7 @@ import (
"github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar" "github.com/docker/docker/vendor/src/code.google.com/p/go/src/pkg/archive/tar"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/pools" "github.com/docker/docker/pkg/pools"
"github.com/docker/docker/pkg/system" "github.com/docker/docker/pkg/system"
) )
@ -401,22 +401,22 @@ func ExportChanges(dir string, changes []Change) (Archive, error) {
ChangeTime: timestamp, ChangeTime: timestamp,
} }
if err := ta.TarWriter.WriteHeader(hdr); err != nil { if err := ta.TarWriter.WriteHeader(hdr); err != nil {
log.Debugf("Can't write whiteout header: %s", err) logrus.Debugf("Can't write whiteout header: %s", err)
} }
} else { } else {
path := filepath.Join(dir, change.Path) path := filepath.Join(dir, change.Path)
if err := ta.addTarFile(path, change.Path[1:]); err != nil { if err := ta.addTarFile(path, change.Path[1:]); err != nil {
log.Debugf("Can't add file %s to tar: %s", path, err) logrus.Debugf("Can't add file %s to tar: %s", path, err)
} }
} }
} }
// Make sure to check the error on Close. // Make sure to check the error on Close.
if err := ta.TarWriter.Close(); err != nil { if err := ta.TarWriter.Close(); err != nil {
log.Debugf("Can't close layer: %s", err) logrus.Debugf("Can't close layer: %s", err)
} }
if err := writer.Close(); err != nil { if err := writer.Close(); err != nil {
log.Debugf("failed close Changes writer: %s", err) logrus.Debugf("failed close Changes writer: %s", err)
} }
}() }()
return reader, nil return reader, nil

View file

@ -6,7 +6,7 @@ import (
"sync" "sync"
"time" "time"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/jsonlog" "github.com/docker/docker/pkg/jsonlog"
) )
@ -61,7 +61,7 @@ func (w *BroadcastWriter) Write(p []byte) (n int, err error) {
jsonLog := jsonlog.JSONLog{Log: line, Stream: stream, Created: created} jsonLog := jsonlog.JSONLog{Log: line, Stream: stream, Created: created}
err = jsonLog.MarshalJSONBuf(w.jsLogBuf) err = jsonLog.MarshalJSONBuf(w.jsLogBuf)
if err != nil { if err != nil {
log.Errorf("Error making JSON log line: %s", err) logrus.Errorf("Error making JSON log line: %s", err)
continue continue
} }
w.jsLogBuf.WriteByte('\n') w.jsLogBuf.WriteByte('\n')

View file

@ -7,7 +7,7 @@ import (
"os" "os"
"syscall" "syscall"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
) )
func stringToLoopName(src string) [LoNameSize]uint8 { func stringToLoopName(src string) [LoNameSize]uint8 {
@ -39,20 +39,20 @@ func openNextAvailableLoopback(index int, sparseFile *os.File) (loopFile *os.Fil
fi, err := os.Stat(target) fi, err := os.Stat(target)
if err != nil { if err != nil {
if os.IsNotExist(err) { if os.IsNotExist(err) {
log.Errorf("There are no more loopback devices available.") logrus.Errorf("There are no more loopback devices available.")
} }
return nil, ErrAttachLoopbackDevice return nil, ErrAttachLoopbackDevice
} }
if fi.Mode()&os.ModeDevice != os.ModeDevice { if fi.Mode()&os.ModeDevice != os.ModeDevice {
log.Errorf("Loopback device %s is not a block device.", target) logrus.Errorf("Loopback device %s is not a block device.", target)
continue continue
} }
// OpenFile adds O_CLOEXEC // OpenFile adds O_CLOEXEC
loopFile, err = os.OpenFile(target, os.O_RDWR, 0644) loopFile, err = os.OpenFile(target, os.O_RDWR, 0644)
if err != nil { if err != nil {
log.Errorf("Error opening loopback device: %s", err) logrus.Errorf("Error opening loopback device: %s", err)
return nil, ErrAttachLoopbackDevice return nil, ErrAttachLoopbackDevice
} }
@ -62,7 +62,7 @@ func openNextAvailableLoopback(index int, sparseFile *os.File) (loopFile *os.Fil
// If the error is EBUSY, then try the next loopback // If the error is EBUSY, then try the next loopback
if err != syscall.EBUSY { if err != syscall.EBUSY {
log.Errorf("Cannot set up loopback device %s: %s", target, err) logrus.Errorf("Cannot set up loopback device %s: %s", target, err)
return nil, ErrAttachLoopbackDevice return nil, ErrAttachLoopbackDevice
} }
@ -75,7 +75,7 @@ func openNextAvailableLoopback(index int, sparseFile *os.File) (loopFile *os.Fil
// This can't happen, but let's be sure // This can't happen, but let's be sure
if loopFile == nil { if loopFile == nil {
log.Errorf("Unreachable code reached! Error attaching %s to a loopback device.", sparseFile.Name()) logrus.Errorf("Unreachable code reached! Error attaching %s to a loopback device.", sparseFile.Name())
return nil, ErrAttachLoopbackDevice return nil, ErrAttachLoopbackDevice
} }
@ -91,13 +91,13 @@ func AttachLoopDevice(sparseName string) (loop *os.File, err error) {
// loopback from index 0. // loopback from index 0.
startIndex, err := getNextFreeLoopbackIndex() startIndex, err := getNextFreeLoopbackIndex()
if err != nil { if err != nil {
log.Debugf("Error retrieving the next available loopback: %s", err) logrus.Debugf("Error retrieving the next available loopback: %s", err)
} }
// OpenFile adds O_CLOEXEC // OpenFile adds O_CLOEXEC
sparseFile, err := os.OpenFile(sparseName, os.O_RDWR, 0644) sparseFile, err := os.OpenFile(sparseName, os.O_RDWR, 0644)
if err != nil { if err != nil {
log.Errorf("Error opening sparse file %s: %s", sparseName, err) logrus.Errorf("Error opening sparse file %s: %s", sparseName, err)
return nil, ErrAttachLoopbackDevice return nil, ErrAttachLoopbackDevice
} }
defer sparseFile.Close() defer sparseFile.Close()
@ -115,11 +115,11 @@ func AttachLoopDevice(sparseName string) (loop *os.File, err error) {
} }
if err := ioctlLoopSetStatus64(loopFile.Fd(), loopInfo); err != nil { if err := ioctlLoopSetStatus64(loopFile.Fd(), loopInfo); err != nil {
log.Errorf("Cannot set up loopback device info: %s", err) logrus.Errorf("Cannot set up loopback device info: %s", err)
// If the call failed, then free the loopback device // If the call failed, then free the loopback device
if err := ioctlLoopClrFd(loopFile.Fd()); err != nil { if err := ioctlLoopClrFd(loopFile.Fd()); err != nil {
log.Errorf("Error while cleaning up the loopback device") logrus.Errorf("Error while cleaning up the loopback device")
} }
loopFile.Close() loopFile.Close()
return nil, ErrAttachLoopbackDevice return nil, ErrAttachLoopbackDevice

View file

@ -9,7 +9,7 @@ import (
"runtime" "runtime"
"syscall" "syscall"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
) )
type DevmapperLogger interface { type DevmapperLogger interface {
@ -237,7 +237,7 @@ func (t *Task) GetNextTarget(next uintptr) (nextPtr uintptr, start uint64,
func getLoopbackBackingFile(file *os.File) (uint64, uint64, error) { func getLoopbackBackingFile(file *os.File) (uint64, uint64, error) {
loopInfo, err := ioctlLoopGetStatus64(file.Fd()) loopInfo, err := ioctlLoopGetStatus64(file.Fd())
if err != nil { if err != nil {
log.Errorf("Error get loopback backing file: %s", err) logrus.Errorf("Error get loopback backing file: %s", err)
return 0, 0, ErrGetLoopbackBackingFile return 0, 0, ErrGetLoopbackBackingFile
} }
return loopInfo.loDevice, loopInfo.loInode, nil return loopInfo.loDevice, loopInfo.loInode, nil
@ -245,7 +245,7 @@ func getLoopbackBackingFile(file *os.File) (uint64, uint64, error) {
func LoopbackSetCapacity(file *os.File) error { func LoopbackSetCapacity(file *os.File) error {
if err := ioctlLoopSetCapacity(file.Fd(), 0); err != nil { if err := ioctlLoopSetCapacity(file.Fd(), 0); err != nil {
log.Errorf("Error loopbackSetCapacity: %s", err) logrus.Errorf("Error loopbackSetCapacity: %s", err)
return ErrLoopbackSetCapacity return ErrLoopbackSetCapacity
} }
return nil return nil
@ -285,7 +285,7 @@ func FindLoopDeviceFor(file *os.File) *os.File {
func UdevWait(cookie uint) error { func UdevWait(cookie uint) error {
if res := DmUdevWait(cookie); res != 1 { if res := DmUdevWait(cookie); res != 1 {
log.Debugf("Failed to wait on udev cookie %d", cookie) logrus.Debugf("Failed to wait on udev cookie %d", cookie)
return ErrUdevWait return ErrUdevWait
} }
return nil return nil
@ -305,7 +305,7 @@ func LogInit(logger DevmapperLogger) {
func SetDevDir(dir string) error { func SetDevDir(dir string) error {
if res := DmSetDevDir(dir); res != 1 { if res := DmSetDevDir(dir); res != 1 {
log.Debugf("Error dm_set_dev_dir") logrus.Debugf("Error dm_set_dev_dir")
return ErrSetDevDir return ErrSetDevDir
} }
return nil return nil
@ -348,8 +348,8 @@ func CookieSupported() bool {
// Useful helper for cleanup // Useful helper for cleanup
func RemoveDevice(name string) error { func RemoveDevice(name string) error {
log.Debugf("[devmapper] RemoveDevice START(%s)", name) logrus.Debugf("[devmapper] RemoveDevice START(%s)", name)
defer log.Debugf("[devmapper] RemoveDevice END(%s)", name) defer logrus.Debugf("[devmapper] RemoveDevice END(%s)", name)
task, err := TaskCreateNamed(DeviceRemove, name) task, err := TaskCreateNamed(DeviceRemove, name)
if task == nil { if task == nil {
return err return err
@ -375,7 +375,7 @@ func RemoveDevice(name string) error {
func GetBlockDeviceSize(file *os.File) (uint64, error) { func GetBlockDeviceSize(file *os.File) (uint64, error) {
size, err := ioctlBlkGetSize64(file.Fd()) size, err := ioctlBlkGetSize64(file.Fd())
if err != nil { if err != nil {
log.Errorf("Error getblockdevicesize: %s", err) logrus.Errorf("Error getblockdevicesize: %s", err)
return 0, ErrGetBlockSize return 0, ErrGetBlockSize
} }
return uint64(size), nil return uint64(size), nil
@ -494,21 +494,21 @@ func GetDriverVersion() (string, error) {
func GetStatus(name string) (uint64, uint64, string, string, error) { func GetStatus(name string) (uint64, uint64, string, string, error) {
task, err := TaskCreateNamed(DeviceStatus, name) task, err := TaskCreateNamed(DeviceStatus, name)
if task == nil { if task == nil {
log.Debugf("GetStatus: Error TaskCreateNamed: %s", err) logrus.Debugf("GetStatus: Error TaskCreateNamed: %s", err)
return 0, 0, "", "", err return 0, 0, "", "", err
} }
if err := task.Run(); err != nil { if err := task.Run(); err != nil {
log.Debugf("GetStatus: Error Run: %s", err) logrus.Debugf("GetStatus: Error Run: %s", err)
return 0, 0, "", "", err return 0, 0, "", "", err
} }
devinfo, err := task.GetInfo() devinfo, err := task.GetInfo()
if err != nil { if err != nil {
log.Debugf("GetStatus: Error GetInfo: %s", err) logrus.Debugf("GetStatus: Error GetInfo: %s", err)
return 0, 0, "", "", err return 0, 0, "", "", err
} }
if devinfo.Exists == 0 { if devinfo.Exists == 0 {
log.Debugf("GetStatus: Non existing device %s", name) logrus.Debugf("GetStatus: Non existing device %s", name)
return 0, 0, "", "", fmt.Errorf("Non existing device %s", name) return 0, 0, "", "", fmt.Errorf("Non existing device %s", name)
} }
@ -567,7 +567,7 @@ func ResumeDevice(name string) error {
} }
func CreateDevice(poolName string, deviceId int) error { func CreateDevice(poolName string, deviceId int) error {
log.Debugf("[devmapper] CreateDevice(poolName=%v, deviceId=%v)", poolName, deviceId) logrus.Debugf("[devmapper] CreateDevice(poolName=%v, deviceId=%v)", poolName, deviceId)
task, err := TaskCreateNamed(DeviceTargetMsg, poolName) task, err := TaskCreateNamed(DeviceTargetMsg, poolName)
if task == nil { if task == nil {
return err return err

View file

@ -1,7 +1,7 @@
package fileutils package fileutils
import ( import (
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"path/filepath" "path/filepath"
) )
@ -10,15 +10,15 @@ func Matches(relFilePath string, patterns []string) (bool, error) {
for _, exclude := range patterns { for _, exclude := range patterns {
matched, err := filepath.Match(exclude, relFilePath) matched, err := filepath.Match(exclude, relFilePath)
if err != nil { if err != nil {
log.Errorf("Error matching: %s (pattern: %s)", relFilePath, exclude) logrus.Errorf("Error matching: %s (pattern: %s)", relFilePath, exclude)
return false, err return false, err
} }
if matched { if matched {
if filepath.Clean(relFilePath) == "." { if filepath.Clean(relFilePath) == "." {
log.Errorf("Can't exclude whole path, excluding pattern: %s", exclude) logrus.Errorf("Can't exclude whole path, excluding pattern: %s", exclude)
continue continue
} }
log.Debugf("Skipping excluded path: %s", relFilePath) logrus.Debugf("Skipping excluded path: %s", relFilePath)
return true, nil return true, nil
} }
} }

View file

@ -6,7 +6,7 @@ import (
"net/http" "net/http"
"time" "time"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
) )
type resumableRequestReader struct { type resumableRequestReader struct {
@ -72,7 +72,7 @@ func (r *resumableRequestReader) Read(p []byte) (n int, err error) {
r.cleanUpResponse() r.cleanUpResponse()
} }
if err != nil && err != io.EOF { if err != nil && err != io.EOF {
log.Infof("encountered error during pull and clearing it before resume: %s", err) logrus.Infof("encountered error during pull and clearing it before resume: %s", err)
err = nil err = nil
} }
return n, err return n, err

View file

@ -9,7 +9,7 @@ import (
"strconv" "strconv"
"strings" "strings"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
) )
type Action string type Action string
@ -283,7 +283,7 @@ func Raw(args ...string) ([]byte, error) {
args = append([]string{"--wait"}, args...) args = append([]string{"--wait"}, args...)
} }
log.Debugf("%s, %v", iptablesPath, args) logrus.Debugf("%s, %v", iptablesPath, args)
output, err := exec.Command(iptablesPath, args...).CombinedOutput() output, err := exec.Command(iptablesPath, args...).CombinedOutput()
if err != nil { if err != nil {

View file

@ -6,7 +6,7 @@ import (
"io" "io"
"time" "time"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
) )
type JSONLog struct { type JSONLog struct {
@ -39,7 +39,7 @@ func WriteLog(src io.Reader, dst io.Writer, format string) error {
if err := dec.Decode(l); err == io.EOF { if err := dec.Decode(l); err == io.EOF {
return nil return nil
} else if err != nil { } else if err != nil {
log.Printf("Error streaming logs: %s", err) logrus.Printf("Error streaming logs: %s", err)
return err return err
} }
line, err := l.Format(format) line, err := l.Format(format)

View file

@ -5,7 +5,7 @@ import (
"net" "net"
"syscall" "syscall"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
) )
type TCPProxy struct { type TCPProxy struct {
@ -31,7 +31,7 @@ func NewTCPProxy(frontendAddr, backendAddr *net.TCPAddr) (*TCPProxy, error) {
func (proxy *TCPProxy) clientLoop(client *net.TCPConn, quit chan bool) { func (proxy *TCPProxy) clientLoop(client *net.TCPConn, quit chan bool) {
backend, err := net.DialTCP("tcp", nil, proxy.backendAddr) backend, err := net.DialTCP("tcp", nil, proxy.backendAddr)
if err != nil { if err != nil {
log.Printf("Can't forward traffic to backend tcp/%v: %s\n", proxy.backendAddr, err) logrus.Printf("Can't forward traffic to backend tcp/%v: %s\n", proxy.backendAddr, err)
client.Close() client.Close()
return return
} }
@ -78,7 +78,7 @@ func (proxy *TCPProxy) Run() {
for { for {
client, err := proxy.listener.Accept() client, err := proxy.listener.Accept()
if err != nil { if err != nil {
log.Printf("Stopping proxy on tcp/%v for tcp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err) logrus.Printf("Stopping proxy on tcp/%v for tcp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err)
return return
} }
go proxy.clientLoop(client.(*net.TCPConn), quit) go proxy.clientLoop(client.(*net.TCPConn), quit)

View file

@ -8,7 +8,7 @@ import (
"syscall" "syscall"
"time" "time"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
) )
const ( const (
@ -105,7 +105,7 @@ func (proxy *UDPProxy) Run() {
// ECONNREFUSED like Read do (see comment in // ECONNREFUSED like Read do (see comment in
// UDPProxy.replyLoop) // UDPProxy.replyLoop)
if !isClosedError(err) { if !isClosedError(err) {
log.Printf("Stopping proxy on udp/%v for udp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err) logrus.Printf("Stopping proxy on udp/%v for udp/%v (%s)", proxy.frontendAddr, proxy.backendAddr, err)
} }
break break
} }
@ -116,7 +116,7 @@ func (proxy *UDPProxy) Run() {
if !hit { if !hit {
proxyConn, err = net.DialUDP("udp", nil, proxy.backendAddr) proxyConn, err = net.DialUDP("udp", nil, proxy.backendAddr)
if err != nil { if err != nil {
log.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err) logrus.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err)
proxy.connTrackLock.Unlock() proxy.connTrackLock.Unlock()
continue continue
} }
@ -127,7 +127,7 @@ func (proxy *UDPProxy) Run() {
for i := 0; i != read; { for i := 0; i != read; {
written, err := proxyConn.Write(readBuf[i:read]) written, err := proxyConn.Write(readBuf[i:read])
if err != nil { if err != nil {
log.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err) logrus.Printf("Can't proxy a datagram to udp/%s: %s\n", proxy.backendAddr, err)
break break
} }
i += written i += written

View file

@ -8,7 +8,7 @@ import (
"strings" "strings"
"sync" "sync"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/docker/utils" "github.com/docker/docker/utils"
) )
@ -99,10 +99,10 @@ func FilterResolvDns(resolvConf []byte, ipv6Enabled bool) ([]byte, bool) {
// if the resulting resolvConf has no more nameservers defined, add appropriate // if the resulting resolvConf has no more nameservers defined, add appropriate
// default DNS servers for IPv4 and (optionally) IPv6 // default DNS servers for IPv4 and (optionally) IPv6
if len(GetNameservers(cleanedResolvConf)) == 0 { if len(GetNameservers(cleanedResolvConf)) == 0 {
log.Infof("No non-localhost DNS nameservers are left in resolv.conf. Using default external servers : %v", defaultIPv4Dns) logrus.Infof("No non-localhost DNS nameservers are left in resolv.conf. Using default external servers : %v", defaultIPv4Dns)
dns := defaultIPv4Dns dns := defaultIPv4Dns
if ipv6Enabled { if ipv6Enabled {
log.Infof("IPv6 enabled; Adding default IPv6 external servers : %v", defaultIPv6Dns) logrus.Infof("IPv6 enabled; Adding default IPv6 external servers : %v", defaultIPv6Dns)
dns = append(dns, defaultIPv6Dns...) dns = append(dns, defaultIPv6Dns...)
} }
cleanedResolvConf = append(cleanedResolvConf, []byte("\n"+strings.Join(dns, "\n"))...) cleanedResolvConf = append(cleanedResolvConf, []byte("\n"+strings.Join(dns, "\n"))...)

View file

@ -6,7 +6,7 @@ import (
"sync/atomic" "sync/atomic"
"syscall" "syscall"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
) )
// Trap sets up a simplified signal "trap", appropriate for common // Trap sets up a simplified signal "trap", appropriate for common
@ -29,7 +29,7 @@ func Trap(cleanup func()) {
interruptCount := uint32(0) interruptCount := uint32(0)
for sig := range c { for sig := range c {
go func(sig os.Signal) { go func(sig os.Signal) {
log.Infof("Received signal '%v', starting shutdown of docker...", sig) logrus.Infof("Received signal '%v', starting shutdown of docker...", sig)
switch sig { switch sig {
case os.Interrupt, syscall.SIGTERM: case os.Interrupt, syscall.SIGTERM:
// If the user really wants to interrupt, let him do so. // If the user really wants to interrupt, let him do so.
@ -43,7 +43,7 @@ func Trap(cleanup func()) {
return return
} }
} else { } else {
log.Infof("Force shutdown of docker, interrupting cleanup") logrus.Infof("Force shutdown of docker, interrupting cleanup")
} }
case syscall.SIGQUIT: case syscall.SIGQUIT:
} }

View file

@ -5,7 +5,7 @@ import (
"errors" "errors"
"io" "io"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
) )
const ( const (
@ -95,13 +95,13 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
nr += nr2 nr += nr2
if er == io.EOF { if er == io.EOF {
if nr < StdWriterPrefixLen { if nr < StdWriterPrefixLen {
log.Debugf("Corrupted prefix: %v", buf[:nr]) logrus.Debugf("Corrupted prefix: %v", buf[:nr])
return written, nil return written, nil
} }
break break
} }
if er != nil { if er != nil {
log.Debugf("Error reading header: %s", er) logrus.Debugf("Error reading header: %s", er)
return 0, er return 0, er
} }
} }
@ -117,18 +117,18 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
// Write on stderr // Write on stderr
out = dsterr out = dsterr
default: default:
log.Debugf("Error selecting output fd: (%d)", buf[StdWriterFdIndex]) logrus.Debugf("Error selecting output fd: (%d)", buf[StdWriterFdIndex])
return 0, ErrInvalidStdHeader return 0, ErrInvalidStdHeader
} }
// Retrieve the size of the frame // Retrieve the size of the frame
frameSize = int(binary.BigEndian.Uint32(buf[StdWriterSizeIndex : StdWriterSizeIndex+4])) frameSize = int(binary.BigEndian.Uint32(buf[StdWriterSizeIndex : StdWriterSizeIndex+4]))
log.Debugf("framesize: %d", frameSize) logrus.Debugf("framesize: %d", frameSize)
// Check if the buffer is big enough to read the frame. // Check if the buffer is big enough to read the frame.
// Extend it if necessary. // Extend it if necessary.
if frameSize+StdWriterPrefixLen > bufLen { if frameSize+StdWriterPrefixLen > bufLen {
log.Debugf("Extending buffer cap by %d (was %d)", frameSize+StdWriterPrefixLen-bufLen+1, len(buf)) logrus.Debugf("Extending buffer cap by %d (was %d)", frameSize+StdWriterPrefixLen-bufLen+1, len(buf))
buf = append(buf, make([]byte, frameSize+StdWriterPrefixLen-bufLen+1)...) buf = append(buf, make([]byte, frameSize+StdWriterPrefixLen-bufLen+1)...)
bufLen = len(buf) bufLen = len(buf)
} }
@ -140,13 +140,13 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
nr += nr2 nr += nr2
if er == io.EOF { if er == io.EOF {
if nr < frameSize+StdWriterPrefixLen { if nr < frameSize+StdWriterPrefixLen {
log.Debugf("Corrupted frame: %v", buf[StdWriterPrefixLen:nr]) logrus.Debugf("Corrupted frame: %v", buf[StdWriterPrefixLen:nr])
return written, nil return written, nil
} }
break break
} }
if er != nil { if er != nil {
log.Debugf("Error reading frame: %s", er) logrus.Debugf("Error reading frame: %s", er)
return 0, er return 0, er
} }
} }
@ -154,12 +154,12 @@ func StdCopy(dstout, dsterr io.Writer, src io.Reader) (written int64, err error)
// Write the retrieved frame (without header) // Write the retrieved frame (without header)
nw, ew = out.Write(buf[StdWriterPrefixLen : frameSize+StdWriterPrefixLen]) nw, ew = out.Write(buf[StdWriterPrefixLen : frameSize+StdWriterPrefixLen])
if ew != nil { if ew != nil {
log.Debugf("Error writing frame: %s", ew) logrus.Debugf("Error writing frame: %s", ew)
return 0, ew return 0, ew
} }
// If the frame has not been fully written: error // If the frame has not been fully written: error
if nw != frameSize { if nw != frameSize {
log.Debugf("Error Short Write: (%d on %d)", nw, frameSize) logrus.Debugf("Error Short Write: (%d on %d)", nw, frameSize)
return 0, io.ErrShortWrite return 0, io.ErrShortWrite
} }
written += int64(nw) written += int64(nw)

View file

@ -5,7 +5,7 @@ import (
"os" "os"
"path" "path"
log "github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
"github.com/docker/libcontainer/cgroups" "github.com/docker/libcontainer/cgroups"
) )
@ -20,20 +20,20 @@ func New(quiet bool) *SysInfo {
sysInfo := &SysInfo{} sysInfo := &SysInfo{}
if cgroupMemoryMountpoint, err := cgroups.FindCgroupMountpoint("memory"); err != nil { if cgroupMemoryMountpoint, err := cgroups.FindCgroupMountpoint("memory"); err != nil {
if !quiet { if !quiet {
log.Warnf("%s", err) logrus.Warnf("%s", err)
} }
} else { } else {
_, err1 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.limit_in_bytes")) _, err1 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.limit_in_bytes"))
_, err2 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.soft_limit_in_bytes")) _, err2 := ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.soft_limit_in_bytes"))
sysInfo.MemoryLimit = err1 == nil && err2 == nil sysInfo.MemoryLimit = err1 == nil && err2 == nil
if !sysInfo.MemoryLimit && !quiet { if !sysInfo.MemoryLimit && !quiet {
log.Warnf("Your kernel does not support cgroup memory limit.") logrus.Warnf("Your kernel does not support cgroup memory limit.")
} }
_, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes")) _, err = ioutil.ReadFile(path.Join(cgroupMemoryMountpoint, "memory.memsw.limit_in_bytes"))
sysInfo.SwapLimit = err == nil sysInfo.SwapLimit = err == nil
if !sysInfo.SwapLimit && !quiet { if !sysInfo.SwapLimit && !quiet {
log.Warnf("Your kernel does not support cgroup swap limit.") logrus.Warnf("Your kernel does not support cgroup swap limit.")
} }
} }