beego: github.com/astaxie/beego/logs/alils Index | Files

package alils

import "github.com/astaxie/beego/logs/alils"

Package alils implements the SDK(v0.5.0) of Simple Log Service(abbr. SLS).

For more description about SLS, please read this article: http://gitlab.alibaba-inc.com/sls/doc.

Index

Package Files

alils.go config.go log.pb.go log_config.go log_project.go log_store.go machine_group.go request.go signature.go

Constants

const (
    // CacheSize set the flush size
    CacheSize int = 64
    // Delimiter define the topic delimiter
    Delimiter string = "##"
)
const (

    // OffsetNewest stands for the log head offset, i.e. the offset that will be
    // assigned to the next message that will be produced to the shard.
    OffsetNewest = "end"
    // OffsetOldest stands for the oldest offset available on the logstore for a
    // shard.
    OffsetOldest = "begin"
)

Variables

var (
    // ErrInvalidLengthLog invalid proto
    ErrInvalidLengthLog = fmt.Errorf("proto: negative length found during unmarshaling")
    // ErrIntOverflowLog overflow
    ErrIntOverflowLog = fmt.Errorf("proto: integer overflow")
)

func NewAliLS Uses

func NewAliLS() logs.Logger

NewAliLS create a new Logger

type Config Uses

type Config struct {
    Project   string   `json:"project"`
    Endpoint  string   `json:"endpoint"`
    KeyID     string   `json:"key_id"`
    KeySecret string   `json:"key_secret"`
    LogStore  string   `json:"log_store"`
    Topics    []string `json:"topics"`
    Source    string   `json:"source"`
    Level     int      `json:"level"`
    FlushWhen int      `json:"flush_when"`
}

Config is the Config for Ali Log

type InputDetail Uses

type InputDetail struct {
    LogType       string   `json:"logType"`
    LogPath       string   `json:"logPath"`
    FilePattern   string   `json:"filePattern"`
    LocalStorage  bool     `json:"localStorage"`
    TimeFormat    string   `json:"timeFormat"`
    LogBeginRegex string   `json:"logBeginRegex"`
    Regex         string   `json:"regex"`
    Keys          []string `json:"key"`
    FilterKeys    []string `json:"filterKey"`
    FilterRegex   []string `json:"filterRegex"`
    TopicFormat   string   `json:"topicFormat"`
}

InputDetail define log detail

type Log Uses

type Log struct {
    Time            *uint32       `protobuf:"varint,1,req,name=Time" json:"Time,omitempty"`
    Contents        []*LogContent `protobuf:"bytes,2,rep,name=Contents" json:"Contents,omitempty"`
    XXXUnrecognized []byte        `json:"-"`
}

Log define the proto Log

func (*Log) GetContents Uses

func (m *Log) GetContents() []*LogContent

GetContents return the Log's Contents

func (*Log) GetTime Uses

func (m *Log) GetTime() uint32

GetTime return the Log's Time

func (*Log) Marshal Uses

func (m *Log) Marshal() (data []byte, err error)

Marshal the logs to byte slice

func (*Log) MarshalTo Uses

func (m *Log) MarshalTo(data []byte) (int, error)

MarshalTo data

func (*Log) ProtoMessage Uses

func (*Log) ProtoMessage()

ProtoMessage not implemented

func (*Log) Reset Uses

func (m *Log) Reset()

Reset the Log

func (*Log) Size Uses

func (m *Log) Size() (n int)

Size return the log's size

func (*Log) String Uses

func (m *Log) String() string

String return the Compact Log

func (*Log) Unmarshal Uses

func (m *Log) Unmarshal(data []byte) error

Unmarshal data to log

type LogConfig Uses

type LogConfig struct {
    Name         string       `json:"configName"`
    InputType    string       `json:"inputType"`
    InputDetail  InputDetail  `json:"inputDetail"`
    OutputType   string       `json:"outputType"`
    OutputDetail OutputDetail `json:"outputDetail"`

    CreateTime     uint32
    LastModifyTime uint32
    // contains filtered or unexported fields
}

LogConfig define Log Config

func (*LogConfig) GetAppliedMachineGroup Uses

func (c *LogConfig) GetAppliedMachineGroup(confName string) (groupNames []string, err error)

