mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #2952 from xiang90/fileutil
fileutil: use leveled logging
This commit is contained in:
commit
f64a8214f7
@ -19,12 +19,18 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
"github.com/coreos/etcd/Godeps/_workspace/src/github.com/coreos/pkg/capnslog"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
privateFileMode = 0600
|
privateFileMode = 0600
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
plog = capnslog.NewPackageLogger("github.com/coreos/etcd/pkg", "fileutil")
|
||||||
|
)
|
||||||
|
|
||||||
// IsDirWriteable checks if dir is writable by writing and removing a file
|
// IsDirWriteable checks if dir is writable by writing and removing a file
|
||||||
// to dir. It returns nil if dir is writable.
|
// to dir. It returns nil if dir is writable.
|
||||||
func IsDirWriteable(dir string) error {
|
func IsDirWriteable(dir string) error {
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
package fileutil
|
package fileutil
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"sort"
|
"sort"
|
||||||
@ -57,13 +56,17 @@ func PurgeFile(dirname string, suffix string, max uint, interval time.Duration,
|
|||||||
}
|
}
|
||||||
err = l.Unlock()
|
err = l.Unlock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("filePurge: unlock %s error %v", l.Name(), err)
|
plog.Errorf("error unlocking %s when purging file (%v)", l.Name(), err)
|
||||||
|
errC <- err
|
||||||
|
return
|
||||||
}
|
}
|
||||||
err = l.Destroy()
|
err = l.Destroy()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("filePurge: destroy lock %s error %v", l.Name(), err)
|
plog.Errorf("error destroying lock %s when purging file (%v)", l.Name(), err)
|
||||||
|
errC <- err
|
||||||
|
return
|
||||||
}
|
}
|
||||||
log.Printf("filePurge: successfully removed file %s", f)
|
plog.Infof("purged file %s successfully", f)
|
||||||
newfnames = newfnames[1:]
|
newfnames = newfnames[1:]
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user