more go.wit.com/log
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b97b51855e
commit
bfdc9780f7
15
chomp.go
15
chomp.go
|
@ -6,11 +6,14 @@ package shell
|
|||
send it anything, always get back a string
|
||||
*/
|
||||
|
||||
import "log"
|
||||
import "fmt"
|
||||
import "reflect"
|
||||
import "strings"
|
||||
import "bytes"
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strings"
|
||||
"bytes"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
|
@ -81,7 +84,7 @@ func Chomp(a interface{}) string {
|
|||
default:
|
||||
tmp := fmt.Sprint("shell.Chomp() NO HANDLER FOR TYPE: %T", a)
|
||||
handleError(fmt.Errorf(tmp), -1)
|
||||
log.Printf("shell.Chomp() NEED TO MAKE CONVERTER FOR type =", reflect.TypeOf(t))
|
||||
log.Warn("shell.Chomp() NEED TO MAKE CONVERTER FOR type =", reflect.TypeOf(t))
|
||||
}
|
||||
tmp := "shell.Chomp() THIS SHOULD NEVER HAPPEN"
|
||||
handleError(fmt.Errorf(tmp), -1)
|
||||
|
|
30
wget.go
30
wget.go
|
@ -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
|
||||
}
|
||||
|
|
|
@ -4,15 +4,17 @@
|
|||
|
||||
package shell
|
||||
|
||||
import "log"
|
||||
import (
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// import "go.wit.com/shell"
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
func handleSignal(err interface{}, ret int) {
|
||||
log.Println("handleSignal() windows doesn't do signals")
|
||||
log.Warn("handleSignal() windows doesn't do signals")
|
||||
}
|
||||
|
||||
func UseJournalctl() {
|
||||
log.Println("journalctl doesn't exist on windows")
|
||||
log.Warn("journalctl doesn't exist on windows")
|
||||
}
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package shell
|
||||
|
||||
import "log"
|
||||
import "runtime"
|
||||
import "strings"
|
||||
import (
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
func Execname(filename string) string {
|
||||
if runtime.GOOS != "windows" {
|
||||
|
@ -12,12 +15,12 @@ func Execname(filename string) string {
|
|||
}
|
||||
|
||||
func Path(filename string) string {
|
||||
log.Println("shell.Path() START filename =", filename)
|
||||
log.Log(INFO, "Path() START filename =", filename)
|
||||
if runtime.GOOS != "windows" {
|
||||
log.Println("shell.Path() END filename =", filename)
|
||||
log.Log(INFO, "Path() END filename =", filename)
|
||||
return filename
|
||||
}
|
||||
filename = strings.Replace(filename, "/", "\\", -1)
|
||||
log.Println("shell.Path() END filename =", filename)
|
||||
log.Log(INFO, "Path() END filename =", filename)
|
||||
return filename
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue