outlining stuff

master
Jordan Orelli 5 years ago
parent afd6577c9f
commit 2a6224532b

@ -0,0 +1,6 @@
package blammo
type Codec interface {
Encode(*Event, []byte) error
Decode(*Event, []byte) error
}

@ -0,0 +1,27 @@
package blammo
import (
"time"
)
// Event is a single log record. A log line if you're writing to file, a
// database row if you're writing to a database, etc. Everything internally is
// expressed as an event.
//
// Event is exported to support the implementation of custom log writers.
type Event struct {
// severity of the event
Level Level
// time at which the event occured
Time time.Time
// where the event occurred in the system
Path *Path
// message to be logged
Text string
// key-value pairs to log as extra metadata
Tags *Tags
}

@ -1,3 +1,5 @@
module github.com/jordanorelli/blammo module github.com/jordanorelli/blammo
go 1.13 go 1.13
require golang.org/x/crypto v0.0.0-20200117160349-530e935923ad // indirect

@ -0,0 +1,8 @@
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200117160349-530e935923ad h1:Jh8cai0fqIK+f6nG0UgPW5wFk8wmiMhM3AyciDBdtQg=
golang.org/x/crypto v0.0.0-20200117160349-530e935923ad/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

@ -0,0 +1,4 @@
package blammo
type JSONWriter struct {
}

@ -0,0 +1,23 @@
package blammo
type Level uint
const (
// Debug is intended to be used for verbose logging information of
// implementation details.
Debug Level = iota
// Info is intended to be used to report expected behaviors; it's used to
// log usage and observe normal behaviors.
Info
// Warn is intended to be used to report events that are not along the
// expected "happy path" of the application. These events should generally
// represent failures of -other- systems.
Warn
// Error is intended to b e used to report things that the application was
// not able to handle. These events should generally represent failures of
// the system at hand.
Error
)

@ -0,0 +1,4 @@
package blammo
type LineWriter struct {
}

@ -39,6 +39,9 @@ func (p *Path) String() string {
// Child creates a child path having parent p. This is the recommended way of // Child creates a child path having parent p. This is the recommended way of
// constructing a hierarchical path. // constructing a hierarchical path.
func (p *Path) Child(name string) *Path { func (p *Path) Child(name string) *Path {
if name == "" {
name = "-"
}
return &Path{ return &Path{
name: MakeSafeName(name), name: MakeSafeName(name),
parent: p, parent: p,

@ -56,6 +56,9 @@ func TestSafeNames(t *testing.T) {
"one ", "one ",
"alice/bob", "alice/bob",
"alice bob", "alice bob",
"alice[bob]",
"alice{bob}",
"alice=bob",
} }
for _, n := range unsafeNames { for _, n := range unsafeNames {
if IsSafeName(n) { if IsSafeName(n) {

@ -0,0 +1,7 @@
package blammo
type Tags struct {
key string
value interface{}
parent *Tags
}

@ -0,0 +1,4 @@
package blammo
type TextWriter struct {
}

@ -0,0 +1,5 @@
package blammo
type EventWriter interface {
WriteEvent(*Event) error
}
Loading…
Cancel
Save