本文整理汇总了Golang中github.com/cosiner/zerver.Environment.Logger方法的典型用法代码示例。如果您正苦于以下问题:Golang Environment.Logger方法的具体用法?Golang Environment.Logger怎么用?Golang Environment.Logger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cosiner/zerver.Environment
的用法示例。
在下文中一共展示了Environment.Logger方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Init
// Init must be called
func (h *Handler) Init(env zerver.Environment) error {
if h.SaveImage == nil {
panic("the function to save image should not be nil")
}
defval.Int64(&h.MaxMemory, 1<<19) // 512K
defval.String(&h.FileKey, "image")
if h.ErrNoFile == nil {
h.ErrNoFile = httperrs.BadRequest.NewS("upload file not exists")
}
if h.Suffixes == nil {
h.AddSuffixes("png", "jpg")
}
if h.ErrNonImage == nil {
h.ErrNonImage = httperrs.BadRequest.NewS("the upload file is not an image")
}
defval.Int64(&h.MaxSize, 1<<18) // 256K
if h.ErrTooLarge == nil {
h.ErrTooLarge = httperrs.BadRequest.NewS("the upload file size is too large")
}
defval.String(&h.PathKey, "path")
h.logger = env.Logger().Prefix("[zerver/image]")
return nil
}
示例2: Init
func (ri *RequestId) Init(env zerver.Environment) error {
defval.Nil(&ri.Store, new(MemIDStore))
ri.Store.Init(env)
defval.String(&ri.HeaderName, "X-Request-Id")
defval.String(&ri.Error, "header value X-Request-Id can't be empty")
defval.String(&ri.ErrorOverlap, "request already accepted before, please wait")
ri.logger = env.Logger().Prefix("[RequestID]")
return nil
}
示例3: Init
func (r *Redis) Init(env zerver.Environment) error {
compEnv := env.(zerver.ComponentEnvironment)
var o *RedisOption
if op := compEnv.GetSetAttr(REDIS, nil); op == nil {
o = &RedisOption{}
} else {
o = op.(*RedisOption)
}
o.init()
r.MaxIdle = o.MaxIdle
r.MaxActive = o.MaxActive
r.IdleTimeout = time.Duration(o.IdleTimeout) * time.Second
r.Dial = o.Dial
r.logger = env.Logger().Prefix("[Redis]")
_, err := r.Get().Do("PING")
return err
}
示例4: Init
func (m *Queue) Init(env zerver.Environment) error {
if m.Processor == nil {
return errors.Err("message processor shouldn't be nil")
}
if m.TaskBufsize == 0 {
m.TaskBufsize = 256
}
if m.ErrorLogger == nil {
m.ErrorLogger = env.Logger()
}
m.ErrorLogger = m.ErrorLogger.Prefix("zerver/msq")
if m.BytesPool == nil {
m.BytesPool = bytes2.NewFakePool()
}
m.queue = make(chan zerver.Task, m.TaskBufsize)
go m.start()
return nil
}
示例5: Init
func (x *Xsrf) Init(env zerver.Environment) error {
if x.Secret == "" {
return errors.Err("xsrf secret can't be empty")
}
defval.Int64(&x.Timeout, _DEF_XSRF_TIMEOUT)
defval.Nil(&x.HashMethod, sha256.New)
defval.String(&x.Error, "xsrf token is invalid or not found")
if x.UsePool {
if x.Pool == nil {
x.Pool = bytes2.NewSyncPool(0, true)
}
} else {
x.Pool = bytes2.FakePool{}
}
defval.Nil(&x.TokenInfo, jsonToken{})
x.logger = env.Logger().Prefix("[XSRF]")
return nil
}
示例6: Init
func (l *Log) Init(env zerver.Environment) error {
defval.String(&l.Prefix, "[Access]")
l.logger = env.Logger().Prefix(l.Prefix)
return nil
}
示例7: Init
func (r *Recovery) Init(env zerver.Environment) error {
r.logger = env.Logger().Prefix("[Recovery]")
defval.Int(&r.Bufsize, 1024*4)
return nil
}