本文整理汇总了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))
}
}
示例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,
}
}
示例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")
}
}
示例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
}
示例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)
}
示例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
})
}
示例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
}
示例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++
}
}
示例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)
}
示例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)
}
示例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)
}
}
示例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)
}
}
示例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
}
示例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
}
示例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)
}