本文整理匯總了Golang中code/google/com/p/log4go.Warn函數的典型用法代碼示例。如果您正苦於以下問題:Golang Warn函數的具體用法?Golang Warn怎麽用?Golang Warn使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Warn函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: PermanentDeleteTeam
func PermanentDeleteTeam(c *Context, team *model.Team) *model.AppError {
l4g.Warn("Attempting to permanently delete team %v id=%v", team.Name, team.Id)
c.Path = "/teams/permanent_delete"
c.LogAuditWithUserId("", fmt.Sprintf("attempt teamId=%v", team.Id))
team.DeleteAt = model.GetMillis()
if result := <-Srv.Store.Team().Update(team); result.Err != nil {
return result.Err
}
if result := <-Srv.Store.User().GetForExport(team.Id); result.Err != nil {
return result.Err
} else {
users := result.Data.([]*model.User)
for _, user := range users {
PermanentDeleteUser(c, user)
}
}
if result := <-Srv.Store.Channel().PermanentDeleteByTeam(team.Id); result.Err != nil {
return result.Err
}
if result := <-Srv.Store.Team().PermanentDelete(team.Id); result.Err != nil {
return result.Err
}
l4g.Warn("Permanently deleted team %v id=%v", team.Name, team.Id)
c.LogAuditWithUserId("", fmt.Sprintf("success teamId=%v", team.Id))
return nil
}
示例2: RegisterTemp
// RegisterTmp create a ephemeral node, and watch it, if node droped then send a SIGQUIT to self.
func RegisterTemp(conn *zk.Conn, fpath string, data []byte) error {
tpath, err := conn.Create(path.Join(fpath)+"/", data, zk.FlagEphemeral|zk.FlagSequence, zk.WorldACL(zk.PermAll))
if err != nil {
log.Error("conn.Create(\"%s\", \"%s\", zk.FlagEphemeral|zk.FlagSequence) error(%v)", fpath, string(data), err)
return err
}
log.Debug("create a zookeeper node:%s", tpath)
// watch self
go func() {
for {
log.Info("zk path: \"%s\" set a watch", tpath)
exist, _, watch, err := conn.ExistsW(tpath)
if err != nil {
log.Error("zk.ExistsW(\"%s\") error(%v)", tpath, err)
log.Warn("zk path: \"%s\" set watch failed, kill itself", tpath)
killSelf()
return
}
if !exist {
log.Warn("zk path: \"%s\" not exist, kill itself", tpath)
killSelf()
return
}
event := <-watch
log.Info("zk path: \"%s\" receive a event %v", tpath, event)
}
}()
return nil
}
示例3: writeLoop
func (ctx *CommunicationContext) writeLoop() {
ctx.communicating.Add(1)
defer ctx.communicating.Done()
log4go.Debug("write loop started")
for ctx.isOpen {
tckt, ok := <-ctx.Output
if ok {
log4go.Debug("found new output in output channel")
err := ctx.sender.Send(tckt.msg)
if err != nil {
log4go.Warn("error while sending to device: %v", err.Error())
tckt.error <- err
} else {
tckt.isSend = true
tckt.send <- tckt.msg
}
} else {
log4go.Warn("output channel closed")
}
}
log4go.Debug("write loop finished")
}
示例4: watchCometNode
// watchNode watch a named node for leader selection when failover
func watchCometNode(conn *zk.Conn, node, fpath string, retry, ping time.Duration, ch chan *CometNodeEvent) {
fpath = path.Join(fpath, node)
for {
nodes, watch, err := myzk.GetNodesW(conn, fpath)
if err == myzk.ErrNodeNotExist {
log.Warn("zk don't have node \"%s\"", fpath)
break
} else if err == myzk.ErrNoChild {
log.Warn("zk don't have any children in \"%s\", retry in %d second", fpath, waitNodeDelay)
time.Sleep(waitNodeDelaySecond)
continue
} else if err != nil {
log.Error("zk path: \"%s\" getNodes error(%v), retry in %d second", fpath, err, waitNodeDelay)
time.Sleep(waitNodeDelaySecond)
continue
}
// leader selection
sort.Strings(nodes)
if info, err := registerCometNode(conn, nodes[0], fpath, retry, ping, true); err != nil {
log.Error("zk path: \"%s\" registerCometNode error(%v)", fpath, err)
time.Sleep(waitNodeDelaySecond)
continue
} else {
// update node info
ch <- &CometNodeEvent{Event: eventNodeUpdate, Key: node, Value: info}
}
// blocking receive event
event := <-watch
log.Info("zk path: \"%s\" receive a event: (%v)", fpath, event)
}
// WARN, if no persistence node and comet rpc not config
log.Warn("zk path: \"%s\" never watch again till recreate", fpath)
}
示例5: ScanPlugins
// Scaning path for finding plugins that contain files
// whith specific suffix
func ScanPlugins(path string, suffix string) []*Plugin {
var plugins []*Plugin
f, err := os.Open(path)
if err != nil {
log4go.Warn(err)
return nil
}
defer f.Close()
dirs, err := f.Readdirnames(-1)
if err != nil {
log4go.Warn(err)
return nil
}
for _, dir := range dirs {
dir2 := pt.Join(path, dir)
f2, err := os.Open(dir2)
if err != nil {
log4go.Warn(err)
continue
}
defer f2.Close()
fi, err := f2.Readdir(-1)
if err != nil {
continue
}
for _, f := range fi {
fn := f.Name()
if strings.HasSuffix(fn, suffix) {
plugins = append(plugins, NewPlugin(dir2, suffix))
break
}
}
}
return plugins
}
示例6: buildCachePath
func (p *Provider) buildCachePath() {
go func() {
fpath := "/rpc/" + p.Namespace + "/" + p.Version
for {
nodes, watch, err := zk.GetNodesW(p.ZkConn, fpath)
if err == zk.ErrNodeNotExist {
log.Warn("zk don't have node \"%s\", retry in %d second", fpath, waitNodeDelay)
time.Sleep(waitNodeDelaySecond)
continue
} else if err == zk.ErrNoChild {
log.Warn("zk don't have any children in \"%s\", retry in %d second", fpath, waitNodeDelay)
time.Sleep(waitNodeDelaySecond)
continue
} else if err != nil {
log.Error("getNodes error(%v), retry in %d second", err, waitNodeDelay)
time.Sleep(waitNodeDelaySecond)
continue
}
p.lock.Lock()
p.addes = nodes
p.lock.Unlock()
event := <-watch
log.Info("zk path: \"%s\" receive a event %v", fpath, event)
}
}()
}
示例7: Reset
func (device *AntUsbDevice) Reset() {
log4go.Debug("resetting usb hardware")
SEND_RESET:
// Hard reset device first
resetBuffer := []byte{
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00,
0x00, 0x00, 0x00}
_, err := device.Write(resetBuffer)
for err != nil {
log4go.Warn("error while writing reset bytes to usb device: %v", err.Error())
_, err = device.Write(resetBuffer)
}
buffer := make([]byte, 16)
// Read hard reset reply
_, err = device.Read(buffer)
for err != nil {
log4go.Warn("error while reading reset bytes reply from usb device: %v", err.Error())
goto SEND_RESET
}
}
示例8: GetConnectionStatus
// This method fetches the status of the IGD.
//
// Errors are indicated by the channel closing before a ConnectionStatus is
// returned. Listeners should therefore check at the very least for nil, better
// still for channel closure.
//
// NOTA BENE the channel closes after a successive ConnectionStatus has been
// send on it, in order to not leak resources.
func (self *IGD) GetConnectionStatus() (ret chan *ConnectionStatus) {
// We initialise the channel
ret = make(chan *ConnectionStatus)
// We go do the work in a separate goroutine, the closure has access to the
// channel we just instanciated so we will be able to manipulate it.
go func() {
x, ok := self.soapRequest("GetStatusInfo", statusRequestStringReader(self.upnptype))
if ok && strings.EqualFold(x.Body.Status.NewConnectionStatus, "Connected") {
y, ok := self.soapRequest("GetExternalIPAddress", externalIPRequestStringReader(self.upnptype))
if ok {
ipString := y.Body.IP.NewExternalIPAddress
ip := net.ParseIP(ipString)
if ip != nil {
ret <- &ConnectionStatus{true, ip}
return
} else {
l4g.Warn("Failed to parse IP string %v", ipString)
}
} else {
l4g.Warn("Failed to get IP address after estabilishing the connection was ok")
}
} else if ok && strings.EqualFold(x.Body.Status.NewConnectionStatus, "Disconnected") {
ret <- &ConnectionStatus{false, nil}
}
close(ret)
}()
// We immediately return the channel to the caller
return
}
示例9: scanpath
func scanpath(path string, m *py.Module) {
sys, err := py.Import("sys")
if err != nil {
log4go.Debug(err)
} else {
defer sys.Decref()
}
// This should probably be done by the Editor as it needs to scan through for themes, keybinding, settings etc
if f, err := os.Open(path); err != nil {
log4go.Warn(err)
} else {
defer f.Close()
if dirs, err := f.Readdirnames(-1); err != nil {
log4go.Warn(err)
} else {
for _, dir := range dirs {
if dir != "Vintageous" && dir != "Default" && dir != "plugins" {
// TODO obviously
continue
}
dir2 := path + dir
if f2, err := os.Open(dir2); err != nil {
log4go.Warn(err)
} else {
defer f2.Close()
if fi, err := f2.Readdir(-1); err != nil {
log4go.Warn(err)
} else {
for _, f := range fi {
if fn := f.Name(); strings.HasSuffix(fn, ".py") {
//m.Incref()
if s, err := py.NewUnicode(dir + "." + fn[:len(fn)-3]); err != nil {
log4go.Error(err)
} else {
if r, err := m.Base().CallMethodObjArgs("reload_plugin", s); err != nil {
log4go.Error(err)
} else if r != nil {
r.Decref()
}
// if i, err := sys.Base().CallMethodObjArgs("getrefcount", s); err != nil {
// log4go.Error(err)
// } else {
// log4go.Debug("m refs: %d", i.(*py.Long).Int64())
// i.Decref()
// }
}
}
}
}
}
}
}
}
}
示例10: Execute
func (node MenuNode) Execute(ivrChannel *IVRChannel) (string, error) {
if ivrChannel.ChannelState == IVRChannel_State_Hangup {
return "", errors.New("channel state is invalid : hangup")
}
ivrChannel.ActiveNode = node.NodeName
// Clear dtmf channel value.
for len(ivrChannel.Dtmf) > 0 {
<-ivrChannel.Dtmf
}
executePrompt(node.Prompts.Prompt, ivrChannel)
/*
if len(node.Prompts.Prompt) > 0 {
for _, promptName := range node.Prompts.Prompt {
// Find prompt from ivrPromptMap by promptName
if prompt, ok := ivrPromptMap[promptName]; ok {
executePrompt(prompt, ivrChannel)
<-ivrChannel.PlaybackDone
} else {
l4g.Warn("Prompt not find for promptName=%s", promptName)
}
}
}
*/
ivrChannel.Esocket.StartDTMF()
defer ivrChannel.Esocket.StopDTMF()
// Wait dtmf input.
timeout := eventsocket.CheckTimeout(node.Timeout)
select {
case <-timeout:
l4g.Warn("Timeout,no dtmf.")
ivrChannel.NoInputTimes = ivrChannel.NoInputTimes + 1
return node.NoInput, nil
case dtmf := <-ivrChannel.Dtmf:
for _, choice := range node.Choices.Choice {
if dtmf == choice.DTMF {
return choice.NextNode, nil
}
}
l4g.Warn("No match for dtmf=%s", dtmf)
ivrChannel.NoMatchTimes = ivrChannel.NoMatchTimes + 1
return node.NoMatch, nil
case <-ivrChannel.ChannelHangup:
l4g.Trace("Channel hangup.")
return "", errors.New("Channel hangup.")
}
}
示例11: watchMessageRoot
// watchMessageRoot watch the message root path.
func watchMessageRoot(conn *zk.Conn, fpath string, ch chan *MessageNodeEvent) error {
for {
nodes, watch, err := myzk.GetNodesW(conn, fpath)
if err == myzk.ErrNodeNotExist {
log.Warn("zk don't have node \"%s\", retry in %d second", fpath, waitNodeDelay)
time.Sleep(waitNodeDelaySecond)
continue
} else if err == myzk.ErrNoChild {
log.Warn("zk don't have any children in \"%s\", retry in %d second", fpath, waitNodeDelay)
// all child died, kick all the nodes
for _, client := range MessageRPC.Clients {
log.Debug("node: \"%s\" send del node event", client.Addr)
ch <- &MessageNodeEvent{Event: eventNodeDel, Key: &WeightRpc{Addr: client.Addr, Weight: client.Weight}}
}
time.Sleep(waitNodeDelaySecond)
continue
} else if err != nil {
log.Error("getNodes error(%v), retry in %d second", err, waitNodeDelay)
time.Sleep(waitNodeDelaySecond)
continue
}
nodesMap := map[string]bool{}
// handle new add nodes
for _, node := range nodes {
data, _, err := conn.Get(path.Join(fpath, node))
if err != nil {
log.Error("zk.Get(\"%s\") error(%v)", path.Join(fpath, node), err)
continue
}
// parse message node info
nodeInfo := &MessageNodeInfo{}
if err := json.Unmarshal(data, nodeInfo); err != nil {
log.Error("json.Unmarshal(\"%s\", nodeInfo) error(%v)", string(data), err)
continue
}
for _, addr := range nodeInfo.Rpc {
// if not exists in old map then trigger a add event
if _, ok := MessageRPC.Clients[addr]; !ok {
ch <- &MessageNodeEvent{Event: eventNodeAdd, Key: &WeightRpc{Addr: addr, Weight: nodeInfo.Weight}}
}
nodesMap[addr] = true
}
}
// handle delete nodes
for _, client := range MessageRPC.Clients {
if _, ok := nodesMap[client.Addr]; !ok {
ch <- &MessageNodeEvent{Event: eventNodeDel, Key: client}
}
}
// blocking wait node changed
event := <-watch
log.Info("zk path: \"%s\" receive a event %v", fpath, event)
}
}
示例12: query
func query(projectName string, statement string, params []interface{}, callback func(rows *sql.Rows) interface{}) ([]interface{}, error) {
databaseId, err := getDatabaseId(projectName)
if err != nil {
logger.Error(err)
return nil, err
}
projectDbFile := fmt.Sprintf("./db/%d.db", databaseId)
if _, err := os.Stat(projectDbFile); err != nil {
if os.IsNotExist(err) {
logger.Warn("create project table.")
CreateProjectTables(projectName, databaseId)
logger.Warn("created project table.")
}
}
db, err := sql.Open("sqlite3", projectDbFile)
if err != nil {
logger.Error(err)
return nil, err
}
defer db.Close()
logger.Debug("sql: %s", statement)
stmt, err := db.Prepare(statement)
if err != nil {
logger.Error(err)
return nil, err
}
defer stmt.Close()
//execute `rows, err := stmt.Query(arg1, arg2, ...)` by reflect
values := []reflect.Value{}
for _, p := range params {
logger.Debug("[%s]", p)
values = append(values, reflect.ValueOf(p))
}
returnValues := reflect.ValueOf(stmt).MethodByName("Query").Call(values)
rows := returnValues[0].Interface().(*sql.Rows)
if !returnValues[1].IsNil() {
err = returnValues[1].Interface().(error)
}
if err != nil {
logger.Error(err)
return nil, err
}
defer rows.Close()
results := []interface{}{}
for rows.Next() {
results = append(results, callback(rows))
}
rows.Close()
return results, nil
}
示例13: drainresults
// drainresults loops, printing the address of nodes it has found.
func drainresults(n *dht.DHT) {
fmt.Println("=========================== DHT")
l4g.Warn("Note that there are many bad nodes that reply to anything you ask.")
l4g.Warn("Peers found:")
for r := range n.PeersRequestResults {
for _, peers := range r {
for _, x := range peers {
l4g.Warn("%v", dht.DecodePeerAddress(x))
}
}
}
}
示例14: Cache
func (p *Pattern) Cache(data string, pos int) (pat *Pattern, ret MatchObject) {
if p.cachedData == data {
if p.cachedMatch == nil {
return nil, nil
}
if p.cachedMatch[0] >= pos && p.cachedPat.cachedMatch != nil {
p.hits++
return p.cachedPat, p.cachedMatch
}
} else {
p.cachedPatterns = nil
}
if p.cachedPatterns == nil {
p.cachedPatterns = make([]*Pattern, len(p.Patterns))
for i := range p.cachedPatterns {
p.cachedPatterns[i] = &p.Patterns[i]
}
}
p.misses++
if p.Match.re != nil {
pat, ret = p, p.Match.Find(data, pos)
} else if p.Begin.re != nil {
pat, ret = p, p.Begin.Find(data, pos)
} else if p.Include != "" {
if z := p.Include[0]; z == '#' {
key := p.Include[1:]
if p2, ok := p.owner.Repository[key]; ok {
pat, ret = p2.Cache(data, pos)
} else {
log4go.Fine("Not found in repository: %s", p.Include)
}
} else if z == '$' {
// TODO(q): Implement tmLanguage $ include directives
log4go.Warn("Unhandled include directive: %s", p.Include)
} else if l, err := Provider.GetLanguage(p.Include); err != nil {
if !failed[p.Include] {
log4go.Warn("Include directive %s failed: %s", p.Include, err)
}
failed[p.Include] = true
} else {
return l.RootPattern.Cache(data, pos)
}
} else {
pat, ret = p.FirstMatch(data, pos)
}
p.cachedData = data
p.cachedMatch = ret
p.cachedPat = pat
return
}
示例15: PermanentDeleteUser
func PermanentDeleteUser(c *Context, user *model.User) *model.AppError {
l4g.Warn("Attempting to permanently delete account %v id=%v", user.Email, user.Id)
c.Path = "/users/permanent_delete"
c.LogAuditWithUserId(user.Id, fmt.Sprintf("attempt userId=%v", user.Id))
c.LogAuditWithUserId("", fmt.Sprintf("attempt userId=%v", user.Id))
if user.IsInRole(model.ROLE_SYSTEM_ADMIN) {
l4g.Warn("You are deleting %v that is a system administrator. You may need to set another account as the system administrator using the command line tools.", user.Email)
}
UpdateActive(c, user, false)
if result := <-Srv.Store.Session().PermanentDeleteSessionsByUser(user.Id); result.Err != nil {
return result.Err
}
if result := <-Srv.Store.OAuth().PermanentDeleteAuthDataByUser(user.Id); result.Err != nil {
return result.Err
}
if result := <-Srv.Store.Webhook().PermanentDeleteIncomingByUser(user.Id); result.Err != nil {
return result.Err
}
if result := <-Srv.Store.Webhook().PermanentDeleteOutgoingByUser(user.Id); result.Err != nil {
return result.Err
}
if result := <-Srv.Store.Preference().PermanentDeleteByUser(user.Id); result.Err != nil {
return result.Err
}
if result := <-Srv.Store.Channel().PermanentDeleteMembersByUser(user.Id); result.Err != nil {
return result.Err
}
if result := <-Srv.Store.Post().PermanentDeleteByUser(user.Id); result.Err != nil {
return result.Err
}
if result := <-Srv.Store.User().PermanentDelete(user.Id); result.Err != nil {
return result.Err
}
if result := <-Srv.Store.Audit().PermanentDeleteByUser(user.Id); result.Err != nil {
return result.Err
}
l4g.Warn("Permanently deleted account %v id=%v", user.Email, user.Id)
c.LogAuditWithUserId("", fmt.Sprintf("success userId=%v", user.Id))
return nil
}