當前位置: 首頁>>代碼示例>>Golang>>正文


Golang logrus.Panicf函數代碼示例

本文整理匯總了Golang中github.com/Sirupsen/logrus.Panicf函數的典型用法代碼示例。如果您正苦於以下問題:Golang Panicf函數的具體用法?Golang Panicf怎麽用?Golang Panicf使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Panicf函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: main

func main() {
    var err error

    serverAddr, err := net.ResolveUDPAddr("udp", "127.0.0.1:58672")
    if err != nil {
        logrus.Panicf("Error resolving UDP address with %v", err)
    }

    localAddr, err := net.ResolveUDPAddr("udp", "127.0.0.1:0")
    if err != nil {
        logrus.Panicf("Error resolving UDP address with %v", err)
    }

    UDPConn, err := net.DialUDP("udp", localAddr, serverAddr)
    if err != nil {
        logrus.Panicf("Error with dial UDP: %v", err)
    }

    defer UDPConn.Close()
    readBuf := make([]byte, UDPBufSize)
    for {
        read, err := UDPConn.Read(readBuf)
        if err != nil {
            logrus.Print("Read error: %v", err)
            continue
        }

        logrus.Printf("Readed bytes %d with message: %s", read, string(readBuf))
    }
}
開發者ID:leominov,項目名稱:udp-test,代碼行數:30,代碼來源:main.go

示例2: NewFrameworkRiakNode

func NewFrameworkRiakNode(sc *SchedulerCore, clusterName string, restartGeneration int64, simpleId int) *FrameworkRiakNode {
    nodeCpusFloat, err := strconv.ParseFloat(sc.nodeCpus, 64)
    if err != nil {
        log.Panicf("Unable to determine node_cpus: %+v", err)
    }
    nodeMemFloat, err := strconv.ParseFloat(sc.nodeMem, 64)
    if err != nil {
        log.Panicf("Unable to determine node_mem: %+v", err)
    }
    nodeDiskFloat, err := strconv.ParseFloat(sc.nodeDisk, 64)
    if err != nil {
        log.Panicf("Unable to determine node_disk: %+v", err)
    }

    return &FrameworkRiakNode{
        DestinationState:  process_state.Started,
        CurrentState:      process_state.Unknown,
        Generation:        0,
        reconciled:        false,
        FrameworkName:     sc.frameworkName,
        Role:              &sc.frameworkRole,
        Principal:         &sc.mesosAuthPrincipal,
        SimpleId:          simpleId,
        ClusterName:       clusterName,
        Cpus:              nodeCpusFloat,
        Mem:               nodeMemFloat,
        Disk:              nodeDiskFloat,
        Ports:             PORTS_PER_TASK,
        UUID:              uuid.NewV4().String(),
        ContainerPath:     CONTAINER_PATH,
        RestartGeneration: restartGeneration,
    }
}
開發者ID:sanmiguel,項目名稱:riak-mesos,代碼行數:33,代碼來源:node.go

示例3: init

func init() {
    kv, err := kvdb.New(mem.Name, "driver_test", []string{}, nil)
    if err != nil {
        log.Panicf("Failed to intialize KVDB")
    }
    err = kvdb.SetInstance(kv)
    if err != nil {
        log.Panicf("Failed to set KVDB instance")
    }
}
開發者ID:phoenix-io,項目名稱:openstorage,代碼行數:10,代碼來源:driver.go

示例4: assertTagged

func assertTagged(image string) reference.NamedTagged {
    ref, err := reference.Parse(image)
    if err != nil {
        logrus.Panicf("Invalid reference %q: %v", image, err)
    }
    named, ok := ref.(reference.NamedTagged)
    if !ok {
        logrus.Panicf("Image reference must have name and tag: %s", image)
    }

    return named
}
開發者ID:carriercomm,項目名稱:golem,代碼行數:12,代碼來源:configuration.go

示例5: init

func init() {
    kv, err := kvdb.New(mem.Name, "driver_test", []string{}, nil)
    if err != nil {
        logrus.Panicf("Failed to intialize KVDB")
    }
    err = kvdb.SetInstance(kv)
    if err != nil {
        logrus.Panicf("Failed to set KVDB instance")
    }

    e = NewDefaultEnumerator("enumerator_test", kv)
}
開發者ID:pombredanne,項目名稱:openstorage,代碼行數:12,代碼來源:enumerator_test.go

示例6: DumpStore

