diff options
| author | Jeff Carr <[email protected]> | 2024-01-10 18:39:58 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-10 18:39:58 -0600 |
| commit | e24c2c2eb3feb5083a74a9b2cb396bcbcb0ac52d (patch) | |
| tree | 65c131d3f739368c75dad2dffc477c1e8c9cb545 /wget.go | |
| parent | 096a4b17d1579a2e5997abcdd8b29eb85aff0fae (diff) | |
go.wit.com/log changev0.2.3
Signed-off-by: Jeff Carr <[email protected]>
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 } |
