本文整理汇总了Golang中github.com/urandom/webfw.Logger.Infoln方法的典型用法代码示例。如果您正苦于以下问题:Golang Logger.Infoln方法的具体用法?Golang Logger.Infoln怎么用?Golang Logger.Infoln使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/urandom/webfw.Logger
的用法示例。
在下文中一共展示了Logger.Infoln方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewSearchIndex
func NewSearchIndex(repo content.Repo, config Config, logger webfw.Logger) (SearchIndex, error) {
var err error
var index bleve.Index
si := SearchIndex{}
_, err = os.Stat(config.SearchIndex.BlevePath)
if err == nil {
logger.Infoln("Opening search index " + config.SearchIndex.BlevePath)
index, err = bleve.Open(config.SearchIndex.BlevePath)
if err != nil {
return EmptySearchIndex, errors.New(fmt.Sprintf("Error opening search index: %v\n", err))
}
} else if os.IsNotExist(err) {
mapping := bleve.NewIndexMapping()
docMapping := bleve.NewDocumentMapping()
idfieldmapping := bleve.NewTextFieldMapping()
idfieldmapping.IncludeInAll = false
docMapping.AddFieldMappingsAt("FeedId", idfieldmapping)
docMapping.AddFieldMappingsAt("ArticleId", idfieldmapping)
mapping.AddDocumentMapping(mapping.DefaultType, docMapping)
logger.Infoln("Creating search index " + config.SearchIndex.BlevePath)
index, err = bleve.New(config.SearchIndex.BlevePath, mapping)
if err != nil {
return EmptySearchIndex, errors.New(fmt.Sprintf("Error creating search index: %v\n", err))
}
si.newIndex = true
} else {
return EmptySearchIndex, errors.New(
fmt.Sprintf("Error getting stat of '%s': %v\n", config.SearchIndex.BlevePath, err))
}
si.logger = logger
si.repo = repo
si.Index = index
si.batchSize = config.SearchIndex.BatchSize
return si, nil
}
示例2: NewBleve
func NewBleve(path string, size int64, logger webfw.Logger) (content.SearchProvider, error) {
var err error
var exists bool
var index bleve.Index
_, err = os.Stat(path)
if err == nil {
logger.Infoln("Opening search index " + path)
index, err = bleve.Open(path)
if err != nil {
return nil, errors.New(fmt.Sprintf("Error opening search index: %v\n", err))
}
exists = true
} else if os.IsNotExist(err) {
mapping := bleve.NewIndexMapping()
docMapping := bleve.NewDocumentMapping()
idfieldmapping := bleve.NewTextFieldMapping()
idfieldmapping.IncludeInAll = false
docMapping.AddFieldMappingsAt("FeedId", idfieldmapping)
docMapping.AddFieldMappingsAt("ArticleId", idfieldmapping)
mapping.AddDocumentMapping(mapping.DefaultType, docMapping)
logger.Infoln("Creating search index " + path)
index, err = bleve.NewUsing(path, mapping, upside_down.Name, goleveldb.Name, nil)
if err != nil {
return nil, errors.New(fmt.Sprintf("Error creating search index: %v\n", err))
}
} else {
return nil, errors.New(
fmt.Sprintf("Error getting stat of '%s': %v\n", path, err))
}
return &Bleve{logger: logger, index: index, batchSize: size, newIndex: !exists}, nil
}