本文整理匯總了Golang中github.com/h00gs/gubed.Logger.Error方法的典型用法代碼示例。如果您正苦於以下問題:Golang Logger.Error方法的具體用法?Golang Logger.Error怎麽用?Golang Logger.Error使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/h00gs/gubed.Logger
的用法示例。
在下文中一共展示了Logger.Error方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetKeyType
func GetKeyType(key interface{}, debug *gubed.Logger) LBTYPE {
switch ktype := key.(type) {
case uint8:
return LBTYPE_UINT8
case uint16:
return LBTYPE_UINT16
case uint32:
return LBTYPE_UINT32
case uint64:
return LBTYPE_UINT64
case int8:
return LBTYPE_INT8
case int16:
return LBTYPE_INT16
case int32:
return LBTYPE_INT32
case int64:
return LBTYPE_INT64
case float32:
return LBTYPE_FLOAT32
case float64:
return LBTYPE_FLOAT64
case complex64:
return LBTYPE_COMPLEX64
case complex128:
return LBTYPE_COMPLEX128
case CATID_TYPE:
return LBTYPE_CATID
case string:
return LBTYPE_STRING
default:
debug.Error(FmtErrBadType("Unrecognised key type: %d", ktype))
}
return LBTYPE_NIL
}
示例2: Gobify
// Encode a Go object into bytes.
func Gobify(param interface{}, debug *gubed.Logger) []byte {
var bfr bytes.Buffer
enc := gob.NewEncoder(&bfr)
err := enc.Encode(param)
debug.Error(err)
return bfr.Bytes()
}
示例3: Degobify
// Decode bytes into the given Go object.
func Degobify(byts []byte, param interface{}, debug *gubed.Logger) {
var bfr bytes.Buffer
dec := gob.NewDecoder(&bfr)
err := dec.Decode(¶m)
debug.Error(err)
return
}
示例4: MakeKey
// Keys can only be a subset of the LBTYPEs.
func MakeKey(kbyts []byte, ktype LBTYPE, debug *gubed.Logger) (interface{}, error) {
if IsAllowableKey(ktype) {
return MakeTypeFromBytes(kbyts, ktype)
} else {
err := debug.Error(FmtErrBadType("Bad key type: %d", ktype))
return nil, err
}
}
示例5: GetType
// Read the first bytes of the given byte slice to return the LBTYPE.
func GetType(x []byte, debug *gubed.Logger) (typ LBTYPE) {
if len(x) < LBTYPE_SIZE {
debug.Error(FmtErrSliceTooSmall(x, LBTYPE_SIZE))
}
bfr := bufio.NewReader(bytes.NewBuffer(x[:LBTYPE_SIZE]))
debug.DecodeError(binary.Read(bfr, BIGEND, &typ))
return
}
示例6: ToUserPermissionRecord
// Map GenericRecord to a new UserPermissionRecord.
func (rec *GenericRecord) ToUserPermissionRecord(debug *gubed.Logger) (interface{}, *UserPermissionRecord) {
key, err := MakeKey(rec.kbyts, rec.ktype, debug)
debug.Error(err)
upr := NewUserPermissionRecord()
// Unpack
var p uint8 = uint8(rec.vbyts[0])
upr.Create = PERMISSION_CREATE == (p & PERMISSION_CREATE)
upr.Read = PERMISSION_READ == (p & PERMISSION_READ)
upr.Update = PERMISSION_UPDATE == (p & PERMISSION_UPDATE)
upr.Delete = PERMISSION_DELETE == (p & PERMISSION_DELETE)
return key, upr
}
示例7: ToValueLocation
// Map GenericRecord to a new MasterLogRecord.
func (rec *GenericRecord) ToValueLocation(debug *gubed.Logger) (interface{}, *ValueLocation) {
key, err := MakeKey(rec.kbyts, rec.ktype, debug)
debug.Error(err)
vbyts, _ := rec.GetValueAndType(MASTER_RECORD, debug)
vloc := NewValueLocation()
// Unpack
bfr := bufio.NewReader(bytes.NewBuffer(vbyts))
debug.DecodeError(binary.Read(bfr, BIGEND, &vloc.fnum))
debug.DecodeError(binary.Read(bfr, BIGEND, &vloc.vsz))
debug.DecodeError(binary.Read(bfr, BIGEND, &vloc.vpos))
return key, vloc
}
示例8: ToZapRecordList
// Map GenericRecord to a new ZapRecord list.
func (rec *GenericRecord) ToZapRecordList(debug *gubed.Logger) (interface{}, []*ZapRecord) {
key, err := MakeKey(rec.kbyts, rec.ktype, debug)
debug.Error(err)
n := rec.LocationListLength()
bfr := bufio.NewReader(bytes.NewBuffer(rec.vbyts))
var zrecs = make([]*ZapRecord, n)
for i := 0; i < n; i++ {
zrecs[i] = NewZapRecord()
debug.DecodeError(binary.Read(bfr, BIGEND, &zrecs[i].fnum))
debug.DecodeError(binary.Read(bfr, BIGEND, &zrecs[i].rsz))
debug.DecodeError(binary.Read(bfr, BIGEND, &zrecs[i].rpos))
}
return key, zrecs
}
示例9: MakeNode
func MakeNode(name string, ntype LBTYPE, debug *gubed.Logger) *Node {
switch ntype {
case LBTYPE_KIND, LBTYPE_DOC:
return &Node{
name: name,
ntype: ntype,
parents: NewCatalogIdSet(),
debug: debug,
FieldMap: NewFieldMap(),
}
default:
debug.Error(FmtErrBadType("Bad key type: %d", ntype))
return nil
}
}
示例10: FromBytes
// Read the parent CATID set, which is always the last section of the buffer.
func (cidset *CatalogIdSet) FromBytes(bfr *bytes.Buffer, debug *gubed.Logger) (err error) {
rem := bfr.Len() % int(CATID_TYPE_SIZE)
if rem > 0 {
err = debug.Error(FmtErrPartialCATIDSet(bfr.Len(), CATID_TYPE_SIZE))
return
}
n := bfr.Len() / int(CATID_TYPE_SIZE)
var id CATID_TYPE
cidset.set = make([]*CatalogId, n)
for i := 0; i < n; i++ {
err = debug.Error(binary.Read(bfr, BIGEND, &id))
cidset.set[i] = NewCatalogId(id)
if err != nil {
break
}
}
return
}
示例11: ToBytes
func ToBytes(val interface{}, vt LBTYPE, debug *gubed.Logger) (byts []byte, err error) {
bfr := new(bytes.Buffer)
es := "Type mismatch, value is type %T but LBTYPE is %v"
switch v := val.(type) {
case uint8:
if vt != LBTYPE_UINT8 {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
binary.Write(bfr, BIGEND, v)
case uint16:
if vt != LBTYPE_UINT16 {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
binary.Write(bfr, BIGEND, v)
case uint32:
if vt != LBTYPE_UINT32 {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
binary.Write(bfr, BIGEND, v)
case uint64:
if vt != LBTYPE_UINT64 {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
binary.Write(bfr, BIGEND, v)
case int8:
if vt != LBTYPE_INT8 {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
binary.Write(bfr, BIGEND, v)
case int16:
if vt != LBTYPE_INT16 {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
binary.Write(bfr, BIGEND, v)
case int32:
if vt != LBTYPE_INT32 {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
binary.Write(bfr, BIGEND, v)
case int64:
if vt != LBTYPE_INT64 {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
binary.Write(bfr, BIGEND, v)
case float32:
if vt != LBTYPE_FLOAT32 {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
binary.Write(bfr, BIGEND, v)
case float64:
if vt != LBTYPE_FLOAT64 {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
binary.Write(bfr, BIGEND, v)
case complex64:
if vt != LBTYPE_COMPLEX64 {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
binary.Write(bfr, BIGEND, v)
case complex128:
if vt != LBTYPE_COMPLEX128 {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
binary.Write(bfr, BIGEND, v)
case CATID_TYPE:
if vt != LBTYPE_CATID {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
binary.Write(bfr, BIGEND, v)
case []byte:
if vt != LBTYPE_BYTES {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
return v, nil
case string:
if vt != LBTYPE_STRING && vt != LBTYPE_LOCATION {
return nil, debug.Error(FmtErrBadType(es, v, vt))
}
return []byte(v), nil
}
return bfr.Bytes(), nil
}