本文整理汇总了Golang中github.com/Sirupsen/logrus.Panicf函数的典型用法代码示例。如果您正苦于以下问题:Golang Panicf函数的具体用法?Golang Panicf怎么用?Golang Panicf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Panicf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: InstallDependencies
//InstallDependencies install all external sources
func (b *Base) InstallDependencies() error {
components := b.MainfileData.Graph
for _, c := range components {
if !IsExternal(c) {
//Save the parameters to the answer data.
b.updateComponentAnswers(c)
continue
}
logrus.Infof("Installing dependency: %s", c.Name)
image, err := GetSourceImage(c)
if err != nil {
return err
}
externalDir, err := b.makeExternalAppDirectory(c)
if err != nil {
return err
}
externalBase := New(externalDir, image)
externalBase.setAnswersDir(b.Target())
if err := externalBase.Install(); err != nil {
logrus.Panicf("Failed to install dependency: %s", err)
return err
}
}
return nil
}
开发者ID:aweiteka,项目名称:nulecule-go,代码行数:27,代码来源:install.go
示例17: InitConfig
// InitConfig initializes configuration file
func InitConfig(filepath string, section string) Config {
var (
c Config
requiredOptions = []string{"host", "client_token", "client_secret", "access_token"}
missing []string
)
// Check if filepath is empty
if filepath == "" {
filepath = "~/.edgerc"
}
// Check if section is empty
if section == "" {
section = "default"
}
// Tilde seems to be not working when passing ~/.edgerc as file
// Takes current user and use home dir instead
path, err := tilde.Expand(filepath)
if err != nil {
log.Panicf("Fatal could not find home dir from user: %s \n", err)
}
edgerc, err := ini.Load(path)
if err != nil {
log.Panicf("Fatal error config file: %s \n", err)
}
edgerc.Section(section).MapTo(&c)
for _, opt := range requiredOptions {
if !(edgerc.Section(section).HasKey(opt)) {
missing = append(missing, opt)
}
}
if len(missing) > 0 {
log.Panicf("Fatal missing required options: %s \n", missing)
}
if c.MaxBody == 0 {
c.MaxBody = 131072
}
return c
}
开发者ID:yu81,项目名称:AkamaiOPEN-edgegrid-golang,代码行数:45,代码来源:edgegrid.go
示例18: doStart
func (pm *ProcessManager) doStart(executablePath string, args []string, procattr *syscall.ProcAttr) {
var err error
log.Infof("Getting Ready to start process: %v with args: %v and ProcAttr: %+v", executablePath, args, procattr)
pm.pid, err = syscall.ForkExec(executablePath, args, procattr)
if err != nil {
log.Panicf("Error starting process %v", err)
} else {
log.Infof("Process Manager started to manage %v at PID: %v", executablePath, pm.pid)
}
}
开发者ID:glickbot,项目名称:riak-mesos,代码行数:10,代码来源:process_manager_linux.go
示例19: enableHealthchecks
func enableHealthchecks(port int) {
healthcheck := &Healthcheck{http.Client{}, appConfig}
router := mux.NewRouter()
router.HandleFunc("/__health", healthcheck.checkHealth())
router.HandleFunc("/__gtg", healthcheck.gtg)
http.Handle("/", router)
err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
if err != nil {
log.Panicf("Couldn't set up HTTP listener: %+v\n", err)
}
}
开发者ID:Financial-Times,项目名称:up-river-of-news,代码行数:12,代码来源:app.go
示例20: Initialise
func (ro *RouteOptions) Initialise(g *Grapi) {
// This could get expensive - just do it once.
if ro.initialised {
return
}
ro.initialised = true
if !ro.UseDefaultAuth {
return
}
if ro.Authenticate != nil {
log.Panicf("Should set either RouteOptions.Authenticate or RouteOptions.UseDefaultAuth, but not both. " +
"Your custom authenticator will now be overwritten.")
}
ro.Authenticate = g.defaultAuthenticator()
}
开发者ID:ivanol,项目名称:grapi,代码行数:15,代码来源:route_options.go
注:本文中的github.com/Sirupsen/logrus.Panicf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论