[from now] 2014/08/24 19:35:16

diff --git a/cmd/copybackup/copybackup.go b/cmd/copybackup/copybackup.go
index 4ee3d4c..0b6dfae 100644
--- a/cmd/copybackup/copybackup.go
+++ b/cmd/copybackup/copybackup.go
@@ -7,11 +7,16 @@ import (
 	"path/filepath"
 	"sync"

-	"github.com/yukimemi/copybackup"
+	"github.com/umisama/golog"
+	cb "github.com/yukimemi/copybackup"
+	core "github.com/yukimemi/gocore"
 )

+type Options struct {
+}
+
 func main() {
-	var debug copybackup.DebugT
+	core.Logger, _ = log.NewLogger(os.Stdout, log.TIME_FORMAT_SEC, log.LOG_FORMAT_POWERFUL, log.LogLevel_Debug)

 	var root string
 	var e error
@@ -20,37 +25,33 @@ func main() {
 	g := flag.Int("g", -1, "バックアップする世代。")
 	b := flag.String("b", "_old", "バックアップを保存する先。絶対パスでの指定も可能。 ([デフォルト _old])")
 	s := flag.Int("s", 60*5, "バックアップ間隔。 (秒 [デフォルト 5分])")
-	flag.Parse()

-	debug.Println("g = ", *g)
-	debug.Println("b = ", *b)
-	debug.Println("s = ", *s)
+	core.Logger.Debugf("g = %d", *g)
+	core.Logger.Debugf("b = %s", *b)
+	core.Logger.Debugf("s = %d", *s)
+	flag.Parse()

-	debug.PrintValue("args", flag.Args())
-	debug.PrintValue("args", os.Args)
 	if flag.NArg() != 0 {
 		root = flag.Arg(0)
 	} else {
 		root, e = os.Getwd()
-		copybackup.FailOnError(e)
+		core.FailOnError(e)
 		flag.Usage()
-		os.Exit(1)
+		os.Exit(0)
 	}

-	debug.PrintValue("root", root)
-
 	files, e := ioutil.ReadDir(root)
-	copybackup.FailOnError(e)
+	core.FailOnError(e)

 	for _, f := range files {
 		if !f.IsDir() {
 			src := filepath.Join(root, f.Name())
-			dst, e := copybackup.MakeDstPath(src, "_old")
-			copybackup.FailOnError(e)
+			dst, e := cb.MakeDstPath(src, "_old")
+			core.FailOnError(e)
 			wg.Add(1)
 			go func(src, dst string) {
 				defer wg.Done()
-				copybackup.Backup(src, dst)
+				cb.Backup(src, dst)
 			}(src, dst)
 		}
 		wg.Wait()
diff --git a/copybackup.go b/copybackup.go
index bc217e3..ce6ea3c 100644
--- a/copybackup.go
+++ b/copybackup.go
@@ -2,52 +2,13 @@ package copybackup

 import ( // {{{
 	"io"
-	"log"
 	"os"
 	"path/filepath"
 	"strings"
 	"time"
-) // }}}
-
-// for debug {{{
-type DebugT bool
-
-var debug = DebugT(true)
-
-func (d DebugT) Println(args ...interface{}) { // {{{
-	if d {
-		log.Println(args...)
-	}
-} // }}}
-
-func (d DebugT) Printf(format string, v ...interface{}) { // {{{
-	if d {
-		log.Printf(format, v...)
-	}
-} // }}}

-func (d DebugT) PrintValue(vs string, v interface{}) { // {{{
-	if d {
-		log.Printf("%s = [%s]", vs, v)
-	}
-} // }}}
-
-func trace(s string) string { // {{{
-	debug.Println("ENTER:", s)
-	return s
-} // }}}
-
-func un(s string) { // {{{
-	debug.Println("LEAVE:", s)
-} // }}}
-
-// }}}
-
-func FailOnError(e error) { // {{{
-	if e != nil {
-		log.Fatal("Error:", e)
-	}
-} // }}}
+	core "github.com/yukimemi/gocore"
+) // }}}

 type Options struct {
 	path       string
@@ -72,12 +33,13 @@ func MakeDstPath(path, bkpath string) (string, error) {
 }

 func Backup(src, dst string) {
+	var e error
 	dstParent := filepath.Dir(dst)
-	os.MkdirAll(dstParent, 0755)
-	e := cp(dst, src)
-	debug.PrintValue("src", src)
-	debug.PrintValue("dst", dst)
-	FailOnError(e)
+	e = os.MkdirAll(dstParent, os.ModePerm)
+	core.FailOnError(e)
+	core.Logger.Infof("%s -> %s", src, dst)
+	e = cp(dst, src)
+	core.FailOnError(e)
 }

 func cp(dst, src string) error {