本文整理汇总了Golang中github.com/jeffail/util/log.Logger类的典型用法代码示例。如果您正苦于以下问题:Golang Logger类的具体用法?Golang Logger怎么用?Golang Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Logger类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: NewRedis
/*
NewRedis - Creates a Redis using the provided configuration.
*/
func NewRedis(config Config, logger *log.Logger) *Redis {
return &Redis{
logger: logger.NewModule(":redis_auth"),
config: config,
pool: newPool(config.RedisConfig),
}
}
开发者ID:jonasfj,项目名称:leaps,代码行数:10,代码来源:redis_based.go
示例2: NewFile
/*
NewFile - Creates an File using the provided configuration.
*/
func NewFile(config Config, logger *log.Logger) *File {
fa := File{
logger: logger.NewModule(":fs_auth"),
config: config,
paths: []string{},
mutex: &sync.RWMutex{},
}
go fa.loop()
return &fa
}
开发者ID:jonasfj,项目名称:leaps,代码行数:13,代码来源:file_based.go
示例3: NewWebsocketServer
/*
NewWebsocketServer - Creates a new HTTP websocket client.
*/
func NewWebsocketServer(
config HTTPBinderConfig,
socket *websocket.Conn,
binder lib.BinderPortal,
closeChan <-chan bool,
logger *log.Logger,
stats *log.Stats,
) *WebsocketServer {
return &WebsocketServer{
config: config,
socket: socket,
binder: binder,
closeChan: closeChan,
logger: logger.NewModule(":socket"),
stats: stats,
}
}
开发者ID:jonasfj,项目名称:leaps,代码行数:20,代码来源:websocket_server.go
示例4: NewHTTP
/*
NewHTTP - Creates an HTTP using the provided configuration.
*/
func NewHTTP(config Config, logger *log.Logger, stats *log.Stats) *HTTP {
authorizer := HTTP{
logger: logger.NewModule(":http_auth"),
stats: stats,
config: config,
mutex: sync.RWMutex{},
tokensCreate: tokensMap{},
tokensJoin: tokensMap{},
tokensReadOnly: tokensMap{},
}
authorizer.createHandler = authorizer.createGenerateTokenHandler(authorizer.tokensCreate)
authorizer.joinHandler = authorizer.createGenerateTokenHandler(authorizer.tokensJoin)
authorizer.readOnlyHandler = authorizer.createGenerateTokenHandler(authorizer.tokensReadOnly)
return &authorizer
}
开发者ID:jonasfj,项目名称:leaps,代码行数:21,代码来源:http_based.go
示例5: NewAuthMiddleware
/*
NewAuthMiddleware - Create a new leaps AuthMiddleware.
*/
func NewAuthMiddleware(
config AuthMiddlewareConfig,
logger *log.Logger,
stats *log.Stats,
) (*AuthMiddleware, error) {
auth := AuthMiddleware{
config: config,
accounts: map[string]string{},
logger: logger.NewModule(":basic_auth"),
stats: stats,
}
if config.Enabled {
if 0 == len(config.PasswdFilePath) {
return nil, ErrInvalidHtpasswdPath
}
if err := auth.accountsFromFile(config.PasswdFilePath); err != nil {
return nil, fmt.Errorf("htpasswd file read error: %v", err)
}
}
return &auth, nil
}
开发者ID:jonasfj,项目名称:leaps,代码行数:24,代码来源:auth_middleware.go
示例6: NewInternalServer
/*
NewInternalServer - Create a new leaps InternalServer.
*/
func NewInternalServer(
admin LeapAdmin,
config InternalServerConfig,
logger *log.Logger,
stats *log.Stats,
) (*InternalServer, error) {
auth, err := NewAuthMiddleware(config.HTTPAuth, logger, stats)
if err != nil {
return nil, err
}
httpServer := InternalServer{
config: config,
admin: admin,
logger: logger.NewModule(":http_admin"),
stats: stats,
mux: http.NewServeMux(),
auth: auth,
}
// Register handling for static files
if len(httpServer.config.StaticFilePath) > 0 {
if len(httpServer.config.Path) == 0 {
return nil, ErrInvalidStaticPath
}
// If the static file path is relative then we use the location of the binary to resolve it.
if err := binpath.FromBinaryIfRelative(&httpServer.config.StaticFilePath); err != nil {
return nil, fmt.Errorf("relative path for static files could not be resolved: %v", err)
}
httpServer.mux.Handle(httpServer.config.Path,
httpServer.auth.WrapHandler( // Auth wrap
http.StripPrefix(httpServer.config.Path, // File strip prefix wrap
http.FileServer(http.Dir(httpServer.config.StaticFilePath))))) // File serve handler
}
httpServer.registerEndpoints()
return &httpServer, nil
}
开发者ID:jonasfj,项目名称:leaps,代码行数:41,代码来源:internal_server.go
示例7: NewCurator
/*
NewCurator - Creates and returns a fresh curator, and launches its internal loop.
*/
func NewCurator(
config CuratorConfig,
log *log.Logger,
stats *log.Stats,
auth auth.Authenticator,
store store.Store,
) (*Curator, error) {
curator := Curator{
config: config,
store: store,
log: log.NewModule(":curator"),
stats: stats,
authenticator: auth,
openBinders: make(map[string]*Binder),
errorChan: make(chan BinderError, 10),
closeChan: make(chan struct{}),
closedChan: make(chan struct{}),
}
go curator.loop()
return &curator, nil
}
开发者ID:varver,项目名称:leaps,代码行数:26,代码来源:curator.go
示例8: NewBinder
/*
NewBinder - Creates a binder targeting an existing document determined via an ID. Must provide a
store.Store to acquire the document and apply future updates to.
*/
func NewBinder(
id string,
block store.Store,
config BinderConfig,
errorChan chan<- BinderError,
log *log.Logger,
stats *log.Stats,
) (*Binder, error) {
binder := Binder{
ID: id,
config: config,
model: CreateTextModel(config.ModelConfig),
block: block,
log: log.NewModule(":binder"),
stats: stats,
clients: make(map[string]BinderClient),
subscribeChan: make(chan BinderSubscribeBundle),
transformChan: make(chan TransformSubmission),
messageChan: make(chan MessageSubmission),
usersRequestChan: make(chan usersRequestObj),
exitChan: make(chan string),
errorChan: errorChan,
closedChan: make(chan struct{}),
}
binder.log.Debugln("Bound to document, attempting flush")
if _, err := binder.flush(); err != nil {
stats.Incr("binder.new.error", 1)
return nil, err
}
go binder.loop()
stats.Incr("binder.new.success", 1)
return &binder, nil
}
开发者ID:varver,项目名称:leaps,代码行数:40,代码来源:binder.go
注:本文中的github.com/jeffail/util/log.Logger类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论