Permalink
Browse files

Add pid field to log record

  • Loading branch information...
1 parent 848d104 commit 259a27c533479d1a40951e08ed3a4bf6c7be1351 @pietern pietern committed Jan 29, 2013
Showing with 15 additions and 0 deletions.
  1. +9 −0 record.go
  2. +6 −0 record_test.go
View
9 record.go
@@ -1,6 +1,7 @@
package steno
import (
+ "os"
"runtime"
"strings"
"time"
@@ -9,6 +10,7 @@ import (
// FIXME: Missing fields
type Record struct {
Timestamp float64
+ Pid int
Source string
Level LogLevel
Message string
@@ -18,9 +20,16 @@ type Record struct {
Method string
}
+var pid int
+
+func init() {
+ pid = os.Getpid()
+}
+
func NewRecord(s string, l LogLevel, m string, d map[string]string) *Record {
r := &Record{
Timestamp: float64(time.Now().UnixNano()) / 1000000000,
+ Pid: pid,
Source: s,
Level: l,
Message: m,
View
6 record_test.go
@@ -25,3 +25,9 @@ func (s *RecordSuite) TestNewRecordWithoutLOC(c *C) {
c.Check(r.Line, Equals, 0)
c.Check(r.Method, Equals, "")
}
+
+func (s *RecordSuite) TestRecordPid(c *C) {
+ r := NewRecord("source", LOG_INFO, "hello", map[string]string{})
+
+ c.Check(r.Pid, Not(Equals), 0)
+}

0 comments on commit 259a27c

Please sign in to comment.