GetAppliedMachineGroup returns applied machine group of this config.

type LogContent Uses

type LogContent struct {
    Key             *string `protobuf:"bytes,1,req,name=Key" json:"Key,omitempty"`
    Value           *string `protobuf:"bytes,2,req,name=Value" json:"Value,omitempty"`
    XXXUnrecognized []byte  `json:"-"`
}

LogContent define the Log content struct

func (*LogContent) GetKey Uses

func (m *LogContent) GetKey() string

GetKey return the Key

func (*LogContent) GetValue Uses

func (m *LogContent) GetValue() string

GetValue return the Value

func (*LogContent) Marshal Uses

func (m *LogContent) Marshal() (data []byte, err error)

Marshal LogContent

func (*LogContent) MarshalTo Uses

func (m *LogContent) MarshalTo(data []byte) (int, error)

MarshalTo logcontent to data

func (*LogContent) ProtoMessage Uses

func (*LogContent) ProtoMessage()

ProtoMessage not implemented

func (*LogContent) Reset Uses

func (m *LogContent) Reset()

Reset LogContent

func (*LogContent) Size Uses

func (m *LogContent) Size() (n int)

Size return LogContent size based on Key and Value

func (*LogContent) String Uses

func (m *LogContent) String() string

String return the compact text

func (*LogContent) Unmarshal Uses

func (m *LogContent) Unmarshal(data []byte) error

Unmarshal data to LogContent

type LogGroup Uses

type LogGroup struct {
    Logs            []*Log  `protobuf:"bytes,1,rep,name=Logs" json:"Logs,omitempty"`
    Reserved        *string `protobuf:"bytes,2,opt,name=Reserved" json:"Reserved,omitempty"`
    Topic           *string `protobuf:"bytes,3,opt,name=Topic" json:"Topic,omitempty"`
    Source          *string `protobuf:"bytes,4,opt,name=Source" json:"Source,omitempty"`
    XXXUnrecognized []byte  `json:"-"`
}

LogGroup define the logs struct

func (*LogGroup) GetLogs Uses

func (m *LogGroup) GetLogs() []*Log

GetLogs return the loggroup logs

func (*LogGroup) GetReserved Uses

func (m *LogGroup) GetReserved() string

GetReserved return Reserved

func (*LogGroup) GetSource Uses

func (m *LogGroup) GetSource() string

GetSource return Source

func (*LogGroup) GetTopic Uses

func (m *LogGroup) GetTopic() string

GetTopic return Topic

func (*LogGroup) Marshal Uses

func (m *LogGroup) Marshal() (data []byte, err error)

Marshal LogGroup

func (*LogGroup) MarshalTo Uses

func (m *LogGroup) MarshalTo(data []byte) (int, error)

MarshalTo LogGroup to data

func (*LogGroup) ProtoMessage Uses

func (*LogGroup) ProtoMessage()

ProtoMessage not implemented

func (*LogGroup) Reset Uses

func (m *LogGroup) Reset()

Reset LogGroup

func (*LogGroup) Size Uses

func (m *LogGroup) Size() (n int)

Size return LogGroup size based on Logs

func (*LogGroup) String Uses

func (m *LogGroup) String() string

String return the compact text

func (*LogGroup) Unmarshal Uses

func (m *LogGroup) Unmarshal(data []byte) error

Unmarshal data to LogGroup

type LogGroupList Uses

type LogGroupList struct {
    LogGroups       []*LogGroup `protobuf:"bytes,1,rep,name=logGroups" json:"logGroups,omitempty"`
    XXXUnrecognized []byte      `json:"-"`
}

LogGroupList define the LogGroups

func LogsBytesDecode Uses

func LogsBytesDecode(data []byte) (gl *LogGroupList, err error)

LogsBytesDecode decodes logs binary data retruned by GetLogsBytes API

func (*LogGroupList) GetLogGroups Uses

func (m *LogGroupList) GetLogGroups() []*LogGroup

GetLogGroups return the LogGroups

func (*LogGroupList) Marshal Uses

func (m *LogGroupList) Marshal() (data []byte, err error)

Marshal LogGroupList

func (*LogGroupList) MarshalTo Uses

