本文整理汇总了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")
}
}
示例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)
}
}
示例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:
}
}
}
示例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)
}
}
示例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)
//.........这里部分代码省略.........