本文整理汇总了Golang中minilog.Infoln函数的典型用法代码示例。如果您正苦于以下问题:Golang Infoln函数的具体用法?Golang Infoln怎么用?Golang Infoln使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Infoln函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: commandSocketHandle
func commandSocketHandle(c net.Conn) {
defer c.Close()
enc := json.NewEncoder(c)
dec := json.NewDecoder(c)
var err error
for err == nil {
var cmd *minicli.Command
cmd, err = readLocalCommand(dec)
if err != nil {
break
}
if cmd == nil {
err = sendLocalResp(enc, nil, false)
continue
}
// HAX: Don't record the read command
if hasCommand(cmd, "read") {
cmd.SetRecord(false)
}
// HAX: Work around so that we can add the more boolean.
var prev minicli.Responses
// Keep sending until we hit the first error, then just consume the
// channel to ensure that we release any locks acquired by cmd.
for resp := range RunCommands(cmd) {
if prev != nil && err == nil {
err = sendLocalResp(enc, prev, true)
} else if err != nil && len(resp) > 0 {
log.Info("dropping resp from %v", resp[0].Host)
}
prev = resp
}
if err == nil {
err = sendLocalResp(enc, prev, false)
}
}
// finally, log the error, if there was one
if err == nil || err == io.EOF {
log.Infoln("command client disconnected")
} else if err != nil && strings.Contains(err.Error(), "write: broken pipe") {
log.Infoln("command client disconnected without waiting for responses")
} else if err != nil {
log.Errorln(err)
}
}
示例2: dnsmasqKill
func dnsmasqKill(id int) error {
pid := dnsmasqPID(id)
log.Debug("dnsmasq id %v has pid %v", id, pid)
if pid == -1 {
return fmt.Errorf("invalid id")
}
var sOut bytes.Buffer
var sErr bytes.Buffer
p := process("kill")
cmd := &exec.Cmd{
Path: p,
Args: []string{
p,
fmt.Sprintf("%v", pid),
},
Env: nil,
Dir: "",
Stdout: &sOut,
Stderr: &sErr,
}
log.Infoln("killing dnsmasq server:", pid)
err := cmd.Run()
if err != nil {
return err
}
return nil
}
示例3: nukeWalker
// Walks the f_base directory and kills procs read from any qemu or
// dnsmasq pid files
func nukeWalker(path string, info os.FileInfo, err error) error {
if err != nil {
return nil
}
log.Debug("walking file: %v", path)
switch info.Name() {
case "qemu.pid", "dnsmasq.pid":
d, err := ioutil.ReadFile(path)
t := strings.TrimSpace(string(d))
log.Debug("found pid: %v", t)
if err != nil {
return err
}
args := []string{
"kill",
t,
}
log.Infoln("killing process:", t)
out, err := processWrapper(args...)
if err != nil {
log.Error("%v: %v", err, out)
}
}
return nil
}
示例4: nukeBridges
func nukeBridges() {
bNames := nukeBridgeNames(false)
for _, b := range bNames {
var sOut bytes.Buffer
var sErr bytes.Buffer
p := process("ovs")
cmd := &exec.Cmd{
Path: p,
Args: []string{
p,
"del-br",
b,
},
Env: nil,
Dir: "",
Stdout: &sOut,
Stderr: &sErr,
}
log.Infoln("removing bridge:", b)
//err := cmd.Run()
err := cmdTimeout(cmd, OVS_TIMEOUT)
if err != nil {
log.Error("%v: %v", err, sErr.String())
}
}
}
示例5: flush
func (vms VMs) flush() {
for i, vm := range vms {
if vm.State()&(VM_QUIT|VM_ERROR) != 0 {
log.Infoln("deleting VM: ", i)
delete(vms, i)
}
}
}
示例6: flush
func (vms VMs) flush() {
stateMask := VM_QUIT | VM_ERROR
for i, vm := range vms {
if vm.State&stateMask != 0 {
log.Infoln("deleting VM: ", i)
delete(vms, i)
}
}
}
示例7: flush
func (vms VMs) flush() {
vmLock.Lock()
defer vmLock.Unlock()
for i, vm := range vms {
if vm.GetState()&(VM_QUIT|VM_ERROR) != 0 {
log.Infoln("deleting VM: ", i)
delete(vms, i)
}
}
}
示例8: sendLocalResp
func sendLocalResp(enc *json.Encoder, resp minicli.Responses, more bool) error {
log.Infoln("sending resp:", resp)
r := localResponse{
More: more,
}
if resp != nil {
r.Resp = resp
r.Rendered = resp.String()
}
return enc.Encode(&r)
}
示例9: commandSocketHandle
func commandSocketHandle(c net.Conn) {
var err error
enc := json.NewEncoder(c)
dec := json.NewDecoder(c)
outer:
for err == nil {
var cmd *minicli.Command
cmd, err = readLocalCommand(dec)
if err != nil {
if err != io.EOF {
// Must be incompatible versions of minimega... F***
log.Errorln(err)
}
break
}
err = nil
var prevResp minicli.Responses
if cmd != nil {
// HAX: Don't record the read command
if hasCommand(cmd, "read") {
cmd.Record = false
}
// HAX: Work around so that we can add the more boolean
for resp := range runCommand(cmd) {
if prevResp != nil {
err = sendLocalResp(enc, prevResp, true)
if err != nil {
break outer
}
}
prevResp = resp
}
}
if err == nil {
err = sendLocalResp(enc, prevResp, false)
}
}
if err != nil {
if err == io.EOF {
log.Infoln("command client disconnected")
} else {
log.Errorln(err)
}
}
}
示例10: runCommand
// runCommand runs a command through a JSON pipe.
func runCommand(cmd Command) chan *localResponse {
conn, err := net.Dial("unix", path.Join(*f_minimega, "minimega"))
if err != nil {
log.Errorln(err)
return nil
}
enc := json.NewEncoder(conn)
dec := json.NewDecoder(conn)
log.Debug("encoding command: %v", cmd)
err = enc.Encode(cmd)
if err != nil {
log.Errorln("local command json encode: %v", err)
return nil
}
log.Debugln("encoded command:", cmd)
respChan := make(chan *localResponse)
go func() {
defer close(respChan)
for {
var r localResponse
err = dec.Decode(&r)
if err != nil {
if err == io.EOF {
log.Infoln("server disconnected")
return
}
log.Errorln("local command json decode: %v", err)
return
}
respChan <- &r
if !r.More {
log.Debugln("got last message")
break
} else {
log.Debugln("expecting more data")
}
}
}()
return respChan
}
示例11: Overlays
// Overlays copies any overlay directories indicated in c into the build
// directory build_path. Overlays are copied in depth-first order, so that
// the oldest parent overlay data is copied in first. This allows a child
// to overwrite any overlay data created by a parent.
func Overlays(buildPath string, c vmconfig.Config) error {
// copy the overlays in order
for i, o := range c.Overlays {
log.Infoln("copying overlay:", o)
var sourcePath string
// check if overlay exists as absolute path or relative to cwd
if _, err := os.Stat(o); os.IsNotExist(err) {
// it doesn't, so we'll check relative to config file
log.Debugln("overlay directory '%v' does not exist as an absolute path or relative to the current working directory.", o)
var path string
base := filepath.Base(o) // get base path of overlay directory
if i == len(c.Overlays)-1 { // if this is the last overlay, we'll check relative to c.Path
log.Debugln("non-parent overlay")
path = filepath.Join(filepath.Dir(c.Path), base)
} else { // if not, it's a parent overlay and we'll check relative to c.Parents[i]
log.Debugln("parent overlay")
path = filepath.Join(filepath.Dir(c.Parents[i]), base)
}
log.Debugln("checking path relative to config location: '%v'", path)
if _, err := os.Stat(path); os.IsNotExist(err) { // check if we can find overlay relative to config file
return err // nope
} else { // yep
sourcePath = path
}
} else {
sourcePath = o
}
p := process("cp")
cmd := exec.Command(p, "-r", "-v", sourcePath+"/.", buildPath)
stdout, err := cmd.StdoutPipe()
if err != nil {
return err
}
stderr, err := cmd.StderrPipe()
if err != nil {
return err
}
log.LogAll(stdout, log.INFO, "cp")
log.LogAll(stderr, log.ERROR, "cp")
err = cmd.Run()
if err != nil {
return err
}
}
return nil
}
示例12: dnsmasqKill
func dnsmasqKill(id int) error {
pid := dnsmasqPID(id)
log.Debug("dnsmasq id %v has pid %v", id, pid)
if pid == -1 {
return fmt.Errorf("invalid id")
}
log.Infoln("killing dnsmasq server:", pid)
_, err := processWrapper("kill", fmt.Sprintf("%v", pid))
if err != nil {
return err
}
return nil
}
示例13: commandSocketStart
func commandSocketStart() {
l, err := net.Listen("unix", filepath.Join(*f_path, "minirouter"))
if err != nil {
log.Fatalln("commandSocketStart: %v", err)
}
for {
conn, err := l.Accept()
if err != nil {
log.Error("commandSocketStart: accept: %v", err)
}
log.Infoln("client connected")
go commandSocketHandle(conn)
}
}
示例14: commandSocketStart
func commandSocketStart() {
l, err := net.Listen("unix", filepath.Join(*f_base, "minimega"))
if err != nil {
log.Error("commandSocketStart: %v", err)
teardown()
}
for {
conn, err := l.Accept()
if err != nil {
log.Error("commandSocketStart: accept: %v", err)
}
log.Infoln("client connected")
go commandSocketHandle(conn)
}
}
示例15: runCommand
// runCommand runs a command through a JSON pipe.
func (mm *MinimegaConn) runCommand(cmd *minicli.Command) chan *localResponse {
err := mm.enc.Encode(*cmd)
if err != nil {
log.Errorln("local command gob encode: %v", err)
return nil
}
log.Debugln("encoded command:", cmd)
respChan := make(chan *localResponse)
go func() {
defer close(respChan)
for {
var r localResponse
err = mm.dec.Decode(&r)
if err != nil {
if err == io.EOF {
log.Infoln("server disconnected")
return
}
log.Errorln("local command gob decode: %v", err)
return
}
respChan <- &r
if !r.More {
log.Debugln("got last message")
break
} else {
log.Debugln("expecting more data")
}
}
}()
return respChan
}