本文整理汇总了Golang中github.com/redhat-cip/skydive/logging.GetLogger函数的典型用法代码示例。如果您正苦于以下问题:Golang GetLogger函数的具体用法?Golang GetLogger怎么用?Golang GetLogger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetLogger函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: FLowsFromSFlowSample
func FLowsFromSFlowSample(ft *FlowTable, sample *layers.SFlowFlowSample, probePath string) []*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)
packet := &record.Header
key := (FlowKey{}).fillFromGoPacket(packet)
flow, _ := ft.GetFlow(key.String())
flow.ProbeGraphPath = probePath
flow.fillFromGoPacket(packet)
flows = append(flows, flow)
}
return flows
}
开发者ID:safchain,项目名称:skydive,代码行数:29,代码来源:flow.go
示例2: connect
func (probe *DockerProbe) connect() error {
var err error
logging.GetLogger().Debugf("Connecting to Docker daemon: %s", probe.url)
probe.client, err = dockerclient.NewDockerClient(probe.url, nil)
if err != nil {
logging.GetLogger().Errorf("Failed to connect to Docker daemon: %s", err.Error())
return err
}
eventsOptions := &dockerclient.MonitorEventsOptions{
Filters: &dockerclient.MonitorEventsFilters{
Events: []string{"start", "die"},
},
}
eventErrChan, err := probe.client.MonitorEvents(eventsOptions, nil)
if err != nil {
logging.GetLogger().Errorf("Unable to monitor Docker events: %s", err.Error())
return err
}
probe.wg.Add(2)
probe.quit = make(chan bool)
probe.connected.Store(true)
defer probe.connected.Store(false)
go func() {
defer probe.wg.Done()
containers, err := probe.client.ListContainers(false, false, "")
if err != nil {
logging.GetLogger().Errorf("Failed to list containers: %s", err.Error())
return
}
for _, c := range containers {
if atomic.LoadInt64(&probe.state) != RunningState {
break
}
probe.registerContainer(c.Id)
}
}()
defer probe.wg.Done()
for {
select {
case <-probe.quit:
return nil
case e := <-eventErrChan:
if e.Error != nil {
logging.GetLogger().Errorf("Got error while waiting for Docker event: %s", e.Error.Error())
return e.Error
}
probe.handleDockerEvent(&e.Event)
}
}
}
开发者ID:lebauce,项目名称:skydive,代码行数:60,代码来源:docker.go
示例3: SetMetadata
func (g GremlinBackend) SetMetadata(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().Error("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().Error("Gremlin query error: %s, %s", query, err.Error())
return false
}
return true
}
开发者ID:mestery,项目名称:skydive,代码行数:32,代码来源:gremlin.go
示例4: cacheUpdater
func (gfe *GraphFlowEnhancer) cacheUpdater() {
logging.GetLogger().Debug("Start GraphFlowEnhancer cache updater")
var mac string
for {
mac = <-gfe.cacheUpdaterChan
logging.GetLogger().Debug("GraphFlowEnhancer request received: %s", mac)
gfe.Graph.Lock()
intfs := gfe.Graph.LookupNodes(graph.Metadatas{"MAC": mac})
if len(intfs) > 1 {
logging.GetLogger().Info("GraphFlowEnhancer found more than one interface for the mac: %s", mac)
continue
}
if len(intfs) == 1 {
ancestors, ok := gfe.Graph.GetAncestorsTo(intfs[0], graph.Metadatas{"Type": "host"})
if ok {
var path string
for i := len(ancestors) - 1; i >= 0; i-- {
if len(path) > 0 {
path += "/"
}
name, _ := ancestors[i].Metadatas()["Name"]
path += name.(string)
}
gfe.cache.Set(mac, path, cache.DefaultExpiration)
}
}
gfe.Graph.Unlock()
}
}
开发者ID:mestery,项目名称:skydive,代码行数:35,代码来源:graph.go
示例5: 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().Debug("%s", string(m))
logging.GetLogger().Debug("%s", g.String())
onChange(ws)
}
return nil
}
开发者ID:mestery,项目名称:skydive,代码行数:26,代码来源:topology_test.go
示例6: AddEdge
func (g GremlinBackend) AddEdge(e *Edge) bool {
properties, err := toPropertiesString(e.graphElement)
if err != nil {
logging.GetLogger().Error("Error while adding a new Edge: %s", err.Error())
return false
}
propsParent, err := idToPropertiesString(e.parent)
if err != nil {
logging.GetLogger().Error("Error while adding a new Edge: %s", err.Error())
return false
}
propsChild, err := idToPropertiesString(e.child)
if err != nil {
logging.GetLogger().Error("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().Error("Error while adding a new Node: %s", err.Error())
return false
}
return true
}
开发者ID:mestery,项目名称:skydive,代码行数:29,代码来源:gremlin.go
示例7: Connect
func (c *GremlinClient) Connect() {
host := c.Addr + ":" + strconv.FormatInt(int64(c.Port), 10)
conn, err := net.Dial("tcp", host)
if err != nil {
logging.GetLogger().Error("Connection to the WebSocket server failed: %s", err.Error())
return
}
endpoint := "ws://" + host
u, err := url.Parse(endpoint)
if err != nil {
logging.GetLogger().Error("Unable to parse the WebSocket Endpoint %s: %s", endpoint, err.Error())
return
}
wsConn, _, err := websocket.NewClient(conn, u, http.Header{}, 0, 4096)
if err != nil {
logging.GetLogger().Error("Unable to create a WebSocket connection %s : %s", endpoint, err.Error())
return
}
logging.GetLogger().Info("Connected to gremlin server %s:%d", c.Addr, c.Port)
c.wsConn = wsConn
}
开发者ID:mestery,项目名称:skydive,代码行数:26,代码来源:client.go
示例8: 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:fdebonneval,项目名称:skydive,代码行数:26,代码来源:server.go
示例9: GetEdge
func (g GremlinBackend) GetEdge(i Identifier) *Edge {
properties, err := idToPropertiesString(i)
if err != nil {
logging.GetLogger().Error("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)
if parent == nil || child == nil {
return nil
}
edge.parent = parent.ID
edge.child = child.ID
return edge
}
开发者ID:mestery,项目名称:skydive,代码行数:34,代码来源:gremlin.go
示例10: start
func (u *NetNSTopoUpdater) start() {
runtime.LockOSThread()
defer runtime.UnlockOSThread()
watcher, err := inotify.NewWatcher()
if err != nil {
logging.GetLogger().Error("Unable to create a new Watcher: %s", err.Error())
return
}
err = watcher.Watch(runBaseDir)
if err != nil {
logging.GetLogger().Error("Unable to Watch %s: %s", runBaseDir, err.Error())
return
}
u.initialize()
for {
select {
case ev := <-watcher.Event:
if ev.Mask&inotify.IN_CREATE > 0 {
u.onNetNsCreated(ev.Name)
}
if ev.Mask&inotify.IN_DELETE > 0 {
u.onNetNsDeleted(ev.Name)
}
case err := <-watcher.Error:
logging.GetLogger().Error("Error while watching network namespace: %s", err.Error())
}
}
}
开发者ID:razorinc,项目名称:skydive,代码行数:32,代码来源:netns.go
示例11: FlowsFromSFlowSample
func FlowsFromSFlowSample(ft *Table, sample *layers.SFlowFlowSample, setter FlowProbePathSetter) []*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)
flow := FlowFromGoPacket(ft, &record.Header, setter)
if flow != nil {
flows = append(flows, flow)
}
}
return flows
}
开发者ID:fdebonneval,项目名称:skydive,代码行数:27,代码来源:flow.go
示例12: triggerResync
func (c *Forwarder) triggerResync() {
logging.GetLogger().Infof("Start a resync of the graph")
hostname, err := os.Hostname()
if err != nil {
logging.GetLogger().Errorf("Unable to retrieve the hostname: %s", err.Error())
return
}
c.Graph.Lock()
defer c.Graph.Unlock()
// request for deletion of everythin belonging to host node
root := c.Graph.GetNode(Identifier(hostname))
if root == nil {
return
}
c.Client.SendWSMessage(WSMessage{"SubGraphDeleted", root})
// re-added all the nodes and edges
nodes := c.Graph.GetNodes()
for _, n := range nodes {
c.Client.SendWSMessage(WSMessage{"NodeAdded", n})
}
edges := c.Graph.GetEdges()
for _, e := range edges {
c.Client.SendWSMessage(WSMessage{"EdgeAdded", e})
}
}
开发者ID:lebauce,项目名称:skydive,代码行数:30,代码来源:forwarder.go
示例13: Start
func (a *Agent) Start() {
var err error
go a.WSServer.ListenAndServe()
addr, port, err := config.GetAnalyzerClientAddr()
if err != nil {
logging.GetLogger().Errorf("Unable to parse analyzer client %s", err.Error())
os.Exit(1)
}
if addr != "" {
authOptions := &shttp.AuthenticationOpts{
Username: config.GetConfig().GetString("agent.analyzer_username"),
Password: config.GetConfig().GetString("agent.analyzer_password"),
}
authClient := shttp.NewAuthenticationClient(addr, port, authOptions)
a.WSClient, err = shttp.NewWSAsyncClient(addr, port, "/ws", authClient)
if err != nil {
logging.GetLogger().Errorf("Unable to instantiate analyzer client %s", err.Error())
os.Exit(1)
}
graph.NewForwarder(a.WSClient, a.Graph)
a.WSClient.Connect()
// send a first reset event to the analyzers
a.Graph.DelSubGraph(a.Root)
}
a.TopologyProbeBundle = tprobes.NewTopologyProbeBundleFromConfig(a.Graph, a.Root)
a.TopologyProbeBundle.Start()
a.FlowProbeBundle = fprobes.NewFlowProbeBundleFromConfig(a.TopologyProbeBundle, a.Graph)
a.FlowProbeBundle.Start()
if addr != "" {
a.EtcdClient, err = etcd.NewEtcdClientFromConfig()
if err != nil {
logging.GetLogger().Errorf("Unable to start etcd client %s", err.Error())
os.Exit(1)
}
captureHandler := &api.BasicApiHandler{
ResourceHandler: &api.CaptureHandler{},
EtcdKeyAPI: a.EtcdClient.KeysApi,
}
l, err := fprobes.NewOnDemandProbeListener(a.FlowProbeBundle, a.Graph, captureHandler)
if err != nil {
logging.GetLogger().Errorf("Unable to start on-demand flow probe %s", err.Error())
os.Exit(1)
}
a.OnDemandProbeListener = l
a.OnDemandProbeListener.Start()
}
go a.HTTPServer.ListenAndServe()
}
开发者ID:fdebonneval,项目名称:skydive,代码行数:59,代码来源:agent.go
示例14: NewFlowProbeBundleFromConfig
func NewFlowProbeBundleFromConfig(tb *probes.TopologyProbeBundle, g *graph.Graph) *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":
ofe := mappings.NewOvsFlowEnhancer(g)
pipeline := mappings.NewFlowMappingPipeline(gfe, ofe)
o := NewOvsSFlowProbesHandler(tb, g, pipeline, aclient)
if o != nil {
probes[t] = o
}
case "pcap":
pipeline := mappings.NewFlowMappingPipeline(gfe)
o := NewPcapProbesHandler(tb, g, pipeline, aclient)
if o != nil {
probes[t] = o
}
default:
logging.GetLogger().Errorf("unknown probe type %s", t)
}
}
p := probe.NewProbeBundle(probes)
return &FlowProbeBundle{
ProbeBundle: *p,
Graph: g,
}
}
开发者ID:lebauce,项目名称:skydive,代码行数:57,代码来源:probes.go
示例15: processGraphMessage
func (c *WSClient) processGraphMessage(m []byte) {
c.server.Graph.Lock()
defer c.server.Graph.Unlock()
msg, err := UnmarshalWSMessage(m)
if err != nil {
logging.GetLogger().Errorf("Graph: Unable to parse the event %s: %s", msg, err.Error())
return
}
g := c.server.Graph
switch msg.Type {
case "SyncRequest":
reply := WSMessage{
Type: "SyncReply",
Obj: c.server.Graph,
}
c.send <- []byte(reply.String())
case "SubGraphDeleted":
n := msg.Obj.(*Node)
logging.GetLogger().Debugf("Got SubGraphDeleted event from the node %s", n.ID)
node := g.GetNode(n.ID)
if node != nil {
g.DelSubGraph(node)
}
case "NodeUpdated":
n := msg.Obj.(*Node)
node := g.GetNode(n.ID)
if node != nil {
g.SetMetadata(node, n.metadata)
}
case "NodeDeleted":
g.DelNode(msg.Obj.(*Node))
case "NodeAdded":
n := msg.Obj.(*Node)
if g.GetNode(n.ID) == nil {
g.AddNode(n)
}
case "EdgeUpdated":
e := msg.Obj.(*Edge)
edge := g.GetEdge(e.ID)
if edge != nil {
g.SetMetadata(edge, e.metadata)
}
case "EdgeDeleted":
g.DelEdge(msg.Obj.(*Edge))
case "EdgeAdded":
e := msg.Obj.(*Edge)
if g.GetEdge(e.ID) == nil {
g.AddEdge(e)
}
}
}
开发者ID:lebauce,项目名称:skydive,代码行数:56,代码来源:server.go
示例16: 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:lebauce,项目名称:skydive,代码行数:56,代码来源:gremlin.go
示例17: onLinkAdded
func (u *NetLinkTopoUpdater) onLinkAdded(index int) {
logging.GetLogger().Debug("Link added: %d", index)
link, err := netlink.LinkByIndex(index)
if err != nil {
logging.GetLogger().Error("Failed to find interface %d: %s", index, err.Error())
return
}
u.addLinkToTopology(link)
}
开发者ID:razorinc,项目名称:skydive,代码行数:10,代码来源:netlink.go
示例18: registerProbe
func (o *OnDemandProbeListener) registerProbe(n *graph.Node, capture *api.Capture) {
fprobe := o.probeFromType(n)
if fprobe == nil {
logging.GetLogger().Errorf("Failed to register flow probe, unknown type")
return
}
if err := fprobe.RegisterProbe(n, capture); err != nil {
logging.GetLogger().Debugf("Failed to register flow probe: %s", err.Error())
}
}
开发者ID:lebauce,项目名称:skydive,代码行数:11,代码来源:ondemand.go
示例19: SendFlows
func (c *Client) SendFlows(flows []*flow.Flow) {
for _, flow := range flows {
j, _ := json.Marshal(flow)
logging.GetLogger().Debug("Sending to analyzer: %s", string(j))
err := c.SendFlow(flow)
if err != nil {
logging.GetLogger().Error("Unable to send flow: ", err.Error())
}
}
}
开发者ID:razorinc,项目名称:skydive,代码行数:11,代码来源:analyzer_client.go
示例20: cacheUpdater
func (mapper *NeutronMapper) cacheUpdater() {
logging.GetLogger().Debug("Start Neutron cache updater")
var mac string
for {
mac = <-mapper.cacheUpdaterChan
logging.GetLogger().Debug("Mac request received: %s", mac)
attrs := mapper.retrieveAttributes(mac)
mapper.cache.Set(mac, attrs, cache.DefaultExpiration)
}
}
开发者ID:mestery,项目名称:skydive,代码行数:13,代码来源:neutron.go
注:本文中的github.com/redhat-cip/skydive/logging.GetLogger函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论