Ejemplo n.º 1
0
//DebugEvent logs the event and the message local/remote to on debug level
func (client Client) DebugEvent(event *Event.Event, v ...interface{}) {
	if client.logLocal {
		client.localLogger.Debug(v)
	} else {
		client.Log(event, LogServer.NewDebugLogMessage(client.name, fmt.Sprint(v)))
	}
}
Ejemplo n.º 2
0
//NewClientOwnName creates a localClient or a RPC if a address is given and uses the given name as source
func NewClientOwnName(target, name string) (*Client, error) {
	if target == "" {
		//use local logger
		return NewLocalClient(), nil
	}
	logLocal := false
	logRPC := Outgoing.NewRPCInterface(target)
	if err := logRPC.Connect(); err != nil {
		fmt.Println(err)
		logLocal = true
	}

	var clientName string
	if name == "" {
		for name := range logRPC.Config.NameToCertificate {
			clientName = name
			break
		}
		if clientName == "" {
			var err error
			clientName, err = os.Hostname()
			if err != nil {
				return nil, err
			}
		}
	} else {
		clientName = name
	}
	err := logRPC.SendMessage(LogServer.NewDebugLogMessage(clientName, clientName+"-connected"))
	if err != nil {
		fmt.Println(err)
		logLocal = true
	}

	return &Client{logRPC: logRPC, name: clientName, localLogger: Local.GetLogger(), logLocal: logLocal}, nil
}