当前位置: 首页>>代码示例>>Golang>>正文


Golang Logger.Fatalln方法代码示例

本文整理汇总了Golang中log.Logger.Fatalln方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Fatalln方法的具体用法?Golang Logger.Fatalln怎么用?Golang Logger.Fatalln使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在log.Logger的用法示例。


在下文中一共展示了Logger.Fatalln方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: validateConfig

func validateConfig(logger *log.Logger) {
	c := nbadConfig

	if c.MessageInitBufferTimeSeconds > c.MessageCacheTTLInSeconds {
		logger.Fatalln("init buffer ttl cannot be greater than message cache ttl")
	}
}
开发者ID:JohnMurray,项目名称:nbad,代码行数:7,代码来源:config.go

示例2: InitDB

func InitDB(logger *log.Logger) {
	var err interface{}
	Datab, err = sql.Open("sqlite3", "C:\\Users\\Layne\\Documents\\code\\test\\blub.db")
	if err != nil {
		logger.Fatalln(err)
	}

	for _, stmt := range openingStatements {
		Datab.Exec(stmt)
	}
}
开发者ID:lg198,项目名称:CounselorNotesWeb,代码行数:11,代码来源:database.go

示例3: CountElementsInXML

// CountElementsInXML возвращает количество узлов в XML-файле
func CountElementsInXML(w *sync.WaitGroup, c chan int, tableName string, countedElement string, logger *log.Logger) {
	w.Add(1)
	defer w.Done()

	var err error

	format := "xml"

	fileName, err2 := SearchFile(tableName, format)
	if err2 != nil {
		logger.Fatalln("Error searching file:", err)
	}

	pathToFile := format + "/" + fileName

	xmlFile, err := os.Open(pathToFile)
	if err != nil {
		logger.Fatalln("Error opening file:", err)
	}

	defer xmlFile.Close()

	decoder := xml.NewDecoder(xmlFile)
	total := 0
	var inElement string
	for {
		// Read tokens from the XML document in a stream.
		t, _ := decoder.Token()
		if t == nil {
			break
		}
		// Inspect the type of the token just read.
		switch se := t.(type) {
		case xml.StartElement:
			// If we just read a StartElement token
			inElement = se.Name.Local

			if inElement == countedElement {
				total++
				c <- total
			}
		default:
		}
	}
}
开发者ID:pavlik,项目名称:fias_xml2postgresql,代码行数:46,代码来源:xml.go

示例4: main

func main() {
	flag.Parse()
	if *backendURL == "" {
		flag.Usage()
		os.Exit(1)
	}

	var errorLog *log.Logger
	if *errorLogName == "" {
		errorLog = log.New(os.Stderr, "", log.LstdFlags)
	} else {
		errorLogFile, err := os.OpenFile(*errorLogName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
		if err != nil {
			log.Fatalf("Error opening error log file: %v", err)
		}
		defer errorLogFile.Close()
		errorLog = log.New(errorLogFile, "", log.LstdFlags)
	}

	var accessLog *log.Logger
	if *accessLogName != "" {
		accessLogFile, err := os.OpenFile(*accessLogName, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
		if err != nil {
			log.Fatalf("Error opening access log file: %v", err)
		}
		defer accessLogFile.Close()
		accessLog = log.New(accessLogFile, "", log.LstdFlags)
	}

	udpAddr, err := net.ResolveUDPAddr("udp", *listenAddr)
	if err != nil {
		errorLog.Fatalln("Can't resolve UDP addr")
	}
	udpListener, err := net.ListenUDP("udp", udpAddr)
	if err != nil {
		errorLog.Fatalln("Can't listen on UDP")
	}
	defer udpListener.Close()

	errorLog.Printf("crosscoap started: Listening for CoAP on UDP %v ...", *listenAddr)

	p := crosscoap.Proxy{
		Listener:   udpListener,
		BackendURL: *backendURL,
		ErrorLog:   errorLog,
		AccessLog:  accessLog,
	}
	err = p.Serve()
	if err != nil {
		errorLog.Fatalln(err)
	}
}
开发者ID:ibm-security-innovation,项目名称:crosscoap,代码行数:52,代码来源:crosscoap.go

示例5: ExportBulk

// ExportBulk экспортирует данные из xml-файла в таблицу указанную в описании xml-структуры
func ExportBulk(schema func(tableName string) string, xmlObject interface{}, w *sync.WaitGroup, c chan string, db *sqlx.DB, format *string, logger *log.Logger) {

	defer w.Done()

	const dateformat = "2006-01-02"

	objName := extractXMLObjectName(xmlObject)
	fields := extractFeilds(xmlObject)
	searchFileName := objName.tableName
	objName.tableName = strings.TrimSuffix(objName.tableName, "_")

	DropAndCreateTable(schema(objName.tableName), objName.tableName, db)

	var format2 string
	format2 = *format
	fileName, err2 := SearchFile(searchFileName, format2)
	if err2 != nil {
		logger.Fatalln("Error searching file:", err2)
	}

	pathToFile := format2 + "/" + fileName

	xmlFile, err := os.Open(pathToFile)
	if err != nil {
		logger.Fatalln("Error opening file:", err)
	}

	defer xmlFile.Close()

	decoder := xml.NewDecoder(xmlFile)
	var inElement string
	total := 0
	i := 0

	txn, err := db.Begin()
	if err != nil {
		logger.Fatalln(err)
	}

	query := pq.CopyIn(objName.tableName, fields...)

	stmt, err := txn.Prepare(query)
	if err != nil {
		logger.Fatalln(err)
	}

	for {
		if i == 50000 {
			i = 0

			_, err = stmt.Exec()
			if err != nil {
				logger.Fatalln(err)
			}

			err = stmt.Close()
			if err != nil {
				logger.Fatalln(err)
			}

			err = txn.Commit()
			if err != nil {
				logger.Fatalln(err)
			}

			txn, err = db.Begin()
			if err != nil {
				logger.Fatalln(err)
			}

			stmt, err = txn.Prepare(query)
			if err != nil {
				logger.Fatalln(err)
			}
		}

		t, _ := decoder.Token()

		// Если достигли конца xml-файла
		if t == nil {
			if i > 0 {
				_, err = stmt.Exec()
				if err != nil {
					logger.Fatalln(err)
				}

				err = stmt.Close()
				if err != nil {
					logger.Fatalln(err)
				}

				err = txn.Commit()
				if err != nil {
					logger.Fatalln(err)
				}
			}

			//c <- helpers.PrintRowsAffected(elementName, total)

//.........这里部分代码省略.........
开发者ID:pavlik,项目名称:fias_xml2postgresql,代码行数:101,代码来源:export.go


注:本文中的log.Logger.Fatalln方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。