Skip to content

Commit 02bbd83

Browse files
authored
Removed context, lowered info log level to debug and some small millisecond time log. (hyperjumptech#29)
* Moved operators functions from Expression to our reflectmath.go * Removed DataContext from context package to avoid confusion, I know that this update is not additive, but better remove this. * Lowered log level from info to debug that emit on the start and ends of execute * Make proper duration millisecond debug
1 parent 1a23c03 commit 02bbd83

File tree

6 files changed

+8
-225
lines changed

6 files changed

+8
-225
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build:
88

99
test: build
1010
go test ./... -v -covermode=count -coverprofile=coverage.out
11-
golint -set_exit_status builder/... context/... engine/... examples/... ast/... pkg/... antlr/.
11+
golint -set_exit_status builder/... engine/... examples/... ast/... pkg/... antlr/.
1212

1313
test-coverage: test
1414
go tool cover -html=coverage.out

context/DataContext_test.go renamed to ast/DataContext_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
package context
1+
package ast
22

33
import (
44
"fmt"
5-
"github.com/hyperjumptech/grule-rule-engine/pkg"
65
"reflect"
76
"testing"
7+
8+
"github.com/hyperjumptech/grule-rule-engine/pkg"
89
)
910

1011
type TestAStruct struct {

context/DataContext.go

Lines changed: 0 additions & 213 deletions
This file was deleted.

context/KnowledgeContext.go

Lines changed: 0 additions & 6 deletions
This file was deleted.

engine/GruleEngine.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func (g *GruleEngine) notifySubscribers(r *ast.RuleEntry) {
4646
// Execute function will execute a knowledge evaluation and action against data context.
4747
// The engine also do conflict resolution of which rule to execute.
4848
func (g *GruleEngine) Execute(dataCtx *ast.DataContext, knowledge *ast.KnowledgeBase, memory *ast.WorkingMemory) error {
49-
log.Infof("Starting rule execution using knowledge '%s' version %s. Contains %d rule entries", knowledge.Name, knowledge.Version, len(knowledge.RuleEntries))
49+
log.Debugf("Starting rule execution using knowledge '%s' version %s. Contains %d rule entries", knowledge.Name, knowledge.Version, len(knowledge.RuleEntries))
5050

5151
knowledge.WorkingMemory = memory
5252

@@ -137,6 +137,6 @@ func (g *GruleEngine) Execute(dataCtx *ast.DataContext, knowledge *ast.Knowledge
137137
break
138138
}
139139
}
140-
log.Infof("Finished Rules execution. With knowledge base '%s' version %s. Total #%d cycles. Duration %d microsec.", knowledge.Name, knowledge.Version, cycle, time.Now().Sub(startTime))
140+
log.Debugf("Finished Rules execution. With knowledge base '%s' version %s. Total #%d cycles. Duration %d ms.", knowledge.Name, knowledge.Version, cycle, time.Now().Sub(startTime).Milliseconds())
141141
return nil
142142
}

engine/GruleEngine_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ rule SetTime "When Distance Recorder time not set, set it." {
8686
)
8787

8888
func TestGrule_Execute(t *testing.T) {
89+
logrus.SetLevel(logrus.DebugLevel)
8990
tc := &TestCar{
9091
SpeedUp: true,
9192
Speed: 0,
@@ -121,7 +122,7 @@ func TestGrule_Execute(t *testing.T) {
121122
} else {
122123
dur := time.Since(start)
123124
t.Log(dr.TotalDistance)
124-
t.Logf("Duration %f ms", float64(dur)/float64(time.Millisecond))
125+
t.Logf("Duration %d ms", dur.Milliseconds())
125126
}
126127
}
127128
}

0 commit comments

Comments
 (0)