Skip to content

Instantly share code, notes, and snippets.

@vkuznecovas vkuznecovas/main.go
Created Mar 28, 2019

Embed
What would you like to do?
testwin
package main
import (
"fmt"
"os/exec"
"github.com/cihub/seelog"
)
const seewayLogXmlConfig = `
<seelog>
<outputs>
<console formatid="all"/>
</outputs>
<formats>
<format id="all" format="%UTCDate(2006-01-02T15:04:05.999999999)[%Level] %Msg%n"/>
</formats>
</seelog>
`
// Bootstrap loads seelog package into the overall system
func Bootstrap() {
newLogger, err := seelog.LoggerFromConfigAsString(seewayLogXmlConfig)
if err != nil {
seelog.Warn("Error parsing seelog configuration", err)
return
}
err = seelog.ReplaceLogger(newLogger)
if err != nil {
seelog.Warn("Error setting new logger for seelog", err)
}
}
func main() {
Bootstrap()
seelog.Info("this is a test")
defer seelog.Flush()
logdone := make(chan struct{})
shellDone := make(chan struct{})
go func() {
for i := 0; i < 100; i++ {
PowerShell("echo test")
}
shellDone <- struct{}{}
}()
go func() {
for i := 0; i < 100; i++ {
seelog.Info("this is a test")
}
logdone <- struct{}{}
}()
<-shellDone
<-logdone
}
func PowerShell(cmd string) ([]byte, error) {
out, err := exec.Command("powershell", "-Command", cmd).CombinedOutput()
if err != nil {
return nil, fmt.Errorf("'powershell -Command %v': %v output: %s", cmd, err, string(out))
}
return out, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.