diff options
Diffstat (limited to 'wget.go')
| -rw-r--r-- | wget.go | 30 |
1 files changed, 14 insertions, 16 deletions
@@ -10,18 +10,16 @@ package shell global variables */ -import "io" -import "os" -import "fmt" -import "log" -import "bytes" -import "strings" -import "net/http" +import ( + "io" + "os" + "fmt" + "bytes" + "strings" + "net/http" -/* -import "go.wit.com/shell" -import "github.com/davecgh/go-spew/spew" -*/ + "go.wit.com/log" +) func Wget(url string) (*bytes.Buffer) { buf := new(bytes.Buffer) @@ -34,7 +32,7 @@ func Wget(url string) (*bytes.Buffer) { } defer resp.Body.Close() - log.Printf("res.StatusCode: %d\n", resp.StatusCode) + log.Log(INFO, "res.StatusCode: %d\n", resp.StatusCode) if (resp.StatusCode != 200) { handleError(fmt.Errorf(fmt.Sprint("%d", resp.StatusCode)), -1) return nil @@ -45,8 +43,8 @@ func Wget(url string) (*bytes.Buffer) { } func WgetToFile(filepath string, url string) error { - log.Println("WgetToFile() filepath =", filepath) - log.Println("WgetToFile() URL =", url) + log.Log(INFO, "WgetToFile() filepath =", filepath) + log.Log(INFO, "WgetToFile() URL =", url) // Get the data resp, err := http.Get(url) if err != nil { @@ -81,7 +79,7 @@ func Write(filepath string, data string) bool { data = Chomp(data) + "\n" // Create the file ospath := Path(filepath) - log.Println("shell.Write() START ospath =", ospath, "filepath =", filepath) + log.Log(INFO, "shell.Write() START ospath =", ospath, "filepath =", filepath) out, err := os.Create(ospath) if err != nil { return false @@ -96,6 +94,6 @@ func Write(filepath string, data string) bool { return false } handleError(nil, int(count)) - log.Println("shell.Write() END", ospath) + log.Log(INFO, "shell.Write() END", ospath) return true } |
