當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。