1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-13 06:10:39 +00:00

More minor grammar fixes

This commit is contained in:
IamCathal
2020-08-06 16:07:18 +01:00
parent 2fce8f9d1b
commit 1b4bb43df0
34 changed files with 263 additions and 262 deletions

View File

@ -28,7 +28,7 @@ const (
jsonFormat = "JSON_FORMAT"
)
// AccessLogRecord struct for holding access log data.
// AccessLogRecord is astruct for holding access log data.
type AccessLogRecord struct {
RemoteAddr string `json:"remote_addr"`
RequestTime time.Time `json:"request_time"`

View File

@ -11,9 +11,9 @@ import (
)
const (
// CacheSize set the flush size
// CacheSize sets the flush size
CacheSize int = 64
// Delimiter define the topic delimiter
// Delimiter defines the topic delimiter
Delimiter string = "##"
)
@ -31,7 +31,7 @@ type Config struct {
}
// aliLSWriter implements LoggerInterface.
// it writes messages in keep-live tcp connection.
// Writes messages in keep-live tcp connection.
type aliLSWriter struct {
store *LogStore
group []*LogGroup
@ -41,14 +41,14 @@ type aliLSWriter struct {
Config
}
// NewAliLS create a new Logger
// NewAliLS creates a new Logger
func NewAliLS() logs.Logger {
alils := new(aliLSWriter)
alils.Level = logs.LevelTrace
return alils
}
// Init parse config and init struct
// Init parses config and initializes struct
func (c *aliLSWriter) Init(jsonConfig string) (err error) {
json.Unmarshal([]byte(jsonConfig), c)
@ -101,8 +101,8 @@ func (c *aliLSWriter) Init(jsonConfig string) (err error) {
return nil
}
// WriteMsg write message in connection.
// if connection is down, try to re-connect.
// WriteMsg writes a message in connection.
// If connection is down, try to re-connect.
func (c *aliLSWriter) WriteMsg(when time.Time, msg string, level int) (err error) {
if level > c.Level {

View File

@ -4,10 +4,10 @@ const (
version = "0.5.0" // SDK version
signatureMethod = "hmac-sha1" // Signature method
// OffsetNewest stands for the log head offset, i.e. the offset that will be
// OffsetNewest is 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
// OffsetOldest is the the oldest offset available on the logstore for a
// shard.
OffsetOldest = "begin"
)

View File

@ -31,13 +31,13 @@ type Log struct {
// Reset the Log
func (m *Log) Reset() { *m = Log{} }
// String return the Compact Log
// String returns the Compact Log
func (m *Log) String() string { return proto.CompactTextString(m) }
// ProtoMessage not implemented
func (*Log) ProtoMessage() {}
// GetTime return the Log's Time
// GetTime returns the Log's Time
func (m *Log) GetTime() uint32 {
if m != nil && m.Time != nil {
return *m.Time
@ -45,7 +45,7 @@ func (m *Log) GetTime() uint32 {
return 0
}
// GetContents return the Log's Contents
// GetContents returns the Log's Contents
func (m *Log) GetContents() []*LogContent {
if m != nil {
return m.Contents
@ -53,7 +53,7 @@ func (m *Log) GetContents() []*LogContent {
return nil
}
// LogContent define the Log content struct
// LogContent defines the Log content struct
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"`
@ -63,13 +63,13 @@ type LogContent struct {
// Reset LogContent
func (m *LogContent) Reset() { *m = LogContent{} }
// String return the compact text
// String returns the compact text
func (m *LogContent) String() string { return proto.CompactTextString(m) }
// ProtoMessage not implemented
func (*LogContent) ProtoMessage() {}
// GetKey return the Key
// GetKey returns the key
func (m *LogContent) GetKey() string {
if m != nil && m.Key != nil {
return *m.Key
@ -77,7 +77,7 @@ func (m *LogContent) GetKey() string {
return ""
}
// GetValue return the Value
// GetValue returns the value
func (m *LogContent) GetValue() string {
if m != nil && m.Value != nil {
return *m.Value
@ -85,7 +85,7 @@ func (m *LogContent) GetValue() string {
return ""
}
// LogGroup define the logs struct
// LogGroup defines the logs struct
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"`
@ -97,13 +97,13 @@ type LogGroup struct {
// Reset LogGroup
func (m *LogGroup) Reset() { *m = LogGroup{} }
// String return the compact text
// String returns the compact text
func (m *LogGroup) String() string { return proto.CompactTextString(m) }
// ProtoMessage not implemented
func (*LogGroup) ProtoMessage() {}
// GetLogs return the loggroup logs
// GetLogs returns the loggroup logs
func (m *LogGroup) GetLogs() []*Log {
if m != nil {
return m.Logs
@ -111,7 +111,8 @@ func (m *LogGroup) GetLogs() []*Log {
return nil
}
// GetReserved return Reserved
// GetReserved returns Reserved. An empty string is returned
// if an error occurs
func (m *LogGroup) GetReserved() string {
if m != nil && m.Reserved != nil {
return *m.Reserved
@ -119,7 +120,8 @@ func (m *LogGroup) GetReserved() string {
return ""
}
// GetTopic return Topic
// GetTopic returns Topic. An empty string is returned
// if an error occurs
func (m *LogGroup) GetTopic() string {
if m != nil && m.Topic != nil {
return *m.Topic
@ -127,7 +129,8 @@ func (m *LogGroup) GetTopic() string {
return ""
}
// GetSource return Source
// GetSource returns source. An empty string is returned
// if an error occurs
func (m *LogGroup) GetSource() string {
if m != nil && m.Source != nil {
return *m.Source
@ -135,7 +138,7 @@ func (m *LogGroup) GetSource() string {
return ""
}
// LogGroupList define the LogGroups
// LogGroupList defines the LogGroups
type LogGroupList struct {
LogGroups []*LogGroup `protobuf:"bytes,1,rep,name=logGroups" json:"logGroups,omitempty"`
XXXUnrecognized []byte `json:"-"`
@ -144,13 +147,13 @@ type LogGroupList struct {
// Reset LogGroupList
func (m *LogGroupList) Reset() { *m = LogGroupList{} }
// String return compact text
// String returns compact text
func (m *LogGroupList) String() string { return proto.CompactTextString(m) }
// ProtoMessage not implemented
func (*LogGroupList) ProtoMessage() {}
// GetLogGroups return the LogGroups
// GetLogGroups returns the LogGroups
func (m *LogGroupList) GetLogGroups() []*LogGroup {
if m != nil {
return m.LogGroups
@ -158,7 +161,7 @@ func (m *LogGroupList) GetLogGroups() []*LogGroup {
return nil
}
// Marshal the logs to byte slice
// Marshal marshals the logs to byte slice
func (m *Log) Marshal() (data []byte, err error) {
size := m.Size()
data = make([]byte, size)
@ -353,7 +356,7 @@ func encodeVarintLog(data []byte, offset int, v uint64) int {
return offset + 1
}
// Size return the log's size
// Size returns the log's size
func (m *Log) Size() (n int) {
var l int
_ = l
@ -372,7 +375,7 @@ func (m *Log) Size() (n int) {
return n
}
// Size return LogContent size based on Key and Value
// Size returns LogContent size based on Key and Value
func (m *LogContent) Size() (n int) {
var l int
_ = l
@ -390,7 +393,7 @@ func (m *LogContent) Size() (n int) {
return n
}
// Size return LogGroup size based on Logs
// Size returns LogGroup size based on Logs
func (m *LogGroup) Size() (n int) {
var l int
_ = l
@ -418,7 +421,7 @@ func (m *LogGroup) Size() (n int) {
return n
}
// Size return LogGroupList size
// Size returns LogGroupList size
func (m *LogGroupList) Size() (n int) {
var l int
_ = l
@ -448,7 +451,7 @@ func sozLog(x uint64) (n int) {
return sovLog((x << 1) ^ (x >> 63))
}
// Unmarshal data to log
// Unmarshal unmarshals data to log
func (m *Log) Unmarshal(data []byte) error {
var hasFields [1]uint64
l := len(data)
@ -557,7 +560,7 @@ func (m *Log) Unmarshal(data []byte) error {
return nil
}
// Unmarshal data to LogContent
// Unmarshal unmarshals data to LogContent
func (m *LogContent) Unmarshal(data []byte) error {
var hasFields [1]uint64
l := len(data)
@ -679,7 +682,7 @@ func (m *LogContent) Unmarshal(data []byte) error {
return nil
}
// Unmarshal data to LogGroup
// Unmarshal unmarshals data to LogGroup
func (m *LogGroup) Unmarshal(data []byte) error {
l := len(data)
iNdEx := 0
@ -853,7 +856,7 @@ func (m *LogGroup) Unmarshal(data []byte) error {
return nil
}
// Unmarshal data to LogGroupList
// Unmarshal unmarshals data to LogGroupList
func (m *LogGroupList) Unmarshal(data []byte) error {
l := len(data)
iNdEx := 0

View File

@ -1,6 +1,6 @@
package alils
// InputDetail define log detail
// InputDetail defines log detail
type InputDetail struct {
LogType string `json:"logType"`
LogPath string `json:"logPath"`
@ -15,13 +15,13 @@ type InputDetail struct {
TopicFormat string `json:"topicFormat"`
}
// OutputDetail define the output detail
// OutputDetail defines the output detail
type OutputDetail struct {
Endpoint string `json:"endpoint"`
LogStoreName string `json:"logstoreName"`
}
// LogConfig define Log Config
// LogConfig defines Log Config
type LogConfig struct {
Name string `json:"configName"`
InputType string `json:"inputType"`

View File

@ -20,7 +20,7 @@ type errorMessage struct {
Message string `json:"errorMessage"`
}
// LogProject Define the Ali Project detail
// LogProject defines the Ali Project detail
type LogProject struct {
Name string // Project name
Endpoint string // IP or hostname of SLS endpoint

View File

@ -12,7 +12,7 @@ import (
"github.com/gogo/protobuf/proto"
)
// LogStore Store the logs
// LogStore stores the logs
type LogStore struct {
Name string `json:"logstoreName"`
TTL int
@ -24,7 +24,7 @@ type LogStore struct {
project *LogProject
}
// Shard define the Log Shard
// Shard defines the Log Shard
type Shard struct {
ShardID int `json:"shardID"`
}
@ -71,7 +71,7 @@ func (s *LogStore) ListShards() (shardIDs []int, err error) {
return
}
// PutLogs put logs into logstore.
// PutLogs puts logs into logstore.
// The callers should transform user logs into LogGroup.
func (s *LogStore) PutLogs(lg *LogGroup) (err error) {
body, err := proto.Marshal(lg)

View File

@ -8,13 +8,13 @@ import (
"net/http/httputil"
)
// MachineGroupAttribute define the Attribute
// MachineGroupAttribute defines the Attribute
type MachineGroupAttribute struct {
ExternalName string `json:"externalName"`
TopicName string `json:"groupTopic"`
}
// MachineGroup define the machine Group
// MachineGroup defines the machine Group
type MachineGroup struct {
Name string `json:"groupName"`
Type string `json:"groupType"`
@ -29,20 +29,20 @@ type MachineGroup struct {
project *LogProject
}
// Machine define the Machine
// Machine defines the Machine
type Machine struct {
IP string
UniqueID string `json:"machine-uniqueid"`
UserdefinedID string `json:"userdefined-id"`
}
// MachineList define the Machine List
// MachineList defines the Machine List
type MachineList struct {
Total int
Machines []*Machine
}
// ListMachines returns machine list of this machine group.
// ListMachines returns the machine list of this machine group.
func (m *MachineGroup) ListMachines() (ms []*Machine, total int, err error) {
h := map[string]string{
"x-sls-bodyrawsize": "0",

View File

@ -22,7 +22,7 @@ import (
)
// connWriter implements LoggerInterface.
// it writes messages in keep-live tcp connection.
// Writes messages in keep-live tcp connection.
type connWriter struct {
lg *logWriter
innerWriter io.WriteCloser
@ -33,21 +33,21 @@ type connWriter struct {
Level int `json:"level"`
}
// NewConn create new ConnWrite returning as LoggerInterface.
// NewConn creates new ConnWrite returning as LoggerInterface.
func NewConn() Logger {
conn := new(connWriter)
conn.Level = LevelTrace
return conn
}
// Init init connection writer with json config.
// json config only need key "level".
// Init initializes a connection writer with json config.
// json config only needs they "level" key
func (c *connWriter) Init(jsonConfig string) error {
return json.Unmarshal([]byte(jsonConfig), c)
}
// WriteMsg write message in connection.
// if connection is down, try to re-connect.
// WriteMsg writes message in connection.
// If connection is down, try to re-connect.
func (c *connWriter) WriteMsg(when time.Time, msg string, level int) error {
if level > c.Level {
return nil

View File

@ -26,7 +26,7 @@ import (
// brush is a color join function
type brush func(string) string
// newBrush return a fix color Brush
// newBrush returns a fix color Brush
func newBrush(color string) brush {
pre := "\033["
reset := "\033[0m"
@ -53,7 +53,7 @@ type consoleWriter struct {
Colorful bool `json:"color"` //this filed is useful only when system's terminal supports color
}
// NewConsole create ConsoleWriter returning as LoggerInterface.
// NewConsole creates ConsoleWriter returning as LoggerInterface.
func NewConsole() Logger {
cw := &consoleWriter{
lg: newLogWriter(ansicolor.NewAnsiColorWriter(os.Stdout)),
@ -63,8 +63,8 @@ func NewConsole() Logger {
return cw
}
// Init init console logger.
// jsonConfig like '{"level":LevelTrace}'.
// Init initianlizes the console logger.
// jsonConfig must be in the format '{"level":LevelTrace}'
func (c *consoleWriter) Init(jsonConfig string) error {
if len(jsonConfig) == 0 {
return nil
@ -72,7 +72,7 @@ func (c *consoleWriter) Init(jsonConfig string) error {
return json.Unmarshal([]byte(jsonConfig), c)
}
// WriteMsg write message in console.
// WriteMsg writes message in console.
func (c *consoleWriter) WriteMsg(when time.Time, msg string, level int) error {
if level > c.Level {
return nil

View File

@ -15,7 +15,7 @@ import (
"github.com/astaxie/beego/pkg/logs"
)
// NewES return a LoggerInterface
// NewES returns a LoggerInterface
func NewES() logs.Logger {
cw := &esLogger{
Level: logs.LevelDebug,
@ -59,7 +59,7 @@ func (el *esLogger) Init(jsonconfig string) error {
return nil
}
// WriteMsg will write the msg and level into es
// WriteMsg writes the msg and level into es
func (el *esLogger) WriteMsg(when time.Time, msg string, level int) error {
if level > el.Level {
return nil

View File

@ -30,7 +30,7 @@ import (
)
// fileLogWriter implements LoggerInterface.
// It writes messages by lines limit, file size limit, or time frequency.
// Writes messages by lines limit, file size limit, or time frequency.
type fileLogWriter struct {
sync.RWMutex // write log order by order and atomic incr maxLinesCurLines and maxSizeCurSize
// The opened file
@ -71,7 +71,7 @@ type fileLogWriter struct {
fileNameOnly, suffix string // like "project.log", project is fileNameOnly and .log is suffix
}
// newFileWriter create a FileLogWriter returning as LoggerInterface.
// newFileWriter creates a FileLogWriter returning as LoggerInterface.
func newFileWriter() Logger {
w := &fileLogWriter{
Daily: true,
@ -143,7 +143,7 @@ func (w *fileLogWriter) needRotateHourly(size int, hour int) bool {
}
// WriteMsg write logger message into file.
// WriteMsg writes logger message into file.
func (w *fileLogWriter) WriteMsg(when time.Time, msg string, level int) error {
if level > w.Level {
return nil
@ -286,7 +286,7 @@ func (w *fileLogWriter) lines() (int, error) {
return count, nil
}
// DoRotate means it need to write file in new file.
// DoRotate means it needs to write logs into a new file.
// new file name like xx.2013-01-01.log (daily) or xx.001.log (by line or size)
func (w *fileLogWriter) doRotate(logTime time.Time) error {
// file exists
@ -397,7 +397,7 @@ func (w *fileLogWriter) Destroy() {
w.fileWriter.Close()
}
// Flush flush file logger.
// Flush flushes file logger.
// there are no buffering messages in file logger in memory.
// flush file means sync file from disk.
func (w *fileLogWriter) Flush() {

View File

@ -18,7 +18,7 @@ type JLWriter struct {
Level int `json:"level"`
}
// newJLWriter create jiaoliao writer.
// newJLWriter creates jiaoliao writer.
func newJLWriter() Logger {
return &JLWriter{Level: LevelTrace}
}
@ -28,8 +28,8 @@ func (s *JLWriter) Init(jsonconfig string) error {
return json.Unmarshal([]byte(jsonconfig), s)
}
// WriteMsg write message in smtp writer.
// it will send an email with subject and only this message.
// WriteMsg writes message in smtp writer.
// Sends an email with subject and only this message.
func (s *JLWriter) WriteMsg(when time.Time, msg string, level int) error {
if level > s.Level {
return nil

View File

@ -108,7 +108,7 @@ func Register(name string, log newLoggerFunc) {
}
// BeeLogger is default logger in beego application.
// it can contain several providers and log message into all providers.
// Can contain several providers and log message into all providers.
type BeeLogger struct {
lock sync.Mutex
level int
@ -140,7 +140,7 @@ type logMsg struct {
var logMsgPool *sync.Pool
// NewLogger returns a new BeeLogger.
// channelLen means the number of messages in chan(used where asynchronous is true).
// channelLen: the number of messages in chan(used where asynchronous is true).
// if the buffering chan is full, logger adapters write to file or other way.
func NewLogger(channelLens ...int64) *BeeLogger {
bl := new(BeeLogger)
@ -155,7 +155,7 @@ func NewLogger(channelLens ...int64) *BeeLogger {
return bl
}
// Async set the log to asynchronous and start the goroutine
// Async sets the log to asynchronous and start the goroutine
func (bl *BeeLogger) Async(msgLen ...int64) *BeeLogger {
bl.lock.Lock()
defer bl.lock.Unlock()
@ -178,7 +178,7 @@ func (bl *BeeLogger) Async(msgLen ...int64) *BeeLogger {
}
// SetLogger provides a given logger adapter into BeeLogger with config string.
// config need to be correct JSON as string: {"interval":360}.
// config must in in JSON format like {"interval":360}}
func (bl *BeeLogger) setLogger(adapterName string, configs ...string) error {
config := append(configs, "{}")[0]
for _, l := range bl.outputs {
@ -203,7 +203,7 @@ func (bl *BeeLogger) setLogger(adapterName string, configs ...string) error {
}
// SetLogger provides a given logger adapter into BeeLogger with config string.
// config need to be correct JSON as string: {"interval":360}.
// config must in in JSON format like {"interval":360}}
func (bl *BeeLogger) SetLogger(adapterName string, configs ...string) error {
bl.lock.Lock()
defer bl.lock.Unlock()
@ -214,7 +214,7 @@ func (bl *BeeLogger) SetLogger(adapterName string, configs ...string) error {
return bl.setLogger(adapterName, configs...)
}
// DelLogger remove a logger adapter in BeeLogger.
// DelLogger removes a logger adapter in BeeLogger.
func (bl *BeeLogger) DelLogger(adapterName string) error {
bl.lock.Lock()
defer bl.lock.Unlock()
@ -306,9 +306,9 @@ func (bl *BeeLogger) writeMsg(logLevel int, msg string, v ...interface{}) error
return nil
}
// SetLevel Set log message level.
// SetLevel sets log message level.
// If message level (such as LevelDebug) is higher than logger level (such as LevelWarning),
// log providers will not even be sent the message.
// log providers will not be sent the message.
func (bl *BeeLogger) SetLevel(l int) {
bl.level = l
}

View File

@ -14,7 +14,7 @@ type SLACKWriter struct {
Level int `json:"level"`
}
// newSLACKWriter create jiaoliao writer.
// newSLACKWriter creates jiaoliao writer.
func newSLACKWriter() Logger {
return &SLACKWriter{Level: LevelTrace}
}
@ -25,7 +25,7 @@ func (s *SLACKWriter) Init(jsonconfig string) error {
}
// WriteMsg write message in smtp writer.
// it will send an email with subject and only this message.
// Sends an email with subject and only this message.
func (s *SLACKWriter) WriteMsg(when time.Time, msg string, level int) error {
if level > s.Level {
return nil

View File

@ -35,7 +35,7 @@ type SMTPWriter struct {
Level int `json:"level"`
}
// NewSMTPWriter create smtp writer.
// NewSMTPWriter creates the smtp writer.
func newSMTPWriter() Logger {
return &SMTPWriter{Level: LevelTrace}
}
@ -115,8 +115,8 @@ func (s *SMTPWriter) sendMail(hostAddressWithPort string, auth smtp.Auth, fromAd
return client.Quit()
}
// WriteMsg write message in smtp writer.
// it will send an email with subject and only this message.
// WriteMsg writes message in smtp writer.
// Sends an email with subject and only this message.
func (s *SMTPWriter) WriteMsg(when time.Time, msg string, level int) error {
if level > s.Level {
return nil