Skip to content

Commit

Permalink
create grip logger package, allows passing configured logger to subpr…
Browse files Browse the repository at this point in the history
…ocesses
  • Loading branch information
adamstruck committed Oct 1, 2019
1 parent 891e204 commit 43b0361
Show file tree
Hide file tree
Showing 43 changed files with 237 additions and 73 deletions.
4 changes: 2 additions & 2 deletions cmd/kvload/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/bmeg/grip/gripql"
"github.com/bmeg/grip/kvgraph"
"github.com/bmeg/grip/kvi"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/util"
"github.com/paulbellamy/ratecounter"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -106,7 +106,7 @@ var Cmd = &cobra.Command{

edgeCounter := ratecounter.NewRateCounter(10 * time.Second)
for _, edgeFile := range edgeFileArray {
log.Printf("Loading %s", edgeFile)
log.Infof("Loading %s", edgeFile)
count := 0
for e := range util.StreamEdgesFromFile(edgeFile) {
graphChan <- &gripql.GraphElement{Graph: graph, Edge: e}
Expand Down
2 changes: 1 addition & 1 deletion cmd/load/example/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"github.com/bmeg/grip/gripql"
"github.com/bmeg/grip/gripql/example"

"github.com/bmeg/grip/log"
"github.com/bmeg/grip/util/rpc"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/load/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (

"github.com/bmeg/grip/cmd/load/example"
"github.com/bmeg/grip/gripql"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/util"
"github.com/bmeg/grip/util/rpc"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -61,7 +61,7 @@ var Cmd = &cobra.Command{
wait := make(chan bool)
go func() {
if err := conn.BulkAdd(elemChan); err != nil {
log.Printf("bulk add error: %v", err)
log.Errorf("bulk add error: %v", err)
}
wait <- false
}()
Expand Down
2 changes: 1 addition & 1 deletion cmd/mongoload/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import (
"strings"

"github.com/bmeg/grip/gripql"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/mongo"
"github.com/bmeg/grip/util"
"github.com/bmeg/grip/util/rpc"
"github.com/globalsign/mgo"
"github.com/globalsign/mgo/bson"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/rdf/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"strings"

"github.com/bmeg/grip/gripql"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/util/rpc"
"github.com/golang/protobuf/jsonpb"
"github.com/knakk/rdf"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (
_ "github.com/bmeg/grip/kvi/badgerdb" // import so badger will register itself
_ "github.com/bmeg/grip/kvi/boltdb" // import so bolt will register itself
_ "github.com/bmeg/grip/kvi/leveldb" // import so level will register itself
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/mongo"
"github.com/bmeg/grip/psql"
"github.com/bmeg/grip/server"
_ "github.com/go-sql-driver/mysql" //import so mysql will register as a sql driver
"github.com/imdario/mergo"
_ "github.com/lib/pq" // import so postgres will register as a sql driver
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand All @@ -34,7 +34,7 @@ var schemaFile string
// This opens a database and starts an API server.
// This blocks indefinitely.
func Run(conf *config.Config, schemas map[string]*gripql.Graph) error {
config.ConfigureLogger(conf.Logger)
log.ConfigureLogger(conf.Logger)
log.WithFields(log.Fields{"Config": conf}).Info("Starting Server")

var db gdbi.GraphDB
Expand Down
2 changes: 1 addition & 1 deletion cmd/stream/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import (

"github.com/Shopify/sarama"
"github.com/bmeg/grip/gripql"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/util/rpc"
"github.com/golang/protobuf/jsonpb"
log "github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)

Expand Down
5 changes: 3 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/bmeg/grip/elastic"
esql "github.com/bmeg/grip/existing-sql"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/mongo"
"github.com/bmeg/grip/psql"
"github.com/bmeg/grip/server"
Expand All @@ -35,7 +36,7 @@ type Config struct {
MongoDB mongo.Config
PSQL psql.Config
ExistingSQL esql.Config
Logger Logger
Logger log.Logger
}

// DefaultConfig returns an instance of the default configuration for Grip.
Expand Down Expand Up @@ -65,7 +66,7 @@ func DefaultConfig() *Config {
c.Elasticsearch.DBName = "gripdb"
c.Elasticsearch.BatchSize = 1000

c.Logger = DefaultLoggerConfig()
c.Logger = log.DefaultLoggerConfig()
return c
}

Expand Down
2 changes: 1 addition & 1 deletion elastic/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
"github.com/bmeg/grip/engine/core"
"github.com/bmeg/grip/gdbi"
"github.com/bmeg/grip/gripql"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/timestamp"
"github.com/bmeg/grip/util"
"github.com/golang/protobuf/jsonpb"
log "github.com/sirupsen/logrus"
"golang.org/x/sync/errgroup"
elastic "gopkg.in/olivere/elastic.v5"
)
Expand Down
2 changes: 1 addition & 1 deletion elastic/graphdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (

"github.com/bmeg/grip/gdbi"
"github.com/bmeg/grip/gripql"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/timestamp"
log "github.com/sirupsen/logrus"
elastic "gopkg.in/olivere/elastic.v5"
)

Expand Down
2 changes: 1 addition & 1 deletion elastic/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/bmeg/grip/gripql"
"github.com/bmeg/grip/jsonpath"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/protoutil"
log "github.com/sirupsen/logrus"
elastic "gopkg.in/olivere/elastic.v5"
)

Expand Down
2 changes: 1 addition & 1 deletion elastic/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package elastic
import (
"context"

log "github.com/sirupsen/logrus"
"github.com/bmeg/grip/log"
elastic "gopkg.in/olivere/elastic.v5"
)

Expand Down
2 changes: 1 addition & 1 deletion engine/core/processors.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/bmeg/grip/jsonpath"
"github.com/bmeg/grip/kvi"
"github.com/bmeg/grip/kvindex"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/protoutil"
structpb "github.com/golang/protobuf/ptypes/struct"
log "github.com/sirupsen/logrus"
"github.com/spenczar/tdigest"
"github.com/spf13/cast"
"golang.org/x/sync/errgroup"
Expand Down
2 changes: 1 addition & 1 deletion engine/pipes.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (

"github.com/bmeg/grip/gdbi"
"github.com/bmeg/grip/gripql"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/protoutil"
log "github.com/sirupsen/logrus"
)

// Start begins processing a query pipeline
Expand Down
4 changes: 2 additions & 2 deletions existing-sql/graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
"github.com/bmeg/grip/engine/core"
"github.com/bmeg/grip/gdbi"
"github.com/bmeg/grip/gripql"
"github.com/bmeg/grip/log"
"github.com/bmeg/grip/timestamp"
"github.com/jmoiron/sqlx"
log "github.com/sirupsen/logrus"
)

// Graph is the interface to a single graph
Expand Down Expand Up @@ -194,7 +194,7 @@ func (g *Graph) VertexLabelScan(ctx context.Context, label string) chan string {
data := make(map[string]interface{})
if err := rows.MapScan(data); err != nil {
log.WithFields(log.Fields{"error": err}).Error("VertexLabelScan: MapScan")
log.Println("VertexLabelScan failed:", err)
log.Errorln("VertexLabelScan failed:", err)
return
}
v := rowDataToVertex(v, data, types, false)
Expand Down
Loading

0 comments on commit 43b0361

Please sign in to comment.