本文整理汇总了Golang中github.com/cihub/seelog.Critical函数的典型用法代码示例。如果您正苦于以下问题:Golang Critical函数的具体用法?Golang Critical怎么用?Golang Critical使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Critical函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Run
func Run(nsqLookupdHTTPAddrs []string, st store.Store) {
cfg := nsq.NewConfig()
cfg.UserAgent = fmt.Sprintf("phosphor go-nsq/%s", nsq.VERSION)
cfg.MaxInFlight = maxInFlight
consumer, err := nsq.NewConsumer(topic, channel, cfg)
if err != nil {
log.Critical(err)
os.Exit(1)
}
consumer.AddHandler(&IngestionHandler{
store: st,
})
err = consumer.ConnectToNSQLookupds(nsqLookupdHTTPAddrs)
if err != nil {
log.Critical(err)
os.Exit(1)
}
// Block until exit
<-consumer.StopChan
}
开发者ID:gitter-badger,项目名称:phosphor-1,代码行数:25,代码来源:ingester.go
示例2: readFile
func readFile(filename string) int {
file, err := os.Open(filename)
if err != nil {
log.Critical(err)
}
count, err = file.Read(buf)
if err != nil {
log.Critical(err)
}
return count
}
开发者ID:sunbenxin,项目名称:mycode,代码行数:13,代码来源:dsp.go
示例3: main
func main() {
cluster := gocql.NewCluster("127.0.0.1")
cluster.Keyspace = "system"
session, err := cluster.CreateSession()
defer session.Close()
if err != nil {
log.Critical(err)
}
traceSession, err := cluster.CreateSession()
defer session.Close()
if err != nil {
log.Critical(err)
}
// Create a new logger instance that we adjust the stack depth for to get
// more meaningful frames
logger, err := log.LoggerFromConfigAsString(
`<seelog>
<outputs>
<console formatid="fmt"/>
</outputs>
<formats>
<format id="fmt" format="%Date(Jan 02 2006 03:04:05.000) [%LEVEL] %File:%Line - %Msg%n"/>
</formats>
</seelog>
`)
logger.SetAdditionalStackDepth(2)
if err != nil {
log.Critical(err)
}
writer := NewTraceWriter(traceSession, logger)
tracer := gocql.NewTraceWriter(traceSession, writer)
session.SetTrace(tracer)
var count int
iter := session.Query(`select count(*) from schema_keyspaces`).Iter()
iter.Scan(&count)
err = iter.Close()
if err != nil {
log.Critical(err)
}
log.Infof("This instance has %d keyspaces", count)
}
开发者ID:relops,项目名称:gocql-tracing-example,代码行数:51,代码来源:main.go
示例4: doRun
func doRun(opts *Options) {
defer cleanupLogs()
// check we have some endpoints
if reg.size() == 0 {
log.Critical("There are no endpoints for this service")
os.Exit(3)
}
// start listening for incoming messages
deliveries, err := raven.Consume(InstanceID)
if err != nil {
log.Critical("[Server] Failed to consume: %v", err)
os.Exit(5)
}
if opts.SelfBind {
// binding should come after you've started consuming
if err := raven.BindService(Name, InstanceID); err != nil {
log.Criticalf("[Server] Failed to bind itself: %v", err)
os.Exit(7)
}
}
// announce ourselves to the discovery service
dsc = newDiscovery(opts)
go dsc.connect()
// run some post connect handlers
for _, f := range postConnHdlrs {
go f()
}
// register stats collector
go registerStats()
// listen for SIGQUIT
go signalCatcher()
// consume messages
for d := range deliveries {
req := NewRequestFromDelivery(d)
go HandleRequest(req)
}
log.Critical("[Server] Stopping due to channel closing")
os.Exit(6)
}
开发者ID:armada-io,项目名称:h2,代码行数:48,代码来源:server.go
示例5: runFsInspector
func runFsInspector(args []string) int {
if err := fsFlagset.Parse(args); err != nil {
log.Critical(err)
return 1
}
if _fsFlags.OriginalDir == "" {
log.Critical("original-dir is not set")
return 1
}
if _fsFlags.Mountpoint == "" {
log.Critical("mount-point is not set")
return 1
}
if _fsFlags.AutopilotConfig != "" && _fsFlags.OrchestratorURL != ocutil.LocalOrchestratorURL {
log.Critical("non-default orchestrator url set for autopilot orchestration mode")
return 1
}
if logutil.Debug {
// log level: 0..2
hookfs.SetLogLevel(1)
} else {
hookfs.SetLogLevel(0)
}
if _fsFlags.AutopilotConfig != "" {
cfg, err := config.NewFromFile(_fsFlags.AutopilotConfig)
if err != nil {
panic(log.Critical(err))
}
autopilotOrchestrator, err := ocutil.NewAutopilotOrchestrator(cfg)
if err != nil {
panic(log.Critical(err))
}
log.Info("Starting autopilot-mode orchestrator")
go autopilotOrchestrator.Start()
}
hook := &inspector.FilesystemInspector{
OrchestratorURL: _fsFlags.OrchestratorURL,
EntityID: _fsFlags.EntityID,
}
fs, err := hookfs.NewHookFs(_fsFlags.OriginalDir, _fsFlags.Mountpoint, hook)
if err != nil {
panic(log.Critical(err))
}
log.Infof("Serving %s", fs)
log.Infof("Please run `fusermount -u %s` after using this, manually", _fsFlags.Mountpoint)
if err = fs.Serve(); err != nil {
panic(log.Critical(err))
}
// NOTREACHED
return 0
}
开发者ID:terminiter,项目名称:earthquake,代码行数:58,代码来源:fs.go
示例6: Notify
func (emailer *EmailNotifier) Notify(msg Message) error {
if emailer.auth == nil {
switch emailer.AuthType {
case "plain":
emailer.auth = smtp.PlainAuth("", emailer.Username, emailer.Password, emailer.Server)
case "crammd5":
emailer.auth = smtp.CRAMMD5Auth(emailer.Username, emailer.Password)
}
}
if emailer.template == nil {
template, err := template.ParseFiles(emailer.TemplateFile)
if err != nil {
log.Critical("Cannot parse email template: %v", err)
return err
}
emailer.template = template
}
if emailer.groupMsgs == nil {
emailer.groupMsgs = make(map[string]Message)
}
for _, group := range emailer.Groups {
clusterGroup := fmt.Sprintf("%s,%s", msg.Cluster, msg.Group)
if clusterGroup == group {
emailer.groupMsgs[clusterGroup] = msg
}
}
if len(emailer.Groups) == len(emailer.groupMsgs) {
return emailer.sendConsumerGroupStatusNotify()
}
return nil
}
开发者ID:Magnetme,项目名称:Burrow,代码行数:34,代码来源:email_notifier.go
示例7: testFuncException
func testFuncException() {
fmt.Println("testFuncException")
testConfig := `
<seelog type="sync" minlevel="info">
<exceptions>
<exception funcpattern="*main.test*Except*" minlevel="error"/>
</exceptions>
<outputs>
<console/>
</outputs>
</seelog>`
logger, _ := log.LoggerFromConfigAsBytes([]byte(testConfig))
log.ReplaceLogger(logger)
log.Trace("NOT Printed")
log.Debug("NOT Printed")
log.Info("NOT Printed")
log.Warn("NOT Printed")
log.Error("Printed")
log.Critical("Printed")
log.Current.Trace("NOT Printed")
log.Current.Debug("NOT Printed")
log.Current.Info("NOT Printed")
log.Current.Warn("NOT Printed")
log.Current.Error("Printed")
log.Current.Critical("Printed")
}
开发者ID:cihub,项目名称:seelog-examples,代码行数:29,代码来源:exceptions_main.go
示例8: main
func main() {
// context
ctx = context.Background()
loadConfig()
// db
hoge.BuildInstances()
// redis
redis_pool := newPool()
ctx = context.WithValue(ctx, "redis", redis_pool)
router := gin.Default()
router.Use(Custom())
// make route
router.POST("/test", controller.Test)
err := router.Run(":9999")
// 存在しないルート時
if err != nil {
log.Critical(err)
}
}
开发者ID:shamoto-donuts,项目名称:goSample,代码行数:25,代码来源:main.go
示例9: QueueNextEvent
func (d *Dumb) QueueNextEvent(event signal.Event) {
item, err := queue.NewBasicTBQueueItem(event, d.Interval, d.Interval)
if err != nil {
panic(log.Critical(err))
}
d.queue.Enqueue(item)
}
开发者ID:terminiter,项目名称:earthquake,代码行数:7,代码来源:dumbpolicy.go
示例10: Start
/// 启动rpcServer,监听rpc服务器端口,由于Start内部调用阻塞的方法,应在go 语句中调用.
func (ms *RpcServer) Start() {
go func() {
seelog.Info("RpcServer start...")
hostAndPort := fmt.Sprintf("%v:%v", ms.host, ms.port)
servAddr, err := net.ResolveTCPAddr("tcp", hostAndPort)
if err != nil {
seelog.Criticalf("RpcServer failed to start with err<%v>", err.Error())
os.Exit(1)
}
listener, err := net.ListenTCP("tcp4", servAddr)
if err != nil {
seelog.Criticalf("RpcServer failed to start with err<%v>", err.Error())
os.Exit(1)
}
seelog.Debugf("Rpc Server listening: <%v>", servAddr.String())
defer listener.Close()
for {
conn, err := listener.Accept()
seelog.Debug("Rpc Server accept new connection")
if err != nil {
seelog.Critical(err.Error())
os.Exit(1)
}
go ms.rpcServer.ServeCodec(jsonrpc.NewServerCodec(conn))
}
}()
}
开发者ID:liweisheng,项目名称:server-framework,代码行数:36,代码来源:rpcServer.go
示例11: Default
func Default() *truetype.Font {
if defaultFont == nil {
fontBytes, err := ioutil.ReadFile("test.ttf")
if err != nil {
log.Critical(err)
return nil
}
defaultFont, err = freetype.ParseFont(fontBytes)
if err != nil {
log.Critical(err)
return nil
}
}
return defaultFont
}
开发者ID:romovs,项目名称:viscum,代码行数:17,代码来源:fonts.go
示例12: Critical
// Critical outputs critical level message.
func Critical(msg ...interface{}) {
if !isValid {
return
}
mutex.Lock()
defer mutex.Unlock()
seelog.Critical(msg...)
}
开发者ID:unirita,项目名称:gocutoweb,代码行数:9,代码来源:log.go
示例13: loadImage
func loadImage(filename string) (image.Image, error) {
f, err := os.Open(filename)
if err != nil {
log.Critical(err)
return nil, err
}
defer f.Close()
img, _, err := image.Decode(bufio.NewReader(f))
if err != nil {
log.Critical(err)
return nil, err
}
return img, nil
}
开发者ID:romovs,项目名称:viscum,代码行数:17,代码来源:toolkit.go
示例14: Critical
// criticalレベルでログメッセージを出力する。
// この関数が呼び出されると、ただちにログのフラッシュが行われる。
//
// param : msg 出力するメッセージ。複数指定した場合は結合して出力される。
func Critical(msg ...interface{}) {
if !valid {
return
}
locker.Lock(lockTimeout)
defer locker.Unlock()
seelog.Critical(msg...)
}
开发者ID:unikk,项目名称:cuto,代码行数:12,代码来源:log.go
示例15: StartEarthquakeRoutines
func StartEarthquakeRoutines(c *docker.Container, cfg config.Config) error {
log.Debugf("Starting Orchestrator")
go func() {
oerr := StartOrchestrator(cfg)
if oerr != nil {
panic(log.Critical(oerr))
}
}()
if cfg.GetBool("containerParam.enableEthernetInspector") {
nfqNum := cfg.GetInt("containerParam.ethernetNFQNumber")
if nfqNum <= 0 {
return fmt.Errorf("strange containerParam.ethernetNFQNumber: %d", nfqNum)
}
log.Debugf("Configuring NFQUEUE %d for container %s", nfqNum, c.ID)
err := SetupNFQUEUE(c, nfqNum, false, false)
if err != nil {
return err
}
log.Debugf("Starting Ethernet Inspector")
go func() {
ierr := StartEthernetInspector(c, nfqNum)
if ierr != nil {
panic(log.Critical(ierr))
}
}()
}
if cfg.GetBool("containerParam.enableProcInspector") {
watchInterval := cfg.GetDuration("containerParam.procWatchInterval")
if watchInterval <= 0 {
return fmt.Errorf("strange containerParam.procWatchInterval: %s", watchInterval)
}
log.Debugf("Starting Process Inspector")
go func() {
ierr := StartProcInspector(c, watchInterval)
if ierr != nil {
panic(log.Critical(ierr))
}
}()
}
return nil
}
开发者ID:terminiter,项目名称:earthquake,代码行数:44,代码来源:start.go
示例16: runEtherInspector
func runEtherInspector(args []string) int {
if err := etherFlagset.Parse(args); err != nil {
log.Critical(err)
return 1
}
useHookSwitch := _etherFlags.NFQNumber < 0
if useHookSwitch && _etherFlags.HookSwitchZMQAddr == "" {
log.Critical("hookswitch is invalid")
return 1
}
if !useHookSwitch && _etherFlags.NFQNumber > 0xFFFF {
log.Critical("nfq-number is invalid")
return 1
}
if _etherFlags.AutopilotConfig != "" && _etherFlags.OrchestratorURL != ocutil.LocalOrchestratorURL {
log.Critical("non-default orchestrator url set for autopilot orchestration mode")
return 1
}
if _etherFlags.AutopilotConfig != "" {
cfg, err := config.NewFromFile(_etherFlags.AutopilotConfig)
if err != nil {
panic(log.Critical(err))
}
autopilotOrchestrator, err := ocutil.NewAutopilotOrchestrator(cfg)
if err != nil {
panic(log.Critical(err))
}
log.Info("Starting autopilot-mode orchestrator")
go autopilotOrchestrator.Start()
}
var etherInspector inspector.EthernetInspector
if useHookSwitch {
etherInspector = &inspector.HookSwitchInspector{
OrchestratorURL: _etherFlags.OrchestratorURL,
EntityID: _etherFlags.EntityID,
HookSwitchZMQAddr: _etherFlags.HookSwitchZMQAddr,
EnableTCPWatcher: true,
}
} else {
etherInspector = &inspector.NFQInspector{
OrchestratorURL: _etherFlags.OrchestratorURL,
EntityID: _etherFlags.EntityID,
NFQNumber: uint16(_etherFlags.NFQNumber),
EnableTCPWatcher: true,
}
}
if err := etherInspector.Start(); err != nil {
panic(log.Critical(err))
}
// NOTREACHED
return 0
}
开发者ID:terminiter,项目名称:earthquake,代码行数:59,代码来源:ethernet.go
示例17: checkConfigAndDie
func checkConfigAndDie() {
if len(config.AsteriskAddr) == 0 {
log.Critical("Asterisk address is null or empty. Please check the configuraiton file.\n")
log.Flush()
os.Exit(1)
}
if len(config.AsteriskUser) == 0 || len(config.AsteriskPassword) == 0 {
log.Critical("Asterisk credentials missing. Please check the configuration file.\n")
log.Flush()
os.Exit(1)
}
if config.TestCallActive && config.TestCallSchedule < 30 {
log.Criticalf("Asterisk tesing interval is too short : %d. Minimal value is 30(seconds).Please check the configuration file.\n", config.TestCallSchedule)
log.Flush()
os.Exit(1)
}
}
开发者ID:vassilux,项目名称:vorimport,代码行数:19,代码来源:main.go
示例18: Register
// Register an endpoint with the registry
func Register(eps ...*Endpoint) (err error) {
if !initialised {
log.Critical("Server must be initialised before you can register an endpoint")
cleanupLogs()
os.Exit(2)
}
for _, ep := range eps {
if err = reg.add(ep); err != nil {
log.Critical("Error registering endpoint, %v: %v", ep.Name, err)
log.Flush()
os.Exit(2)
}
log.Infof("[Server] Registered endpoint: %s", ep.Name)
}
return nil
}
开发者ID:armada-io,项目名称:h2,代码行数:20,代码来源:server.go
示例19: dequeueEventRoutine
func (d *Dumb) dequeueEventRoutine() {
for {
qItem := <-d.queueDeqCh
event := qItem.Value().(signal.Event)
action, err := event.DefaultAction()
if err != nil {
panic(log.Critical(err))
}
d.nextActionChan <- action
}
}
开发者ID:terminiter,项目名称:earthquake,代码行数:11,代码来源:dumbpolicy.go
示例20: Run
func Run(args []string) int {
dockerOpt, removeOnExit, eqCfg, err := prepare(args)
if err != nil {
// do not panic here
fmt.Fprintf(os.Stderr, "%s\n", err)
return 1
}
client, err := container.NewDockerClient()
if err != nil {
panic(log.Critical(err))
}
containerExitStatusChan := make(chan error)
c, err := container.Boot(client, dockerOpt, containerExitStatusChan)
if err == docker.ErrNoSuchImage {
log.Critical(err)
// TODO: pull the image automatically
log.Infof("You need to run `docker pull %s`", dockerOpt.Config.Image)
return 1
} else if err != nil {
panic(log.Critical(err))
}
if removeOnExit {
defer container.Remove(client, c)
}
err = core.StartEarthquakeRoutines(c, eqCfg)
if err != nil {
panic(log.Critical(err))
}
err = <-containerExitStatusChan
if err != nil {
// do not panic here
log.Error(err)
}
log.Debugf("Exiting..")
// TODO: propagate err
return 0
}
开发者ID:terminiter,项目名称:earthquake,代码行数:41,代码来源:run.go
注:本文中的github.com/cihub/seelog.Critical函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论