本文整理汇总了Golang中github.com/skydive-project/skydive/logging.GetLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang GetLogger函数的具体用法?Golang GetLogger怎么用?Golang GetLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetLogger函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: startTopologyClient
func startTopologyClient(t *testing.T, g *graph.Graph, onReady func(*websocket.Conn), onChange func(*websocket.Conn)) error {
// ready when got a first ping
ws, err := connectToAgent(5, onReady)
if err != nil {
return err
}
for {
_, m, err := ws.ReadMessage()
if err != nil {
break
}
err = processGraphMessage(g, m)
if err != nil {
return err
}
logging.GetLogger().Debugf("%s", string(m))
logging.GetLogger().Debugf("%s", g.String())
onChange(ws)
}
return nil
}
开发者ID:skydive-project,项目名称:skydive,代码行数:26,代码来源:topology_test.go
示例2: FlowsFromSFlowSample
func FlowsFromSFlowSample(ft *Table, sample *layers.SFlowFlowSample, setter FlowProbeNodeSetter) []*Flow {
flows := []*Flow{}
for _, rec := range sample.Records {
/* FIX(safchain): just keeping the raw packet for now */
switch rec.(type) {
case layers.SFlowRawPacketFlowRecord:
/* We only support RawPacket from SFlow probe */
case layers.SFlowExtendedSwitchFlowRecord:
logging.GetLogger().Debug("1st layer is not SFlowRawPacketFlowRecord type")
continue
default:
logging.GetLogger().Critical("1st layer is not a SFlow supported type")
continue
}
record := rec.(layers.SFlowRawPacketFlowRecord)
goFlows := FlowsFromGoPacket(ft, &record.Header, int64(record.FrameLength), setter)
if goFlows != nil {
flows = append(flows, goFlows...)
}
}
return flows
}
开发者ID:nplanel,项目名称:skydive,代码行数:27,代码来源:flow.go
示例3: GetEdge
func (g GremlinBackend) GetEdge(i Identifier, t *time.Time) *Edge {
properties, err := idToPropertiesString(i)
if err != nil {
logging.GetLogger().Errorf("Error while retrieving a Node: %s", err.Error())
return nil
}
query := "g.E().has(" + properties + ")"
els, err := g.client.QueryElements(query)
if err != nil {
return nil
}
switch l := len(els); {
case l == 0:
return nil
case l > 1:
logging.GetLogger().Error("Found more than one edge for this ID: " + string(i))
return nil
}
edge := gremElementToEdge(els[0])
parent, child := g.GetEdgeNodes(edge, t)
if parent == nil || child == nil {
return nil
}
edge.parent = parent.ID
edge.child = child.ID
return edge
}
开发者ID:nplanel,项目名称:skydive,代码行数:34,代码来源:gremlin.go
示例4: SetStorageFromConfig
func (s *Server) SetStorageFromConfig() {
if t := config.GetConfig().GetString("analyzer.storage"); t != "" {
var (
err error
storage storage.Storage
)
switch t {
case "elasticsearch":
storage, err = elasticsearch.New()
if err != nil {
logging.GetLogger().Fatalf("Can't connect to ElasticSearch server: %v", err)
}
case "orientdb":
storage, err = orientdb.New()
if err != nil {
logging.GetLogger().Fatalf("Can't connect to OrientDB server: %v", err)
}
default:
logging.GetLogger().Fatalf("Storage type unknown: %s", t)
os.Exit(1)
}
s.SetStorage(storage)
logging.GetLogger().Infof("Using %s as storage", t)
}
}
开发者ID:nplanel,项目名称:skydive,代码行数:26,代码来源:server.go
示例5: getCaptureCount
func (c *CaptureApiHandler) getCaptureCount(r ApiResource) ApiResource {
capture := r.(*Capture)
tr := traversal.NewGremlinTraversalParser(strings.NewReader(capture.GremlinQuery), c.Graph)
ts, err := tr.Parse()
if err != nil {
logging.GetLogger().Errorf("Gremlin expression error: %s", err.Error())
return r
}
res, err := ts.Exec()
if err != nil {
logging.GetLogger().Errorf("Gremlin execution error: %s", err.Error())
return r
}
for _, value := range res.Values() {
switch value.(type) {
case *graph.Node:
n := value.(*graph.Node)
if common.IsCaptureAllowed(n.Metadata()["Type"].(string)) {
capture.Count = capture.Count + 1
}
case []*graph.Node:
capture.Count = capture.Count + len(value.([]*graph.Node))
default:
capture.Count = 0
}
}
return capture
}
开发者ID:nplanel,项目名称:skydive,代码行数:30,代码来源:capture.go
示例6: unregisterProbe
func (o *OnDemandProbeServer) unregisterProbe(n *graph.Node) bool {
if !o.isActive(n) {
return false
}
o.Lock()
c := o.captures[n.ID]
o.Unlock()
fprobe, err := o.getProbe(n, c)
if fprobe == nil {
if err != nil {
logging.GetLogger().Error(err.Error())
}
return false
}
if err := fprobe.UnregisterProbe(n); err != nil {
logging.GetLogger().Debugf("Failed to unregister flow probe: %s", err.Error())
}
o.Lock()
o.fta.Release(o.activeProbes[n.ID])
delete(o.activeProbes, n.ID)
delete(o.captures, n.ID)
o.Unlock()
return true
}
开发者ID:skydive-project,项目名称:skydive,代码行数:28,代码来源:server.go
示例7: lookupFlows
func (f *TableClient) lookupFlows(flowset chan *FlowSet, host string, flowSearchQuery *FlowSearchQuery) {
obj, _ := proto.Marshal(flowSearchQuery)
tq := TableQuery{
Type: "FlowSearchQuery",
Obj: obj,
}
msg := shttp.NewWSMessage(Namespace, "TableQuery", tq)
ch := make(chan *json.RawMessage)
defer close(ch)
f.replyChanMutex.Lock()
f.replyChan[msg.UUID] = ch
f.replyChanMutex.Unlock()
defer func() {
f.replyChanMutex.Lock()
delete(f.replyChan, msg.UUID)
f.replyChanMutex.Unlock()
}()
if !f.WSServer.SendWSMessageTo(msg, host) {
logging.GetLogger().Errorf("Unable to send message to agent: %s", host)
flowset <- NewFlowSet()
return
}
select {
case raw := <-ch:
var reply TableReply
if err := json.Unmarshal([]byte(*raw), &reply); err != nil {
logging.GetLogger().Errorf("Error returned while reading TableReply from: %s", host)
break
}
if reply.Status != http.StatusOK {
logging.GetLogger().Errorf("Error %d TableReply from: %s", reply.Status, host)
break
}
fs := NewFlowSet()
context := MergeContext{Sorted: flowSearchQuery.Sort, Dedup: flowSearchQuery.Dedup}
for _, b := range reply.Obj {
var fsr FlowSearchReply
if err := proto.Unmarshal(b, &fsr); err != nil {
logging.GetLogger().Errorf("Unable to decode flow search reply from: %s", host)
continue
}
fs.Merge(fsr.FlowSet, context)
}
flowset <- fs
return
case <-time.After(time.Second * 10):
logging.GetLogger().Errorf("Timeout while reading TableReply from: %s", host)
}
flowset <- NewFlowSet()
}
开发者ID:nplanel,项目名称:skydive,代码行数:60,代码来源:client.go
示例8: AddMetadata
func (g GremlinBackend) AddMetadata(i interface{}, k string, v interface{}) bool {
var e graphElement
var elType string
switch i.(type) {
case *Node:
e = i.(*Node).graphElement
elType = "V"
case *Edge:
e = i.(*Edge).graphElement
elType = "V"
}
properties, err := idToPropertiesString(e.ID)
if err != nil {
logging.GetLogger().Errorf("Error while retrieving a Node: %s", err.Error())
return false
}
encoder := gremlin.GremlinPropertiesEncoder{}
encoder.EncodeKVPair(k, v)
query := "g." + elType + "().has(" + properties + ").property(" + encoder.String() + ")"
_, err = g.client.Query(query)
if err != nil {
logging.GetLogger().Errorf("Gremlin query error: %s, %s", query, err.Error())
return false
}
return true
}
开发者ID:nplanel,项目名称:skydive,代码行数:32,代码来源:gremlin.go
示例9: nodeUpdater
func (mapper *NeutronMapper) nodeUpdater() {
logging.GetLogger().Debugf("Starting Neutron updater")
for nodeID := range mapper.nodeUpdaterChan {
node := mapper.graph.GetNode(nodeID)
if node == nil {
continue
}
if _, ok := node.Metadata()["MAC"]; !ok {
continue
}
portMd := retrievePortMetadata(node.Metadata())
attrs, err := mapper.retrieveAttributes(portMd)
if err != nil {
if nerr, ok := err.(NeutronPortNotFound); ok {
logging.GetLogger().Debugf("Setting in cache not found MAC %s", nerr.MAC)
mapper.cache.Set(nerr.MAC, PortMetadata{}, cache.DefaultExpiration)
} else {
logging.GetLogger().Errorf("Failed to retrieve attributes for port %s/%s : %v",
portMd.portID, portMd.mac, err)
}
continue
}
mapper.updateNode(node, attrs)
mapper.cache.Set(node.Metadata()["MAC"].(string), portMd, cache.DefaultExpiration)
}
logging.GetLogger().Debugf("Stopping Neutron updater")
}
开发者ID:skydive-project,项目名称:skydive,代码行数:30,代码来源:neutron.go
示例10: StoreFlows
func (c *OrientDBStorage) StoreFlows(flows []*flow.Flow) error {
// TODO: use batch of operations
for _, flow := range flows {
flowDoc, err := c.client.Upsert(flowToDocument(flow), "UUID")
if err != nil {
logging.GetLogger().Errorf("Error while pushing flow %s: %s\n", flow.UUID, err.Error())
return err
}
flowID, ok := flowDoc["@rid"]
if !ok {
logging.GetLogger().Errorf("No @rid attribute for flow '%s'", flow.UUID)
return err
}
if flow.LastUpdateMetric != nil {
doc := metricToDocument(flow.LastUpdateMetric)
doc["Flow"] = flowID
if _, err := c.client.CreateDocument(doc); err != nil {
logging.GetLogger().Errorf("Error while pushing metric %+v: %s\n", flow.LastUpdateMetric, err.Error())
continue
}
}
}
return nil
}
开发者ID:skydive-project,项目名称:skydive,代码行数:27,代码来源:orientdb.go
示例11: archiveElement
func (b *ElasticSearchBackend) archiveElement(kind string, id Identifier) bool {
resp, err := b.client.Get(kind, string(id))
if err != nil || !resp.Found {
return false
}
var obj map[string]interface{}
if err := json.Unmarshal([]byte(*resp.Source), &obj); err != nil {
return false
}
if _, err := b.client.Delete(kind, string(id)); err != nil {
logging.GetLogger().Errorf("Error while deleting %s %s: %s", kind, id, err.Error())
return false
}
obj["DeletedAt"] = time.Now().Unix()
obj["CreatedAt"] = int64(obj["CreatedAt"].(float64))
// Archive the element with a different ES id
if err := b.client.Index(kind, string(GenID()), obj); err != nil {
logging.GetLogger().Errorf("Error while deleting %s %s: %s", kind, id, err.Error())
return false
}
return true
}
开发者ID:skydive-project,项目名称:skydive,代码行数:27,代码来源:elasticsearch.go
示例12: registerProbe
func (o *OnDemandProbeListener) registerProbe(n *graph.Node, capture *api.Capture) bool {
o.Lock()
defer o.Unlock()
if _, ok := o.activeProbes[n.ID]; ok {
logging.GetLogger().Debugf("A probe already exists for %s", n.ID)
return false
}
if _, ok := n.Metadata()["Type"]; !ok {
logging.GetLogger().Infof("Do not register flow probe, type not supported %v", n)
return false
}
fprobe := o.getProbe(n, capture)
if fprobe == nil {
logging.GetLogger().Errorf("Failed to register flow probe, unknown type %v", n)
return false
}
ft := o.fta.Alloc(fprobe.AsyncFlowPipeline)
if err := fprobe.RegisterProbe(n, capture, ft); err != nil {
logging.GetLogger().Debugf("Failed to register flow probe: %s", err.Error())
o.fta.Release(ft)
return false
}
o.activeProbes[n.ID] = ft
o.captures[n.ID] = capture
logging.GetLogger().Debugf("New active probe on: %v", n)
return true
}
开发者ID:nplanel,项目名称:skydive,代码行数:33,代码来源:ondemand.go
示例13: matchGremlinExpr
func (o *OnDemandProbeClient) matchGremlinExpr(node *graph.Node, gremlin string) bool {
tr := traversal.NewGremlinTraversalParser(strings.NewReader(gremlin), o.graph)
ts, err := tr.Parse()
if err != nil {
logging.GetLogger().Errorf("Gremlin expression error: %s", err.Error())
return false
}
res, err := ts.Exec()
if err != nil {
logging.GetLogger().Errorf("Gremlin execution error: %s", err.Error())
return false
}
for _, value := range res.Values() {
n, ok := value.(*graph.Node)
if !ok {
logging.GetLogger().Error("Gremlin expression doesn't return node")
return false
}
if node.ID == n.ID {
return true
}
}
return false
}
开发者ID:skydive-project,项目名称:skydive,代码行数:28,代码来源:client.go
示例14: handleUDPFlowPacket
func (s *Server) handleUDPFlowPacket() {
s.conn.SetDeadline(time.Now().Add(200 * time.Millisecond))
data := make([]byte, 4096)
for s.running.Load() == true {
n, _, err := s.conn.ReadFromUDP(data)
if err != nil {
if err.(net.Error).Timeout() == true {
s.conn.SetDeadline(time.Now().Add(200 * time.Millisecond))
continue
}
if s.running.Load() == false {
return
}
logging.GetLogger().Errorf("Error while reading: %s", err.Error())
return
}
f, err := flow.FromData(data[0:n])
if err != nil {
logging.GetLogger().Errorf("Error while parsing flow: %s", err.Error())
}
s.AnalyzeFlows([]*flow.Flow{f})
}
}
开发者ID:nplanel,项目名称:skydive,代码行数:26,代码来源:server.go
示例15: AddEdge
func (g GremlinBackend) AddEdge(e *Edge) bool {
properties, err := toPropertiesString(e.graphElement)
if err != nil {
logging.GetLogger().Errorf("Error while adding a new Edge: %s", err.Error())
return false
}
propsParent, err := idToPropertiesString(e.parent)
if err != nil {
logging.GetLogger().Errorf("Error while adding a new Edge: %s", err.Error())
return false
}
propsChild, err := idToPropertiesString(e.child)
if err != nil {
logging.GetLogger().Errorf("Error while adding a new Edge: %s", err.Error())
return false
}
query := "g.V().has(" + propsParent + ").next()"
query += ".addEdge('linked', g.V().has(" + propsChild + ").next(), " + string(properties) + ")"
_, err = g.client.Query(query)
if err != nil {
logging.GetLogger().Errorf("Error while adding a new Node: %s", err.Error())
return false
}
return true
}
开发者ID:nplanel,项目名称:skydive,代码行数:29,代码来源:gremlin.go
示例16: Eval
func (s *Session) Eval(in string) error {
logging.GetLogger().Debugf("eval >>> %q", in)
for _, command := range commands {
if command.name == "g" && strings.HasPrefix(in, command.name) {
err := command.action(s, in)
if err != nil {
logging.GetLogger().Errorf("%s: %s", command.name, err)
}
return nil
}
arg := strings.TrimPrefix(in, ":"+command.name)
if arg == in {
continue
}
if arg == "" || strings.HasPrefix(arg, " ") {
arg = strings.TrimSpace(arg)
err := command.action(s, arg)
if err != nil {
if err == ErrQuit {
return err
}
logging.GetLogger().Errorf("%s: %s", command.name, err)
}
return nil
}
}
return nil
}
开发者ID:skydive-project,项目名称:skydive,代码行数:30,代码来源:shell.go
示例17: onVhostAdded
func (mapper *OpenContrailMapper) onVhostAdded(node *graph.Node, itf collection.Element) {
phyItf, err := itf.GetField("physical_interface")
if err != nil {
return
}
mapper.vHost = node
m := graph.Metadata{"Name": phyItf}
nodes := mapper.graph.LookupChildren(mapper.root, m, graph.Metadata{"RelationType": "ownership"})
switch {
case len(nodes) == 0:
logging.GetLogger().Errorf("Physical interface %s not found", phyItf)
return
case len(nodes) > 1:
logging.GetLogger().Errorf("Multiple physical interfaces found : %v", nodes)
return
}
mapper.linkToVhost(nodes[0])
for _, n := range mapper.pendingLinks {
mapper.linkToVhost(n)
}
mapper.pendingLinks = mapper.pendingLinks[:0]
mapper.graph.AddMetadata(nodes[0], "MPLSUDPPort", mapper.mplsUDPPort)
}
开发者ID:skydive-project,项目名称:skydive,代码行数:28,代码来源:opencontrail.go
示例18: injectPacket
func (pc *PacketInjectorClient) injectPacket(host string, pp *PacketParams, status chan *string) {
msg := shttp.NewWSMessage(Namespace, "InjectPacket", pp)
ch := make(chan *json.RawMessage)
defer close(ch)
pc.replyChanMutex.Lock()
pc.replyChan[msg.UUID] = ch
pc.replyChanMutex.Unlock()
defer func() {
pc.replyChanMutex.Lock()
delete(pc.replyChan, msg.UUID)
pc.replyChanMutex.Unlock()
}()
if !pc.WSServer.SendWSMessageTo(msg, host) {
e := fmt.Sprintf("Unable to send message to agent: %s", host)
logging.GetLogger().Errorf(e)
status <- &e
return
}
data := <-ch
var reply string
if err := json.Unmarshal([]byte(*data), &reply); err != nil {
e := fmt.Sprintf("Error while reading reply from: %s", host)
logging.GetLogger().Errorf(e)
status <- &e
return
}
status <- &reply
}
开发者ID:skydive-project,项目名称:skydive,代码行数:34,代码来源:client.go
示例19: NewFlowProbeBundleFromConfig
func NewFlowProbeBundleFromConfig(tb *probes.TopologyProbeBundle, g *graph.Graph, fta *flow.TableAllocator) *FlowProbeBundle {
list := config.GetConfig().GetStringSlice("agent.flow.probes")
logging.GetLogger().Infof("Flow probes: %v", list)
gfe := mappings.NewGraphFlowEnhancer(g)
var aclient *analyzer.Client
addr, port, err := config.GetAnalyzerClientAddr()
if err != nil {
logging.GetLogger().Errorf("Unable to parse analyzer client: %s", err.Error())
return nil
}
if addr != "" {
aclient, err = analyzer.NewClient(addr, port)
if err != nil {
logging.GetLogger().Errorf("Analyzer client error %s:%d : %s", addr, port, err.Error())
return nil
}
}
probes := make(map[string]probe.Probe)
for _, t := range list {
if _, ok := probes[t]; ok {
continue
}
switch t {
case "ovssflow":
o := NewOvsSFlowProbesHandler(tb, g)
if o != nil {
ofe := mappings.NewOvsFlowEnhancer(g)
pipeline := mappings.NewFlowMappingPipeline(gfe, ofe)
probes[t] = FlowProbe{fpi: o, pipeline: pipeline, client: aclient}
}
case "gopacket":
o := NewGoPacketProbesHandler(g)
if o != nil {
pipeline := mappings.NewFlowMappingPipeline(gfe)
gopacket := FlowProbe{fpi: o, pipeline: pipeline, client: aclient}
probes["afpacket"] = gopacket
probes["pcap"] = gopacket
}
default:
logging.GetLogger().Errorf("unknown probe type %s", t)
}
}
p := probe.NewProbeBundle(probes)
return &FlowProbeBundle{
ProbeBundle: *p,
Graph: g,
FlowTableAllocator: fta,
}
}
开发者ID:nplanel,项目名称:skydive,代码行数:59,代码来源:probes.go
示例20: SetMetadata
func (g GremlinBackend) SetMetadata(i interface{}, meta Metadata) bool {
var e graphElement
var elType string
switch i.(type) {
case *Node:
e = i.(*Node).graphElement
elType = "V"
case *Edge:
e = i.(*Edge).graphElement
elType = "V"
}
properties, err := idToPropertiesString(e.ID)
if err != nil {
logging.GetLogger().Errorf("Error while retrieving a Node: %s", err.Error())
return false
}
query := "g." + elType + "().has(" + properties + ")"
els, err := g.client.QueryElements(query)
if err != nil || len(els) == 0 {
return false
}
if len(els) > 1 {
logging.GetLogger().Errorf("Found more than one node for this ID: " + string(e.ID))
return false
}
el := els[0]
query = "g." + elType + "(" + string(el.ID) + ").properties().drop()"
_, err = g.client.Query(query)
if err != nil {
logging.GetLogger().Errorf("Gremlin query error: %s, %s", query, err.Error())
return false
}
j := meta.String()
query = "g." + elType + "(" + string(el.ID) + ")"
query += `.sideEffect{v = it; ["_ID": "` + string(e.ID) + `"`
query += `, "_host": "` + string(e.host) + `"`
query += `,` + j[1:len(j)-1] + `]`
query += `.each{v.get().property(it.key, it.value)}}`
_, err = g.client.Query(query)
if err != nil {
logging.GetLogger().Errorf("Gremlin query error: %s, %s", query, err.Error())
return false
}
return true
}
开发者ID:nplanel,项目名称:skydive,代码行数:56,代码来源:gremlin.go
注:本文中的github.com/skydive-project/skydive/logging.GetLogger函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论