Skip to content

Commit

Permalink
Merge pull request #21 from mattaezell/rfc3339
Browse files Browse the repository at this point in the history
Use RFC3339 timestamps
  • Loading branch information
chenglch authored Feb 2, 2018
2 parents be12165 + f4fb4fe commit 1e6b890
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions common/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
const (
PERIODIC_INTERVAL = time.Minute
PIPELINE_SEND_INTERVAL = 300 * time.Millisecond
RFC8601_SECOND = "2006-01-02T15:04:05Z0700"
RFC8601_MILLISECOND = "2006-01-02T15:04:05Z0700.000"
RFC8601_MICROSECOND = "2006-01-02T15:04:05Z0700.000000"
RFC8601_NANOSECOND = "2006-01-02T15:04:05Z0700.000000000"
RFC3339_SECOND = time.RFC3339
RFC3339_MILLISECOND = "2006-01-02T15:04:05.000Z07:00"
RFC3339_MICROSECOND = "2006-01-02T15:04:05.000000Z07:00"
RFC3339_NANOSECOND = "2006-01-02T15:04:05.000000000Z07:00"
CLIENT_CONGO_TYPE = iota
CLIENT_XCAT_TYPE
)
Expand Down Expand Up @@ -49,10 +49,10 @@ var (
"y": true,
}
PRECISION_FORMAT = map[string]string{
"second": RFC8601_SECOND,
"millisecond": RFC8601_MILLISECOND,
"microsecond": RFC8601_MICROSECOND,
"nanosecond": RFC8601_NANOSECOND}
"second": RFC3339_SECOND,
"millisecond": RFC3339_MILLISECOND,
"microsecond": RFC3339_MICROSECOND,
"nanosecond": RFC3339_NANOSECOND}
)

type FileCfg struct {
Expand Down Expand Up @@ -132,7 +132,7 @@ func InitServerConfig(confFile string) (*ServerConfig, error) {
serverConfig.Console.DataDir = "/var/lib/goconserver/"
serverConfig.Console.LogTimestamp = true
serverConfig.Console.TimePrecision = "microsecond"
serverConfig.Console.TimeFormat = RFC8601_MICROSECOND
serverConfig.Console.TimeFormat = RFC3339_MICROSECOND
serverConfig.Console.ReplayLines = 30
serverConfig.Console.ClientTimeout = 30
serverConfig.Console.TargetTimeout = 30
Expand Down
2 changes: 1 addition & 1 deletion console/console.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (self *Console) writeClient(conn net.Conn) {
var ok bool
clientTimeout := time.Duration(serverConfig.Console.ClientTimeout)
welcome := fmt.Sprintf("goconserver(%s): Hello %s, welcome to the session of %s",
time.Now().Format(common.RFC8601_SECOND), conn.RemoteAddr().String(), self.node.StorageNode.Name)
time.Now().Format(common.RFC3339_SECOND), conn.RemoteAddr().String(), self.node.StorageNode.Name)
err := common.Network.SendByteWithLengthTimeout(conn, []byte(welcome+"\r\n"), clientTimeout)
if err != nil {
plog.InfoNode(self.node.StorageNode.Name, fmt.Sprintf("Failed to send message to client. Error:%s", err.Error()))
Expand Down
4 changes: 2 additions & 2 deletions console/pipeline/logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func (self *ByteLogger) insertStamp(b []byte, newLine *bool) ([]byte, error) {
}()
for i := 0; i < len(b); i++ {
if *newLine {
buf.WriteString("\n[" + time.Now().Format(common.RFC8601_SECOND) + "] ")
buf.WriteString("\n[" + time.Now().Format(common.RFC3339_SECOND) + "] ")
*newLine = false
}
if b[i] == '\n' {
Expand Down Expand Up @@ -265,7 +265,7 @@ func (self *ByteLogger) Prompt(node string, message string) error {
message = message + "\r\n"
}
if serverConfig.Console.LogTimestamp {
message = "\r\n[" + time.Now().Format(common.RFC8601_SECOND) + "] " + message
message = "\r\n[" + time.Now().Format(common.RFC3339_SECOND) + "] " + message
}
for _, publisher := range self.publishers {
err = publisher.Publish(node, []byte(message))
Expand Down

0 comments on commit 1e6b890

Please sign in to comment.