go.wit.com/log change
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
096a4b17d1
commit
e24c2c2eb3
32
args.go
32
args.go
|
@ -6,29 +6,17 @@ import (
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var INFO log.LogFlag
|
var NOW *log.LogFlag
|
||||||
var RUN log.LogFlag
|
var INFO *log.LogFlag
|
||||||
var SSH log.LogFlag
|
var RUN *log.LogFlag
|
||||||
|
var SSH *log.LogFlag
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
INFO.B = false
|
full := "go.wit.com/shell"
|
||||||
INFO.Name = "INFO"
|
short := "shell"
|
||||||
INFO.Subsystem = "shell"
|
|
||||||
INFO.Short = "shell"
|
|
||||||
INFO.Desc = "general info"
|
|
||||||
INFO.Register()
|
|
||||||
|
|
||||||
RUN.B = false
|
NOW = log.NewFlag("NOW", true, full, short, "temp debugging stuff")
|
||||||
RUN.Name = "RUN"
|
INFO = log.NewFlag("INFO", false, full, short, "General Info")
|
||||||
RUN.Subsystem = "shell"
|
RUN = log.NewFlag("RUN", false, full, short, "Run() info")
|
||||||
RUN.Short = "shell"
|
SSH = log.NewFlag("SSH", false, full, short, "ssh() info")
|
||||||
RUN.Desc = "Run() info"
|
|
||||||
RUN.Register()
|
|
||||||
|
|
||||||
SSH.B = false
|
|
||||||
SSH.Name = "SSH"
|
|
||||||
SSH.Subsystem = "shell"
|
|
||||||
SSH.Short = "shell"
|
|
||||||
SSH.Desc = "ssh() info"
|
|
||||||
SSH.Register()
|
|
||||||
}
|
}
|
||||||
|
|
15
chomp.go
15
chomp.go
|
@ -6,11 +6,14 @@ package shell
|
||||||
send it anything, always get back a string
|
send it anything, always get back a string
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import "log"
|
import (
|
||||||
import "fmt"
|
"fmt"
|
||||||
import "reflect"
|
"reflect"
|
||||||
import "strings"
|
"strings"
|
||||||
import "bytes"
|
"bytes"
|
||||||
|
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
// import "github.com/davecgh/go-spew/spew"
|
// import "github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
|
@ -81,7 +84,7 @@ func Chomp(a interface{}) string {
|
||||||
default:
|
default:
|
||||||
tmp := fmt.Sprint("shell.Chomp() NO HANDLER FOR TYPE: %T", a)
|
tmp := fmt.Sprint("shell.Chomp() NO HANDLER FOR TYPE: %T", a)
|
||||||
handleError(fmt.Errorf(tmp), -1)
|
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"
|
tmp := "shell.Chomp() THIS SHOULD NEVER HAPPEN"
|
||||||
handleError(fmt.Errorf(tmp), -1)
|
handleError(fmt.Errorf(tmp), -1)
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -6,7 +6,7 @@ require (
|
||||||
github.com/svent/go-nbreader v0.0.0-20150201200112-7cef48da76dc
|
github.com/svent/go-nbreader v0.0.0-20150201200112-7cef48da76dc
|
||||||
github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef
|
github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef
|
||||||
github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117
|
github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117
|
||||||
go.wit.com/log v0.3.1
|
go.wit.com/log v0.4.1
|
||||||
golang.org/x/crypto v0.17.0
|
golang.org/x/crypto v0.17.0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
4
go.sum
4
go.sum
|
@ -18,8 +18,8 @@ github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef h1:7D6Nm4D6f0ci9yttWaKjM1T
|
||||||
github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef/go.mod h1:WLFStEdnJXpjK8kd4qKLwQKX/1vrDzp5BcDyiZJBHJM=
|
github.com/tmc/scp v0.0.0-20170824174625-f7b48647feef/go.mod h1:WLFStEdnJXpjK8kd4qKLwQKX/1vrDzp5BcDyiZJBHJM=
|
||||||
github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117 h1:67A5tweHp3C7osHjrYsy6pQZ00bYkTTttZ7kiOwwHeA=
|
github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117 h1:67A5tweHp3C7osHjrYsy6pQZ00bYkTTttZ7kiOwwHeA=
|
||||||
github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117/go.mod h1:XCsSkdKK4gwBMNrOCZWww0pX6AOt+2gYc5Z6jBRrNVg=
|
github.com/wercker/journalhook v0.0.0-20230927020745-64542ffa4117/go.mod h1:XCsSkdKK4gwBMNrOCZWww0pX6AOt+2gYc5Z6jBRrNVg=
|
||||||
go.wit.com/log v0.3.1 h1:UXtgJ4dwyWL0Yv4mw6gQnlmrIQU/zz6nClCB7NGKBQs=
|
go.wit.com/log v0.4.1 h1:x2PXlm1exgFrweGTM7thyj6KJabtnGlXssYkxv56hpc=
|
||||||
go.wit.com/log v0.3.1/go.mod h1:GmsggfsKrqdZdAj26fEOlcTz6qEIazbV33uyuuktvB8=
|
go.wit.com/log v0.4.1/go.mod h1:EZLvivLZpMoXl5AUBArH0zsIgr+c+WyNXm14BCF+sdw=
|
||||||
go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9 h1:UEX2EzLQPzLTfy/kUFQD7OXtvKn8wk/+jpDOkbl4ff4=
|
go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9 h1:UEX2EzLQPzLTfy/kUFQD7OXtvKn8wk/+jpDOkbl4ff4=
|
||||||
go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9/go.mod h1:qBpgJXThMMT15vym7/E4Ur9y8oOo2nP7t2RP52QHUNw=
|
go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9/go.mod h1:qBpgJXThMMT15vym7/E4Ur9y8oOo2nP7t2RP52QHUNw=
|
||||||
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k=
|
||||||
|
|
30
wget.go
30
wget.go
|
@ -10,18 +10,16 @@ package shell
|
||||||
global variables
|
global variables
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import "io"
|
import (
|
||||||
import "os"
|
"io"
|
||||||
import "fmt"
|
"os"
|
||||||
import "log"
|
"fmt"
|
||||||
import "bytes"
|
"bytes"
|
||||||
import "strings"
|
"strings"
|
||||||
import "net/http"
|
"net/http"
|
||||||
|
|
||||||
/*
|
"go.wit.com/log"
|
||||||
import "go.wit.com/shell"
|
)
|
||||||
import "github.com/davecgh/go-spew/spew"
|
|
||||||
*/
|
|
||||||
|
|
||||||
func Wget(url string) (*bytes.Buffer) {
|
func Wget(url string) (*bytes.Buffer) {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
|
@ -34,7 +32,7 @@ func Wget(url string) (*bytes.Buffer) {
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
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) {
|
if (resp.StatusCode != 200) {
|
||||||
handleError(fmt.Errorf(fmt.Sprint("%d", resp.StatusCode)), -1)
|
handleError(fmt.Errorf(fmt.Sprint("%d", resp.StatusCode)), -1)
|
||||||
return nil
|
return nil
|
||||||
|
@ -45,8 +43,8 @@ func Wget(url string) (*bytes.Buffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func WgetToFile(filepath string, url string) error {
|
func WgetToFile(filepath string, url string) error {
|
||||||
log.Println("WgetToFile() filepath =", filepath)
|
log.Log(INFO, "WgetToFile() filepath =", filepath)
|
||||||
log.Println("WgetToFile() URL =", url)
|
log.Log(INFO, "WgetToFile() URL =", url)
|
||||||
// Get the data
|
// Get the data
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -81,7 +79,7 @@ func Write(filepath string, data string) bool {
|
||||||
data = Chomp(data) + "\n"
|
data = Chomp(data) + "\n"
|
||||||
// Create the file
|
// Create the file
|
||||||
ospath := Path(filepath)
|
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)
|
out, err := os.Create(ospath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
|
@ -96,6 +94,6 @@ func Write(filepath string, data string) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
handleError(nil, int(count))
|
handleError(nil, int(count))
|
||||||
log.Println("shell.Write() END", ospath)
|
log.Log(INFO, "shell.Write() END", ospath)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,15 +4,17 @@
|
||||||
|
|
||||||
package shell
|
package shell
|
||||||
|
|
||||||
import "log"
|
import (
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
// import "go.wit.com/shell"
|
// import "go.wit.com/shell"
|
||||||
// import "github.com/davecgh/go-spew/spew"
|
// import "github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
func handleSignal(err interface{}, ret int) {
|
func handleSignal(err interface{}, ret int) {
|
||||||
log.Println("handleSignal() windows doesn't do signals")
|
log.Warn("handleSignal() windows doesn't do signals")
|
||||||
}
|
}
|
||||||
|
|
||||||
func UseJournalctl() {
|
func UseJournalctl() {
|
||||||
log.Println("journalctl doesn't exist on windows")
|
log.Warn("journalctl doesn't exist on windows")
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package shell
|
package shell
|
||||||
|
|
||||||
import "log"
|
import (
|
||||||
import "runtime"
|
"runtime"
|
||||||
import "strings"
|
"strings"
|
||||||
|
|
||||||
|
"go.wit.com/log"
|
||||||
|
)
|
||||||
|
|
||||||
func Execname(filename string) string {
|
func Execname(filename string) string {
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
|
@ -12,12 +15,12 @@ func Execname(filename string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Path(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" {
|
if runtime.GOOS != "windows" {
|
||||||
log.Println("shell.Path() END filename =", filename)
|
log.Log(INFO, "Path() END filename =", filename)
|
||||||
return filename
|
return filename
|
||||||
}
|
}
|
||||||
filename = strings.Replace(filename, "/", "\\", -1)
|
filename = strings.Replace(filename, "/", "\\", -1)
|
||||||
log.Println("shell.Path() END filename =", filename)
|
log.Log(INFO, "Path() END filename =", filename)
|
||||||
return filename
|
return filename
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue