本文整理匯總了Golang中github.com/cihub/seelog.Flush函數的典型用法代碼示例。如果您正苦於以下問題:Golang Flush函數的具體用法?Golang Flush怎麽用?Golang Flush使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Flush函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: New
func New(endpoint []string, path string) *opt {
cfg := client.Config{
Endpoints: endpoint,
Transport: client.DefaultTransport,
HeaderTimeoutPerRequest: time.Second,
}
etcdClient, err := client.New(cfg)
if err != nil {
log.Errorf("new etcd client error: ", err)
log.Flush()
panic(0)
}
api := client.NewKeysAPI(etcdClient)
resp, err := api.Get(context.Background(), "/swarm/docker/swarm/leader", nil)
if err != nil {
log.Errorf("get swarm leader error: %v", err)
log.Flush()
panic(0)
}
return &opt{
Client: etcdClient,
Endpoint: endpoint,
Path: path,
Api: api,
Leader: fmt.Sprintf("http://%s", resp.Node.Value),
}
}
示例2: read_to_chan
func (fr *TrecFileReader) read_to_chan(count int) (i int) {
//Catch and log panics
defer func() {
if x := recover(); x != nil {
log.Criticalf("Error in document %d of %s: %v", fr.docCounter, fr.filename, x)
log.Flush()
}
}()
for i := 0; i < count || count == -1; i++ {
log.Debugf("Reading document %d from %s", i, fr.filename)
doc, err := fr.read_next_doc()
switch err {
case io.EOF:
log.Debugf("Got EOF for file %s", fr.filename)
close(fr.documents)
return i
case nil:
log.Debugf("Successfully read document %s", doc.Identifier())
fr.documents <- doc
default:
log.Criticalf("Oh fuck...%v", err)
panic(err)
}
}
log.Infof("Returning")
return i
}
示例3: save
// Saves credential cache to disk. This writes to a temporary file first, then moves the file to the config location.
// This elminates from reading partially written credential files, and reduces (but does not eliminate) concurrent
// file access. There is not guarantee here for handling multiple writes at once since there is no out of process locking.
func (f *fileCredentialCache) save(registryCache *RegistryCache) error {
defer log.Flush()
file, err := ioutil.TempFile(f.path, ".config.json.tmp")
if err != nil {
return err
}
buff, err := json.MarshalIndent(registryCache, "", " ")
if err != nil {
file.Close()
os.Remove(file.Name())
return err
}
_, err = file.Write(buff)
if err != nil {
file.Close()
os.Remove(file.Name())
return err
}
file.Close()
// note this is only atomic when relying on linux syscalls
os.Rename(file.Name(), f.fullFilePath())
return err
}
示例4: TestGetPkgPath
func TestGetPkgPath(t *testing.T) {
defer log.Flush()
Convey("Give pkgPath a ptr", t, func() {
c := &Closer{}
name, pkgPath := GetPkgPath(c)
So(name, ShouldEqual, "Closer")
So(pkgPath, ShouldEqual, "github.com/vrecan/death")
})
Convey("Give pkgPath a interface", t, func() {
var closable Closable
closable = Closer{}
name, pkgPath := GetPkgPath(closable)
So(name, ShouldEqual, "Closer")
So(pkgPath, ShouldEqual, "github.com/vrecan/death")
})
Convey("Give pkgPath a copy", t, func() {
c := Closer{}
name, pkgPath := GetPkgPath(c)
So(name, ShouldEqual, "Closer")
So(pkgPath, ShouldEqual, "github.com/vrecan/death")
})
}
示例5: main
func main() {
defer log.Flush()
stdFormat()
flag.Parse()
if *clientId == "" {
fmt.Fprintln(os.Stderr, "--client-id is not specified. See https://developers.google.com/drive/quickstart-go for step-by-step guide.")
return
}
if *clientSecret == "" {
fmt.Fprintln(os.Stderr, "--client-secret is not specified. See https://developers.google.com/drive/quickstart-go for step-by-step guide.")
return
}
fs := gdrive.NewGDriveFileSystem(*clientId, *clientSecret)
http.HandleFunc("/debug/gc", gcHandler)
http.HandleFunc("/favicon.ico", notFoundHandler)
http.HandleFunc("/", webdav.NewHandler(fs))
fmt.Printf("Listening on %v\n", *addr)
err := http.ListenAndServe(*addr, nil)
if err != nil {
log.Errorf("Error starting WebDAV server: %v", err)
}
}
示例6: main
func main() {
defer log.Flush()
flag.Parse()
args := flag.Args()
if len(args) == 0 {
usage(actions(nil))
os.Exit(1)
}
logger, err := log.LoggerFromConfigAsString(config.Logger())
if err != nil {
die(err)
}
log.ReplaceLogger(logger)
init, err := engine.New()
if err != nil {
die(err)
}
log.Info(args[0])
actions := actions(init)
action, ok := actions[args[0]]
if !ok {
usage(actions)
os.Exit(1)
}
err = action.function()
if err != nil {
die(err)
}
}
示例7: TestSTreeMod
func TestSTreeMod(t *testing.T) {
defer log.Flush()
Convey("Test clone\n", t, func() {
s, err := NewSTreeJson(strings.NewReader(`{"key1": "val1", "key.2": 1234, "key3": {"key4": true, "key5": -12.34}}`))
So(err, ShouldBeNil)
c, err := s.clone()
So(err, ShouldBeNil)
s["key1"] = "valMod"
s3, err := s.STreeVal(".key3")
s3["key4"] = false
log.Debugf("Test clone - s: %v", s)
log.Debugf("Test clone - c: %v", c)
v1, err := c.StrVal(".key1")
So(err, ShouldBeNil)
So(v1, ShouldEqual, "val1")
v2, err := c.BoolVal(".key3.key4")
So(err, ShouldBeNil)
So(v2, ShouldBeTrue)
})
}
示例8: main
func main() {
// Set up a done channel, that's shared by the whole pipeline.
// Closing this channel will kill all pipeline goroutines
//done := make(chan struct{})
//defer close(done)
// Set up logging
initializeLogging()
// Flush the log before we shutdown
defer log.Flush()
// Parse the command line flags
config := parseCommandLineFlags()
gamq.SetConfig(&config)
if config.ProfilingEnabled {
defer profile.Start(profile.CPUProfile).Stop()
}
log.Infof("Broker started on port: %d", gamq.Configuration.Port)
log.Infof("Executing on: %d threads", runtime.GOMAXPROCS(-1))
connectionManager := gamq.NewConnectionManager()
connectionManager.Start()
}
示例9: Chew
func Chew(chewChan <-chan *messaging.Food, swallowChan chan *messaging.Food, wg *sync.WaitGroup) {
log.Info("Let the chewing begin!")
defer close(swallowChan)
r := rep.NewReporter()
r.RegisterStatWIndex("chew", "good")
for msg := range chewChan {
if nil != msg {
//parsing work here probably change what our message type looks like when swallowed
date := time.Unix(0, msg.GetTimeNano()).UTC()
fmtDate := date.Format("2006-01-02")
indexType := "all"
customerId := "id" //should exist eventually
index := "documents-" + customerId + "-" + fmtDate
msg.Index = &index
msg.IndexType = &indexType
r.AddStatWIndex("chew", 1, "good")
swallowChan <- msg
}
}
log.Info("Done chewing")
log.Flush()
wg.Done()
}
示例10: main
func main() {
if len(os.Args) < 3 {
fmt.Fprintf(os.Stderr, "too few args,args form: <host port>\n")
os.Exit(1)
}
host := os.Args[1]
port, err := strconv.Atoi(os.Args[2])
if err != nil {
fmt.Fprintf(os.Stderr, "invalid port,need integer type,your input port: <port>\n", os.Args[2])
os.Exit(1)
}
ctx := context.GetContext()
currentServer := make(map[string]interface{})
currentServer["id"] = "connector-1"
currentServer["serverType"] = "connector"
currentServer["host"] = "127.0.0.1"
currentServer["port"] = 8888
ctx.CurrentServer = currentServer
defer seelog.Flush()
tcp_cnct := tcp_connector.NewTcpConnector(host, port, nil)
tcp_cnct.RegistNewConnCB(NewConnCB)
tcp_cnct.RegistNewMsgCB(NewMsgCB)
tcp_cnct.Start()
ch := make(chan int)
<-ch
}
示例11: Tokens
func (tz *BadXMLTokenizer) Tokens() <-chan *Token {
token_channel := make(chan *Token)
log.Debugf("Created channel %v as part of Tokens(), with"+
" Scanner = %v", token_channel, tz)
go func(ret chan *Token, tz *BadXMLTokenizer) {
for {
log.Tracef("Scanner calling Next()")
tok, err := tz.Next()
log.Tracef("scanner.Next() returned %s, %v", tok, err)
switch err {
case nil:
log.Debugf("Pushing %s into token channel %v",
tok, ret)
ret <- tok
case io.EOF:
log.Debugf("received EOF, closing channel")
close(ret)
log.Debugf("Closed.")
log.Flush()
return
panic("I should have exited the goroutine but " +
"didn't")
}
}
}(token_channel, tz)
return token_channel
}
示例12: adaptiveMain
func adaptiveMain() {
defer log.Flush()
loadAdaptiveConfig()
testMsgIntensity(1)
testMsgIntensity(5)
testMsgIntensity(10)
}
示例13: libWithSealogMain
func libWithSealogMain() {
defer library.FlushLog()
defer log.Flush()
loadAppConfig()
log.Info("App started")
log.Info("Config loaded")
// Disable library log
log.Info("* Disabled library log test")
library.DisableLog()
calcF2()
log.Info("* Disabled library log tested")
// Use a special logger for library
log.Info("* Special output test")
specialOutputConfig()
calcF2()
log.Info("* Special output tested")
// Use the same logger for both app and library
log.Info("* Same output test")
sameOutputConfig()
calcF2()
log.Info("* Same output tested")
log.Info("App finished")
}
示例14: exitOnError
func exitOnError(e error) {
if e != nil {
log.Errorf("Received error '%s'", e.Error())
log.Flush()
os.Exit(1)
}
}
示例15: main
func main() {
defer log.Flush()
clientId := os.Getenv("MONDO_CLIENT_ID")
clientSecret := os.Getenv("MONDO_CLIENT_SECRET")
userName := os.Getenv("MONDO_USERNAME")
password := os.Getenv("MONDO_PASSWORD")
// Authenticate with Mondo, and return an authenticated MondoClient.
client, err := mondo.Authenticate(clientId, clientSecret, userName, password)
if err != nil {
panic(err)
}
// Retrieve all of the accounts.
acs, err := client.Accounts()
if err != nil {
panic(err)
}
// Grab our account ID.
accountId := acs[0].ID
if _, err := client.RegisterWebhook(accountId, "YOUR_URL_HERE"); err != nil {
log.Errorf("Error registering webhook: %v", err)
}
}