本文整理匯總了Golang中github.com/h00gs/gubed.Logger類的典型用法代碼示例。如果您正苦於以下問題:Golang Logger類的具體用法?Golang Logger怎麽用?Golang Logger使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Logger類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
示例2: 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
}
示例3: 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()
}
示例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: ToIndexRecord
// Map GenericRecord to a new IndexRecord.
func (rec *GenericRecord) ToIndexRecord(debug *gubed.Logger) *IndexRecord {
irec := NewIndexRecord()
irec.ksz = rec.ksz
irec.kbyts = rec.kbyts
irec.ktype = rec.ktype
// Unpack
bfr := bufio.NewReader(bytes.NewBuffer(rec.vbyts))
debug.DecodeError(binary.Read(bfr, BIGEND, &irec.vsz))
debug.DecodeError(binary.Read(bfr, BIGEND, &irec.vpos))
return irec
}
示例7: FromBytes
func (fmap *FieldMap) FromBytes(bfr *bytes.Buffer, debug *gubed.Logger) (err error) {
var size LBUINT
var label string
var vtype LBTYPE
var bits []byte
for bfr.Len() > 0 {
err = debug.DecodeError(binary.Read(bfr, BIGEND, &size)) // label size
if err == io.EOF {
break
} else {
if err != nil {
return
}
}
bits = make([]byte, int(size))
err = debug.DecodeError(binary.Read(bfr, BIGEND, &bits))
if err == io.EOF {
break
} else {
if err != nil {
return
}
}
label = string(bits) // label
err = debug.DecodeError(binary.Read(bfr, BIGEND, &size)) // value size
if err == io.EOF {
break
} else {
if err != nil {
return
}
}
bits = make([]byte, int(size)-LBTYPE_SIZE)
err = debug.DecodeError(binary.Read(bfr, BIGEND, &vtype)) // LBTYPE
if err == io.EOF {
break
} else {
if err != nil {
return
}
}
err = debug.DecodeError(binary.Read(bfr, BIGEND, &bits))
fmap.fields[label] = MakeField(bits, vtype)
if err == io.EOF {
break
} else {
if err != nil {
return
}
}
}
return
}
示例8: 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
}
示例9: ToLogRecord
// Map GenericRecord to a new LogRecord.
func (rec *GenericRecord) ToLogRecord(debug *gubed.Logger) *LogRecord {
lrec := NewLogRecord()
lrec.ksz = rec.ksz
lrec.vsz = rec.vsz - CRC_SIZE
lrec.kbyts = rec.kbyts
lrec.ktype = rec.ktype
lrec.vtype = rec.vtype
// Unpack
bfr := bufio.NewReader(bytes.NewBuffer(rec.vbyts))
// Note that the generic vsz includes the LBTYPE prefix
lrec.vbyts = make([]byte, int(lrec.vsz)-LBTYPE_SIZE) // must have fixed size
debug.DecodeError(binary.Read(bfr, BIGEND, &lrec.vbyts))
debug.DecodeError(binary.Read(bfr, BIGEND, &lrec.crc))
return lrec
}
示例10: 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
}
}
示例11: 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
}
示例12: 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
}
示例13: Purge
// Delete all zapmap records associated with the given logfile number.
func (zmap *Zapmap) Purge(fnum LBUINT, debug *gubed.Logger) {
debug.Basic("Purge zapmap of logfile %d entries", fnum)
for key, zrecs := range zmap.zapmap {
var newzrecs []*ZapRecord // Make a new list to replace old
for _, zrec := range zrecs {
if zrec.fnum != fnum {
newzrecs = append(newzrecs, zrec)
} else {
debug.Fine("Deleting %q%s from zapmap", key, zrec.String())
}
}
if len(newzrecs) == 0 {
zmap.Delete(key)
} else {
zmap.Put(key, newzrecs)
}
}
return
}
示例14: 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
}
示例15: BytesToCatalogId
// Read an CATID from a byte slice.
func BytesToCatalogId(byts []byte, debug *gubed.Logger) (interface{}, error) {
bfr := bytes.NewBuffer(byts)
var cid CATID_TYPE
err := debug.DecodeError(binary.Read(bfr, BIGEND, &cid))
return cid, err
}