func DumpStore(dbName string) {

    db, err := bolt.Open(dbName, 0600, &bolt.Options{Timeout: 1 * time.Second})
    if err != nil {
        log.Panicf("unable to open %s, error: %v\n", dbName, err)
    }
    db.View(func(tx *bolt.Tx) error {
        b := tx.Bucket([]byte("events"))
        b.ForEach(func(k, v []byte) error {

            seq, err := readSequence(k)
            if err != nil {
                log.Errorf("Error decoding sequence number %v", err)
            }

            evt, err := decodeEvent(v)
            if err != nil {
                log.Errorf("Error decoding event %v", err)
            }
            body := strings.Replace(string(evt.Body), "\n", "\\n", -1)
            fmt.Printf("key=%d, value={channel:\"%s\", body:\"%s\"}\n", seq, evt.Channel, body)
            return nil
        })
        return nil
    })
}
開發者ID:wojtekzw,項目名稱:event-shuttle,代碼行數:26,代碼來源:dumpbolt.go

示例7: GetReader

func GetReader(config []byte) Reader {
    var err error

    br := BaseReader{}
    err = json.Unmarshal(config, &br)
    if err != nil {
        logrus.Error(err)
        logrus.Fatal("Missing reader name and/or type")
    }

    var r Reader

    switch br.Type {
    default:
        logrus.Panicf("Unrecognized reader type: %#v", br)
    case "FileReader":
        fr := FileReader{}
        err = json.Unmarshal(config, &fr)
        r = &fr
    }

    if err != nil {
        logrus.Error(err)
        logrus.Fatal(fmt.Sprintf("Invalid configuration for %#v", br))
    }

    return r
}
開發者ID:ARodri,項目名稱:hume,代碼行數:28,代碼來源:reader.go

示例8: Listening

func Listening() {
    defer func() {
        if sm.l != nil {
            sm.l.Close()
        }
    }()
    l, err := net.Listen("tcp", sm.config.ProxyPort)
    if err != nil {
        log.Panicf("switch manager Listening panic, err:%s\n", err.Error())
    }
    sm.l = l
    var i = 1
    for {
        sm.rwMutex.RLock()
        if sm.closed {
            sm.rwMutex.RUnlock()
            break
        } else {
            sm.rwMutex.RUnlock()
        }
        conn, err := sm.l.Accept()
        if err != nil {
            log.Errorf("sm.l.Accept error:%+v\n", err.Error())
        } else {
            log.Infof("accept connection count %d\n", i)
            go handleConn(sm, conn)
        }

        i++
    }
}
開發者ID:yiduoyunQ,項目名稱:sm,代碼行數:31,代碼來源:sm_listen.go

示例9: createSchema

// Create schema
func createSchema() {
    dbDir := filepath.Dir(*flags.DBPath)
    if _, err := os.Stat(dbDir); os.IsNotExist(err) {
        os.MkdirAll(dbDir, 0777)
        log.Infof("Created directory path=%s", dbDir)
    }
    db, _ := connection()
    defer db.Close()
    stmt, err := db.Prepare(`
        CREATE TABLE notes (
            uid string,
            created string,
            updated string,
            tags string,
            content string,
            encrypted INTEGER DEFAULT 0,
            subject TEXT
        );`)
    if err != nil {
        if err.Error() != "table notes already exists" {
            log.Panicf("Unable to prepare schema path=%s, err=%v", *flags.DBPath, err)
        }
        return
    }
    _, err = stmt.Exec()
    if err != nil {
        log.Errorf("Unable to create schema err=%v", err)
    }
    log.Infof("Schema created path=%s", *flags.DBPath)

}
開發者ID:jmcfarlane,項目名稱:notable,代碼行數:32,代碼來源:database.go

示例10: main

func main() {
    log.Infof("Starting up Popular DNS for domain `%s`...", config.Domain)

    cfClient, err := cloudflare.NewClient(config.CloudFlareEmail, config.CloudFlareToken)
    if err != nil {
        log.Panicf("Could not create CloudFlare client for email `%s`: %v", config.CloudFlareEmail, err)
    } else {
        cf = cfClient
    }

    record, err := createOrGetRecord(config.Domain, config.Domain)
    if err != nil {
        log.Panic(err)
    } else {
        recordId = record.Id
    }

    store = NewDomainStore(config.FirebaseURL, config.FirebaseAuth)

    http.Handle("/ui/dist/", http.StripPrefix("/ui/dist/", http.FileServer(http.Dir("ui/dist"))))
    http.HandleFunc("/set", set)
    http.HandleFunc("/", view)
    http.ListenAndServe(":8080", nil)

}
開發者ID:ethernetdan,項目名稱:wedirect,代碼行數:25,代碼來源:server.go