func (m *LogGroupList) MarshalTo(data []byte) (int, error)

MarshalTo LogGroupList to data

func (*LogGroupList) ProtoMessage Uses

func (*LogGroupList) ProtoMessage()

ProtoMessage not implemented

func (*LogGroupList) Reset Uses

func (m *LogGroupList) Reset()

Reset LogGroupList

func (*LogGroupList) Size Uses

func (m *LogGroupList) Size() (n int)

Size return LogGroupList size

func (*LogGroupList) String Uses

func (m *LogGroupList) String() string

String return compact text

func (*LogGroupList) Unmarshal Uses

func (m *LogGroupList) Unmarshal(data []byte) error

Unmarshal data to LogGroupList

type LogProject Uses

type LogProject struct {
    Name            string // Project name
    Endpoint        string // IP or hostname of SLS endpoint
    AccessKeyID     string
    AccessKeySecret string
}

LogProject Define the Ali Project detail

func NewLogProject Uses

func NewLogProject(name, endpoint, AccessKeyID, accessKeySecret string) (p *LogProject, err error)

NewLogProject creates a new SLS project.

func (*LogProject) ApplyConfigToMachineGroup Uses

func (p *LogProject) ApplyConfigToMachineGroup(confName, groupName string) (err error)

ApplyConfigToMachineGroup applies config to machine group.

func (*LogProject) CreateConfig Uses

func (p *LogProject) CreateConfig(c *LogConfig) (err error)

CreateConfig creates a new config in SLS.

func (*LogProject) CreateLogStore Uses

func (p *LogProject) CreateLogStore(name string, ttl, shardCnt int) (err error)

CreateLogStore creates a new logstore in SLS, where name is logstore name, and ttl is time-to-live(in day) of logs, and shardCnt is the number of shards.

func (*LogProject) CreateMachineGroup Uses

func (p *LogProject) CreateMachineGroup(m *MachineGroup) (err error)

CreateMachineGroup creates a new machine group in SLS.

func (*LogProject) DeleteConfig Uses

func (p *LogProject) DeleteConfig(name string) (err error)

DeleteConfig deletes a config according by config name.

func (*LogProject) DeleteLogStore Uses

func (p *LogProject) DeleteLogStore(name string) (err error)

DeleteLogStore deletes a logstore according by logstore name.

func (*LogProject) DeleteMachineGroup Uses

func (p *LogProject) DeleteMachineGroup(name string) (err error)

DeleteMachineGroup deletes machine group according machine group name.

func (*LogProject) GetAppliedConfigs Uses

func (p *LogProject) GetAppliedConfigs(groupName string) (confNames []string, err error)

GetAppliedConfigs returns applied config names list according machine group name groupName.

func (*LogProject) GetAppliedMachineGroups Uses

func (p *LogProject) GetAppliedMachineGroups(confName string) (groupNames []string, err error)

GetAppliedMachineGroups returns applied machine group names list according config name.

func (*LogProject) GetConfig Uses

func (p *LogProject) GetConfig(name string) (c *LogConfig, err error)

GetConfig returns config according by config name.

func (*LogProject) GetLogStore Uses

func (p *LogProject) GetLogStore(name string) (s *LogStore, err error)

GetLogStore returns logstore according by logstore name.

func (*LogProject) GetMachineGroup Uses

func (p *LogProject) GetMachineGroup(name string) (m *MachineGroup, err error)

GetMachineGroup retruns machine group according by machine group name.

func (*LogProject) ListConfig Uses

func (p *LogProject) ListConfig(offset, size int) (cfgNames []string, total int, err error)

ListConfig returns config names list and the total number of configs. The offset starts from 0 and the size is the max number of configs could be returned.

func (*LogProject) ListLogStore Uses

func (p *LogProject) ListLogStore() (storeNames []string, err error)

ListLogStore returns all logstore names of project p.

func (*LogProject) ListMachineGroup Uses

func (p *LogProject) ListMachineGroup(offset, size int) (m []string, total int, err error)

ListMachineGroup returns machine group name list and the total number of machine groups. The offset starts from 0 and the size is the max number of machine groups could be returned.

func (*LogProject) RemoveConfigFromMachineGroup Uses

func (p *LogProject) RemoveConfigFromMachineGroup(confName, groupName string) (err error)

