本文整理匯總了Golang中github.com/golang/glog.Info函數的典型用法代碼示例。如果您正苦於以下問題:Golang Info函數的具體用法?Golang Info怎麽用?Golang Info使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Info函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: loadMyApp
func loadMyApp() {
timer := time.NewTicker(time.Second)
for {
<-timer.C
glog.Info("Checking time ", time.Now().Unix())
fname := fmt.Sprintf("%d.so", time.Now().Unix())
if _, err := os.Stat(fname); os.IsNotExist(err) {
continue
}
p, err := plugin.Open(fname)
if err != nil {
log.Println(err)
continue
}
glog.Info("Plugin loaded: ", fname)
f, err := p.Lookup("MyAppHandler")
if err != nil {
log.Println(err)
continue
}
glog.Info("Func loaded")
myApp.app = p
h := f.(func(http.ResponseWriter, *http.Request))
myApp.Lock()
myApp.handler = &h
myApp.Unlock()
}
}
示例2: HandleAuthToken
func (client *Client) HandleAuthToken(login *AuthenticationToken) {
appid, uid, err := client.AuthToken(login.token)
if err != nil {
log.Info("auth token err:", err)
msg := &Message{cmd: MSG_AUTH_STATUS, body: &AuthenticationStatus{1, 0}}
client.wt <- msg
return
}
if uid == 0 || appid == 0 {
log.Info("auth token appid==0, uid==0")
msg := &Message{cmd: MSG_AUTH_STATUS, body: &AuthenticationStatus{1, 0}}
client.wt <- msg
return
}
client.tm = time.Now()
client.uid = uid
client.appid = appid
log.Infof("auth appid:%d uid:%d\n", appid, uid)
msg := &Message{cmd: MSG_AUTH_STATUS, body: &AuthenticationStatus{0, client.public_ip}}
client.wt <- msg
client.SendLoginPoint()
client.AddClient()
}
示例3: NewCompany
func NewCompany(d *display.Display, pt complex128, dir complex128, nSoldiers int, f Formation) (c *Company) {
c = new(Company)
c.s = make([]*Soldier, nSoldiers)
c.f = f
_, cols := c.f.RowCols(len(c.s))
for i, _ := range c.s {
if i == 0 {
c.s[i] = NewSoldier(d, fmt.Sprintf("Sol %v ", i), pt, dir)
c.alignBy = c.s[0]
glog.Info(c.s[i].GetName(), c.s[i].Pt)
} else {
c.s[i] = NewRandSoldier(d, fmt.Sprintf("Sol %v ", i))
c.s[0].AddToForm(c.s[i], 1, cols)
c.s[i].Pt = c.s[i].refPt()
c.s[i].PastPt = c.s[i].Pt
c.s[i].Dir = dir
glog.Info(c.s[i].GetName(), c.s[i].Pt)
}
}
for _, s := range c.s {
s.Color()
s.C = c
}
return c
}
示例4: Serve
func (r *SrsServer) Serve() error {
// too many open files will thows a panic.
addr, err := net.ResolveTCPAddr("tcp", r.addr)
if err != nil {
glog.Errorf("resolve listen address failed, err=%v", err)
return fmt.Errorf("resolve listen address failed, err=%v", err)
}
var listener *net.TCPListener
listener, err = net.ListenTCP("tcp", addr)
if err != nil {
glog.Errorf("listen failed, err=%v", err)
return fmt.Errorf("listen failed, err=%v", err)
}
defer listener.Close()
for {
glog.Info("listener ready to accept client")
conn, err := listener.AcceptTCP()
if err != nil {
glog.Errorf("accept client failed, err=%v", err)
return fmt.Errorf("accept client failed, err=%v", err)
}
glog.Info("TCP Connected")
go r.serve(conn)
}
}
示例5: stop
func (es *e2eService) stop() {
glog.Info("Stopping e2e services...")
es.getLogFiles()
// TODO(random-liu): Use a loop to stop all services after introducing service interface.
// Stop namespace controller
if es.nsController != nil {
if err := es.nsController.Stop(); err != nil {
glog.Errorf("Failed to stop %q: %v", es.nsController.Name(), err)
}
}
// Stop apiserver
if es.apiServer != nil {
if err := es.apiServer.Stop(); err != nil {
glog.Errorf("Failed to stop %q: %v", es.apiServer.Name(), err)
}
}
for _, s := range es.services {
if err := s.kill(); err != nil {
glog.Errorf("Failed to stop %v: %v", s.name, err)
}
}
// Stop etcd
if es.etcdServer != nil {
if err := es.etcdServer.Stop(); err != nil {
glog.Errorf("Failed to stop %q: %v", es.etcdServer.Name(), err)
}
}
for _, d := range es.rmDirs {
err := os.RemoveAll(d)
if err != nil {
glog.Errorf("Failed to delete directory %s.\n%v", d, err)
}
}
glog.Info("E2E services stopped.")
}
示例6: procSendMessageTopic
func (self *ProtoProc) procSendMessageTopic(cmd protocol.Cmd, session *libnet.Session) error {
glog.Info("procSendMessageTopic")
var err error
topicName := cmd.GetArgs()[0]
send2Msg := cmd.GetArgs()[1]
glog.Info(send2Msg)
glog.Info(topicName)
if self.msgServer.topics[topicName] == nil {
glog.Warning(topicName + " is not exist")
} else {
resp := protocol.NewCmdSimple(protocol.RESP_MESSAGE_TOPIC_CMD)
resp.AddArg(topicName)
resp.AddArg(send2Msg)
resp.AddArg(session.State.(*base.SessionState).ClientID)
_, err = self.msgServer.topics[topicName].Channel.Broadcast(libnet.Json(resp))
if err != nil {
glog.Error(err.Error())
return err
}
}
return err
}
示例7: Startcollect
func Startcollect(port int, device string, timesignal <-chan time.Time) {
handle, err = pcap.OpenLive(device, snapshotLen, promiscuous, timeout)
if err != nil {
glog.Info(err.Error())
}
defer handle.Close()
packetSource := gopacket.NewPacketSource(handle, handle.LinkType())
templocalip, err := checkLocalip(device)
localip = templocalip
if glog.V(0) {
glog.Info(localip)
}
httpinstancelist = list.New()
if err != nil {
glog.Info(err.Error())
}
A:
for packet := range packetSource.Packets() {
select {
case <-timesignal:
break A
default:
processPacketInfo(packet)
}
}
}
示例8: ReadMessage
func (storage *Storage) ReadMessage(file *os.File) *Message {
//校驗消息起始位置的magic
var magic int32
err := binary.Read(file, binary.BigEndian, &magic)
if err != nil {
log.Info("read file err:", err)
return nil
}
if magic != MAGIC {
log.Warning("magic err:", magic)
return nil
}
msg := ReceiveMessage(file)
if msg == nil {
return msg
}
err = binary.Read(file, binary.BigEndian, &magic)
if err != nil {
log.Info("read file err:", err)
return nil
}
if magic != MAGIC {
log.Warning("magic err:", magic)
return nil
}
return msg
}
示例9: LoadOfflineMessage
func (storage *Storage) LoadOfflineMessage(appid int64, uid int64) []*EMessage {
log.Infof("load offline message appid:%d uid:%d\n", appid, uid)
c := make([]*EMessage, 0, 10)
start := fmt.Sprintf("%d_%d_1", appid, uid)
end := fmt.Sprintf("%d_%d_9223372036854775807", appid, uid)
r := &util.Range{Start: []byte(start), Limit: []byte(end)}
iter := storage.db.NewIterator(r, nil)
for iter.Next() {
value := iter.Value()
msgid, err := strconv.ParseInt(string(value), 10, 64)
if err != nil {
log.Error("parseint err:", err)
continue
}
log.Info("offline msgid:", msgid)
msg := storage.LoadMessage(msgid)
if msg == nil {
log.Error("can't load offline message:", msgid)
continue
}
c = append(c, &EMessage{msgid: msgid, msg: msg})
}
iter.Release()
err := iter.Error()
if err != nil {
log.Warning("iterator err:", err)
}
log.Info("offline count:", len(c))
return c
}
示例10: waitForAllCaPodsReadyInNamespace
func waitForAllCaPodsReadyInNamespace(f *framework.Framework, c *client.Client) error {
var notready []string
for start := time.Now(); time.Now().Before(start.Add(scaleUpTimeout)); time.Sleep(20 * time.Second) {
pods, err := c.Pods(f.Namespace.Name).List(api.ListOptions{})
if err != nil {
return fmt.Errorf("failed to get pods: %v", err)
}
notready = make([]string, 0)
for _, pod := range pods.Items {
ready := false
for _, c := range pod.Status.Conditions {
if c.Type == api.PodReady && c.Status == api.ConditionTrue {
ready = true
}
}
if !ready {
notready = append(notready, pod.Name)
}
}
if len(notready) == 0 {
glog.Infof("All pods ready")
return nil
}
glog.Infof("Some pods are not ready yet: %v", notready)
}
glog.Info("Timeout on waiting for pods being ready")
glog.Info(framework.RunKubectlOrDie("get", "pods", "-o", "json", "--all-namespaces"))
glog.Info(framework.RunKubectlOrDie("get", "nodes", "-o", "json"))
// Some pods are still not running.
return fmt.Errorf("Some pods are still not running: %v", notready)
}
示例11: main
func main() {
flag.Parse()
ok := true
glog.Info("Processing code generator request")
res, err := convertFrom(os.Stdin)
if err != nil {
ok = false
if res == nil {
message := fmt.Sprintf("Failed to read input: %v", err)
res = &plugin.CodeGeneratorResponse{
Error: &message,
}
}
}
glog.Info("Serializing code generator response")
data, err := proto.Marshal(res)
if err != nil {
glog.Fatal("Cannot marshal response", err)
}
_, err = os.Stdout.Write(data)
if err != nil {
glog.Fatal("Failed to write response", err)
}
if ok {
glog.Info("Succeeded to process code generator request")
} else {
glog.Info("Failed to process code generator but successfully sent the error to protoc")
os.Exit(1)
}
}
示例12: ReadMessage
func ReadMessage(b []byte) *Message {
input, err := simplejson.NewJson(b)
if err != nil {
log.Info("json decode fail")
return nil
}
cmd, err := input.Get("cmd").Int()
if err != nil {
log.Info("json decode cmd fail")
return nil
}
seq, err := input.Get("seq").Int()
if err != nil {
log.Info("json decode seq fail")
return nil
}
msg := new(Message)
msg.cmd = cmd
msg.seq = seq
if msg.FromJson(input) {
return msg
}
return nil
}
示例13: main
func main() {
flag.Parse()
if err := embd.InitGPIO(); err != nil {
panic(err)
}
defer embd.CloseGPIO()
pin, err := embd.NewDigitalPin(7)
if err != nil {
panic(err)
}
defer pin.Close()
fluidSensor := watersensor.New(pin)
for {
wet, err := fluidSensor.IsWet()
if err != nil {
panic(err)
}
if wet {
glog.Info("bot is dry")
} else {
glog.Info("bot is Wet")
}
time.Sleep(500 * time.Millisecond)
}
}
示例14: statePreparing
func statePreparing(ctx *VmContext, ev VmEvent) {
switch ev.Event() {
case EVENT_VM_EXIT, ERROR_INTERRUPTED:
glog.Info("VM exited before start...")
case COMMAND_SHUTDOWN, COMMAND_RELEASE:
glog.Info("got shutdown or release command, not started yet")
ctx.reportVmShutdown()
ctx.Become(nil, StateNone)
case COMMAND_EXEC:
ctx.execCmd(ev.(*ExecCommand))
case COMMAND_WINDOWSIZE:
cmd := ev.(*WindowSizeCommand)
ctx.setWindowSize(cmd.ClientTag, cmd.Size)
case COMMAND_RUN_POD, COMMAND_REPLACE_POD:
glog.Info("got spec, prepare devices")
if ok := ctx.lazyPrepareDevice(ev.(*RunPodCommand)); ok {
ctx.startSocks()
ctx.DCtx.(LazyDriverContext).LazyLaunch(ctx)
ctx.setTimeout(60)
ctx.Become(stateStarting, StateStarting)
} else {
glog.Warning("Fail to prepare devices, quit")
ctx.Become(nil, StateNone)
}
case GENERIC_OPERATION:
ctx.handleGenericOperation(ev.(*GenericOperation))
default:
unexpectedEventHandler(ctx, ev, "pod initiating")
}
}
示例15: reconcileCMADAnnotationWithExistingNode
// reconcileCMADAnnotationWithExistingNode reconciles the controller-managed
// attach-detach annotation on a new node and the existing node, returning
// whether the existing node must be updated.
func (kl *Kubelet) reconcileCMADAnnotationWithExistingNode(node, existingNode *v1.Node) bool {
var (
existingCMAAnnotation = existingNode.Annotations[volumehelper.ControllerManagedAttachAnnotation]
newCMAAnnotation, newSet = node.Annotations[volumehelper.ControllerManagedAttachAnnotation]
)
if newCMAAnnotation == existingCMAAnnotation {
return false
}
// If the just-constructed node and the existing node do
// not have the same value, update the existing node with
// the correct value of the annotation.
if !newSet {
glog.Info("Controller attach-detach setting changed to false; updating existing Node")
delete(existingNode.Annotations, volumehelper.ControllerManagedAttachAnnotation)
} else {
glog.Info("Controller attach-detach setting changed to true; updating existing Node")
if existingNode.Annotations == nil {
existingNode.Annotations = make(map[string]string)
}
existingNode.Annotations[volumehelper.ControllerManagedAttachAnnotation] = newCMAAnnotation
}
return true
}