示例11: init

func init() {
    configFile := defaultConfigFile
    if configFileEnv := os.Getenv("CONFIG_FILE"); len(configFileEnv) != 0 {
        configFile = configFileEnv
    }

    data, err := ioutil.ReadFile(configFile)
    if err != nil {
        log.Panicf("Could not read configuration file: %v", err)
    }

    err = json.Unmarshal(data, &config)
    if err != nil {
        log.Panicf("Could not unmarshal configuration struct from file `%s`: %v", configFile, err)
    }
}
開發者ID:ethernetdan,項目名稱:wedirect,代碼行數:16,代碼來源:server.go

示例12: Init

// Init Refcounts. Discover volume usage refcounts from Docker.
// This functions does not sync with mount/unmount handlers and should be called
// and completed BEFORE we start accepting Mount/unmount requests.
func (r refCountsMap) Init(d *vmdkDriver) {
    c, err := client.NewClient(dockerUSocket, apiVersion, nil, defaultHeaders)
    if err != nil {
        log.Panicf("Failed to create client for Docker at %s.( %v)",
            dockerUSocket, err)
    }
    log.Infof("Getting volume data from %s", dockerUSocket)
    info, err := c.Info(context.Background())
    if err != nil {
        log.Infof("Can't connect to %s, skipping discovery", dockerUSocket)
        // TODO: Issue #369
        // Docker is not running, inform ESX to detach docker volumes, if any
        // d.detachAllVolumes()
        return
    }
    log.Debugf("Docker info: version=%s, root=%s, OS=%s",
        info.ServerVersion, info.DockerRootDir, info.OperatingSystem)

    // connects (and polls if needed) and then calls discovery
    err = r.discoverAndSync(c, d)
    if err != nil {
        log.Errorf("Failed to discover mount refcounts(%v)", err)
        return
    }

    log.Infof("Discovered %d volumes in use.", len(r))
    for name, cnt := range r {
        log.Infof("Volume name=%s count=%d mounted=%t device='%s'",
            name, cnt.count, cnt.mounted, cnt.dev)
    }
}
開發者ID:vmware,項目名稱:docker-volume-vsphere,代碼行數:34,代碼來源:refcnt.go

示例13: connection

// connection to a sqlite database (currently hard coded for testing)
func connection() (*sql.DB, error) {
    db, err := sql.Open("sqlite3", *flags.DBPath)
    if err != nil {
        log.Panicf("Unable to open database path=%s, err=%v", *flags.DBPath, err)
    }
    return db, err
}
開發者ID:jmcfarlane,項目名稱:notable,代碼行數:8,代碼來源:database.go

示例14: getTestDb

func getTestDb() *gorm.DB {
    if test_db != nil {
        return test_db
    }
    db, err := gorm.Open("sqlite3", "./api-test.db")

    if err != nil {
        log.Panicf("Error opening sqlite3 database in test %v\n", err)
    }

    db.DropTable(&User{})
    db.DropTable(&PrivateWidget{})
    db.DropTable(&Widget{})
    db.DropTable(&VerifiedWidget{})
    db.CreateTable(&User{})
    db.CreateTable(&PrivateWidget{})
    db.CreateTable(&Widget{})
    db.CreateTable(&VerifiedWidget{})

    var private_widgets []PrivateWidget
    db.Model(&User{}).Related(&private_widgets)

    db.Create(&User{Name: "admin", Password: "password"})

    db.Create(&Widget{ID: 1, Name: "Widget 1"})
    db.Create(&Widget{ID: 2, Name: "Widget 2"})
    db.Create(&Widget{ID: 3, Name: "Widget 3"})

    test_db = &db
    if *verboseMartini {
        test_db = test_db.Debug()
    }
    return test_db
}
開發者ID:ivanol,項目名稱:go-martini-api,代碼行數:34,代碼來源:helpers_test.go

示例15: SetMaxLen

func (r *RoundRobinPeerSelector) SetMaxLen(m uint32) {
    if m > math.MaxUint16 {
        log.Panicf("Number of peers %v greater than those suported %v",
            m, math.MaxUint16)
    }
    atomic.StoreUint32(&r.maxLen, m)
}
開發者ID:ModelRocket,項目名稱:openstorage,代碼行數:7,代碼來源:gossip.go


注:本文中的github.com/Sirupsen/logrus.Panicf函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。