RemoveConfigFromMachineGroup removes config from machine group.

func (*LogProject) UpdateConfig Uses

func (p *LogProject) UpdateConfig(c *LogConfig) (err error)

UpdateConfig updates a config.

func (*LogProject) UpdateLogStore Uses

func (p *LogProject) UpdateLogStore(name string, ttl, shardCnt int) (err error)

UpdateLogStore updates a logstore according by logstore name, obviously we can't modify the logstore name itself.

func (*LogProject) UpdateMachineGroup Uses

func (p *LogProject) UpdateMachineGroup(m *MachineGroup) (err error)

UpdateMachineGroup updates a machine group.

type LogStore Uses

type LogStore struct {
    Name       string `json:"logstoreName"`
    TTL        int
    ShardCount int

    CreateTime     uint32
    LastModifyTime uint32
    // contains filtered or unexported fields
}

LogStore Store the logs

func (*LogStore) GetCursor Uses

func (s *LogStore) GetCursor(shardID int, from string) (cursor string, err error)

GetCursor gets log cursor of one shard specified by shardID. The from can be in three form: a) unix timestamp in seccond, b) "begin", c) "end". For more detail please read: http://gitlab.alibaba-inc.com/sls/doc/blob/master/api/shard.md#logstore

func (*LogStore) GetLogs Uses

func (s *LogStore) GetLogs(shardID int, cursor string,
    logGroupMaxCount int) (gl *LogGroupList, nextCursor string, err error)

GetLogs gets logs from shard specified by shardID according cursor. The logGroupMaxCount is the max number of logGroup could be returned. The nextCursor is the next curosr can be used to read logs at next time.

func (*LogStore) GetLogsBytes Uses

func (s *LogStore) GetLogsBytes(shardID int, cursor string,
    logGroupMaxCount int) (out []byte, nextCursor string, err error)

GetLogsBytes gets logs binary data from shard specified by shardID according cursor. The logGroupMaxCount is the max number of logGroup could be returned. The nextCursor is the next curosr can be used to read logs at next time.

func (*LogStore) ListShards Uses

func (s *LogStore) ListShards() (shardIDs []int, err error)

ListShards returns shard id list of this logstore.

func (*LogStore) PutLogs Uses

func (s *LogStore) PutLogs(lg *LogGroup) (err error)

PutLogs put logs into logstore. The callers should transform user logs into LogGroup.

type Machine Uses

type Machine struct {
    IP            string
    UniqueID      string `json:"machine-uniqueid"`
    UserdefinedID string `json:"userdefined-id"`
}

Machine define the Machine

type MachineGroup Uses

type MachineGroup struct {
    Name          string   `json:"groupName"`
    Type          string   `json:"groupType"`
    MachineIDType string   `json:"machineIdentifyType"`
    MachineIDList []string `json:"machineList"`

    Attribute MachineGroupAttribute `json:"groupAttribute"`

    CreateTime     uint32
    LastModifyTime uint32
    // contains filtered or unexported fields
}

MachineGroup define the machine Group

func (*MachineGroup) GetAppliedConfigs Uses

func (m *MachineGroup) GetAppliedConfigs() (confNames []string, err error)

GetAppliedConfigs returns applied configs of this machine group.

func (*MachineGroup) ListMachines Uses

func (m *MachineGroup) ListMachines() (ms []*Machine, total int, err error)

ListMachines returns machine list of this machine group.

type MachineGroupAttribute Uses

type MachineGroupAttribute struct {
    ExternalName string `json:"externalName"`
    TopicName    string `json:"groupTopic"`
}

MachineGroupAttribute define the Attribute

type MachineList Uses

type MachineList struct {
    Total    int
    Machines []*Machine
}

MachineList define the Machine List

type OutputDetail Uses

type OutputDetail struct {
    Endpoint     string `json:"endpoint"`
    LogStoreName string `json:"logstoreName"`
}

OutputDetail define the output detail

type Shard Uses

type Shard struct {
    ShardID int `json:"shardID"`
}

Shard define the Log Shard

Package alils imports 21 packages (graph). Updated 2017-05-07. Refresh now. Tools for package owners. This is an inactive package (no imports and no commits in at least two years).