本文整理汇总了Golang中code/google/com/p/log4go.Info函数的典型用法代码示例。如果您正苦于以下问题:Golang Info函数的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RecoverServerFromRequestNumber
// In the case where this server is running and another one in the cluster stops responding, at some point this server will have to just write
// requests to disk. When the downed server comes back up, it's this server's responsibility to send out any writes that were queued up. If
// the yield function returns nil then the request is committed.
func (self *WAL) RecoverServerFromRequestNumber(requestNumber uint32, shardIds []uint32, yield func(request *protocol.Request, shardId uint32) error) error {
var firstLogFile int
state := self.logFiles[len(self.logFiles)-1].state
outer:
for _, logFile := range self.logFiles[firstLogFile:] {
logger.Info("Replaying from %s", logFile.file.Name())
count := 0
ch, stopChan := logFile.replayFromRequestNumber(shardIds, requestNumber, state)
for {
x := <-ch
if x == nil {
logger.Info("%s yielded %d requests", logFile.file.Name(), count)
continue outer
}
if x.err != nil {
return x.err
}
if err := yield(x.request, x.shardId); err != nil {
stopChan <- struct{}{}
return err
}
count++
}
close(stopChan)
}
return nil
}
示例2: postnetwork
func postnetwork(container *global.Container, ip string) {
gulpPort, _ := config.GetInt("docker:gulp_port")
url := "http://" + container.SwarmNode + ":" + strconv.Itoa(gulpPort) + "/docker/networks"
log.Info("URL:> %s", url)
bridge, _ := config.GetString("docker:bridge")
gateway, _ := config.GetString("docker:gateway")
data := &global.DockerNetworksInfo{Bridge: bridge, ContainerId: container.ContainerID, IpAddr: ip, Gateway: gateway}
res2B, _ := json.Marshal(data)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(res2B))
req.Header.Set("X-Custom-Header", "myvalue")
req.Header.Set("Content-Type", "application/json")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
log.Error("gulpd client was failed : %s", err)
}
defer resp.Body.Close()
log.Info("response Status : %s", resp.Status)
log.Info("response Headers : %s", resp.Header)
body, _ := ioutil.ReadAll(resp.Body)
log.Info("response Body : %s", string(body))
}
示例3: migrateDir
func (dm *DataMigrator) migrateDir(name string) {
migrateMarkerFile := filepath.Join(dm.shardDir(name), MIGRATED_MARKER)
if _, err := os.Stat(migrateMarkerFile); err == nil {
log.Info("Already migrated %s. Skipping", name)
return
}
log.Info("Migrating %s", name)
shard, err := dm.getShard(name)
if err != nil {
log.Error("Migration error getting shard: %s", err.Error())
return
}
defer shard.Close()
databases := dm.clusterConfig.GetDatabases()
for _, database := range databases {
err := dm.migrateDatabaseInShard(database.Name, shard)
if err != nil {
log.Error("Error migrating database %s: %s", database.Name, err.Error())
return
}
}
err = ioutil.WriteFile(migrateMarkerFile, []byte("done.\n"), 0644)
if err != nil {
log.Error("Problem writing migration marker for shard %s: %s", name, err.Error())
}
}
示例4: Checker
func (self *Server) Checker() {
log.Info("verifying rabbitmq")
factor, err := amqp.Factory()
if err != nil {
log.Error("Error: %v\nFailed to get the queue", err)
}
_, connerr := factor.Dial()
if connerr != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n Please start rabbitmq service.\n", connerr)
os.Exit(1)
}
log.Info("rabbitmq connected [ok]")
log.Info("verifying riak")
rconn, rerr := db.Conn("connection")
if rerr != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n Please start Riak service.\n", rerr)
os.Exit(1)
}
data := "sampledata"
ferr := rconn.StoreObject("sampleobject", data)
if ferr != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n Please start Riak service.\n", ferr)
os.Exit(1)
}
defer rconn.Close()
log.Info("riak connected [ok]")
}
示例5: AddPotentialServer
func (self *ClusterConfiguration) AddPotentialServer(server *ClusterServer) {
self.serversLock.Lock()
defer self.serversLock.Unlock()
server.State = Potential
self.servers = append(self.servers, server)
server.Id = uint32(len(self.servers))
log.Info("Added server to cluster config: %d, %s, %s", server.Id, server.RaftConnectionString, server.ProtobufConnectionString)
log.Info("Checking whether this is the local server new: %s, local: %s\n", self.config.ProtobufConnectionString(), server.ProtobufConnectionString)
if server.RaftName != self.LocalRaftName {
log.Info("Connecting to ProtobufServer: %s", server.ProtobufConnectionString, self.config.ProtobufConnectionString())
if server.connection == nil {
server.connection = self.connectionCreator(server.ProtobufConnectionString)
server.Connect()
}
writeBuffer := NewWriteBuffer(fmt.Sprintf("%d", server.GetId()), server, self.wal, server.Id, self.config.PerServerWriteBufferSize)
self.writeBuffers = append(self.writeBuffers, writeBuffer)
server.SetWriteBuffer(writeBuffer)
server.StartHeartbeat()
} else if !self.addedLocalServer {
log.Info("Added the local server")
self.LocalServerId = server.Id
self.addedLocalServerWait <- true
self.addedLocalServer = true
}
}
示例6: cmdStoreRun
func cmdStoreRun(args []string) error {
if *cpu < 1 {
*cpu = runtime.NumCPU()
}
runtime.GOMAXPROCS(*cpu)
log4go.Info("configuration path: %s", *storeConfPath)
log4go.Info("volume path: %s", *volumeDir)
if _, err := os.Stat(*storeConfPath); err != nil {
if os.IsNotExist(err) {
if err = os.MkdirAll(*storeConfPath, os.ModePerm); err != nil {
return err
}
if err = ioutil.WriteFile(filepath.Join(*storeConfPath, "rabbitfs.conf.json"), []byte(defaultConfig), os.ModePerm); err != nil {
return err
}
} else {
return err
}
}
httpAddr := fmt.Sprintf("%s:%d", *storeIP, *storePort)
store, err := server.NewStoreServer(
*storeConfPath,
*volumeDir,
float32(*garbageThreshold),
httpAddr,
time.Duration((*storeTimeout))*time.Millisecond,
)
if err != nil {
return err
}
store.ListenAndServe()
return nil
}
示例7: RecoverServerFromRequestNumber
// In the case where this server is running and another one in the
// cluster stops responding, at some point this server will have to
// just write requests to disk. When the downed server comes back up,
// it's this server's responsibility to send out any writes that were
// queued up. If the yield function returns nil then the request is
// committed.
func (self *WAL) RecoverServerFromRequestNumber(requestNumber uint32, shardIds []uint32, yield func(request *protocol.Request, shardId uint32) error) error {
// don't replay if we don't have any log files yet
if len(self.logFiles) == 0 {
return nil
}
firstIndex := 0
firstOffset := int64(-1)
// find the log file from which replay will start if the request
// number is in range, otherwise replay from all log files
if !self.isInRange(requestNumber) {
return nil
}
for idx, logIndex := range self.logIndex {
logger.Debug("Trying to find request %d in %s", requestNumber, self.logFiles[idx].file.Name())
if firstOffset = logIndex.requestOffset(requestNumber); firstOffset != -1 {
logger.Debug("Found reqeust %d in %s at offset %d", requestNumber, self.logFiles[idx].file.Name(), firstOffset)
firstIndex = idx
break
}
}
// the request must be at the end of the current log file
if firstOffset == -1 {
firstIndex = len(self.logIndex) - 1
firstOffset = self.logIndex[firstIndex].requestOrLastOffset(requestNumber)
}
outer:
for idx := firstIndex; idx < len(self.logFiles); idx++ {
logFile := self.logFiles[idx]
if idx > firstIndex {
firstOffset = -1
}
logger.Info("Replaying from %s:%d", logFile.file.Name(), firstOffset)
count := 0
ch, stopChan := logFile.dupAndReplayFromOffset(shardIds, firstOffset, requestNumber)
for {
x := <-ch
if x == nil {
logger.Info("%s yielded %d requests", logFile.file.Name(), count)
continue outer
}
if x.err != nil {
return x.err
}
logger.Debug("Yielding request %d", x.request.GetRequestNumber())
if err := yield(x.request, x.shardId); err != nil {
logger.Debug("Stopping replay due to error: %s", err)
stopChan <- struct{}{}
return err
}
count++
}
close(stopChan)
}
return nil
}
示例8: psync
// psync command
func psync() {
runid, offset := initRedisRepilcationInfo()
log.Info("psync cmd starting ...")
cmd := NewStringCmd("PSYNC", runid, offset)
addr := fmt.Sprintf("%s:%s", Conf.RedisMasterIP, Conf.RedisMasterPort)
cn, err := net.DialTimeout("tcp", addr, time.Minute*30)
if err != nil {
log.Error("connect master error : %s", err)
} else {
log.Info("connect redis master : %s", addr)
}
time.Sleep(time.Second * 5)
// init runid offset
conn := &conn{
netcn: cn,
buf: make([]byte, 1024*1024*32),
runid: runid,
offset: offset,
}
conn.rd = bufio.NewReader(conn)
conn.WriteTimeout = time.Minute * 30
conn.ReadTimeout = time.Minute * 30
redisAuth(conn)
sync(cmd, conn)
}
示例9: delta
func delta(val interface{}) {
if val == nil {
log.Warn("redis master delta command is nil")
return
}
log.Info("redis master delta command is %s", val)
switch vv := val.(type) {
case []interface{}:
if vstring, ok := vv[0].(string); ok {
if strings.ToLower(vstring) == "ping" {
replAck <- true
return
} else if strings.ToLower(vstring) == "publish" && len(vv) > 1 { //"PUBLISH","__sentinel__
if sentinel, ok := vv[1].(string); ok {
if strings.HasPrefix(sentinel, "__sentinel__") {
log.Info("publish sentinel info")
return
}
}
}
}
}
newEvent(val)
}
示例10: fullsync
// sync command
func fullsync() {
log.Info("full sync cmd starting ...")
cmd := NewStringCmd("SYNC")
// cmd := NewStringCmd("PSYNC", "?", -1)
addr := fmt.Sprintf("%s:%s", Conf.RedisMasterIP, Conf.RedisMasterPort)
cn, err := net.DialTimeout("tcp", addr, time.Minute*30)
if err != nil {
log.Error("connect master error : %s", err)
} else {
log.Info("connect redis master : %s", addr)
}
time.Sleep(time.Second * 5)
conn := &conn{
netcn: cn,
buf: make([]byte, 1024*1024*32),
}
conn.rd = bufio.NewReader(conn)
conn.WriteTimeout = time.Minute * 30
conn.ReadTimeout = time.Minute * 30
redisAuth(conn)
sync(cmd, conn)
}
示例11: ListenAndServe
func (self *Server) ListenAndServe() error {
go self.ProtobufServer.ListenAndServe()
err := self.RaftServer.ListenAndServe()
if err != nil {
return err
}
log.Info("Waiting for local server to be added")
self.ClusterConfig.WaitForLocalServerLoaded()
self.writeLog.SetServerId(self.ClusterConfig.ServerId())
log.Info("Recovering from log...")
err = self.ClusterConfig.RecoverFromWAL()
if err != nil {
return err
}
log.Info("recovered")
err = self.Coordinator.(*coordinator.CoordinatorImpl).ConnectToProtobufServers(self.Config.ProtobufConnectionString())
if err != nil {
return err
}
log.Info("Starting admin interface on port %d", self.Config.AdminHttpPort)
go self.AdminServer.ListenAndServe()
log.Info("Starting Http Api server on port %d", self.Config.ApiHttpPort)
self.HttpApi.ListenAndServe()
return nil
}
示例12: main
func main() {
l4g.Info("Process ID: %d", os.Getpid())
usage := `
Usage:
napoleon run <path_location>
napoleon -h | --help
napoleon -v | --version
Options:
-h --help Show this screen.
-v --version Show version.`
options, _ := docopt.Parse(usage, nil, true, "1.0.2", false)
l4g.Debug(options)
c := make(<-chan int)
if options["run"].(bool) {
c = consumer(producer(options))
}
<-c
time.Sleep(time.Millisecond)
l4g.Info("napoleon stopped")
}
示例13: startRaft
func (s *RaftServer) startRaft() error {
log.Info("Initializing Raft Server: %s", s.config.RaftConnectionString())
// Initialize and start Raft server.
transporter := raft.NewHTTPTransporter("/raft")
var err error
s.raftServer, err = raft.NewServer(s.name, s.path, transporter, s.clusterConfig, s.clusterConfig, "")
if err != nil {
return err
}
s.raftServer.SetElectionTimeout(s.config.RaftTimeout.Duration)
s.raftServer.LoadSnapshot() // ignore errors
s.raftServer.AddEventListener(raft.StateChangeEventType, s.raftEventHandler)
transporter.Install(s.raftServer, s)
s.raftServer.Start()
go s.CompactLog()
if !s.raftServer.IsLogEmpty() {
log.Info("Recovered from log")
return nil
}
potentialLeaders := s.config.SeedServers
if len(potentialLeaders) == 0 {
log.Info("Starting as new Raft leader...")
name := s.raftServer.Name()
_, err := s.raftServer.Do(&InfluxJoinCommand{
Name: name,
ConnectionString: s.config.RaftConnectionString(),
ProtobufConnectionString: s.config.ProtobufConnectionString(),
})
if err != nil {
log.Error(err)
}
err = s.CreateRootUser()
return err
}
for {
for _, leader := range potentialLeaders {
log.Info("(raft:%s) Attempting to join leader: %s", s.raftServer.Name(), leader)
if err := s.Join(leader); err == nil {
log.Info("Joined: %s", leader)
return nil
}
}
log.Warn("Couldn't join any of the seeds, sleeping and retrying...")
time.Sleep(100 * time.Millisecond)
}
return nil
}
示例14: main
func main() {
var err error
// Parse cmd-line arguments
flag.Parse()
log.Info("web ver: \"%s\" start", ver.Version)
if err = InitConfig(); err != nil {
panic(err)
}
// Set max routine
runtime.GOMAXPROCS(Conf.MaxProc)
// init log
log.LoadConfiguration(Conf.Log)
defer log.Close()
// init zookeeper
zkConn, err := InitZK()
if err != nil {
if zkConn != nil {
zkConn.Close()
}
panic(err)
}
// start pprof http
perf.Init(Conf.PprofBind)
// start http listen.
StartHTTP()
// process init
if err = process.Init(Conf.User, Conf.Dir, Conf.PidFile); err != nil {
panic(err)
}
// init signals, block wait signals
signalCH := InitSignal()
HandleSignal(signalCH)
log.Info("web stop")
}
示例15: work
/*
* work - 处理单个任务
*
* PARAMS:
* - job : 一个待处理任务
*
*/
func (s *Spider) work(job Job) {
defer s.wg.Done()
// 检查是否访问过
if s.visitedUrl[job.url] {
l4g.Info("visted job,continue. url:%s, depth:%d", job.url, job.depth)
return
}
// 判断是否超出最大爬取深度
if job.depth > s.maxDepth {
l4g.Info("visted job,continue. url:%s, depth:%d", job.url, job.depth)
return
}
// 标记为访问过
s.visitedUrl[job.url] = true
resp, err := http.Get(job.url)
if err != nil {
l4g.Error("Failed to crawl %s, err[%s]", job.url, err)
return
} else {
//l4g.Info("http response:%s", resp)
}
defer resp.Body.Close()
// 解析Html, 获取新的url并入任务队列
urls := s.parseHtml(resp.Body, job)
for _, url := range urls {
//新任务入公共队列
s.wg.Add(1)
s.addJob(Job{url, job.depth + 1})
l4g.Info("add job: %s, depth:%d", url, job.depth+1)
}
}