From 95aa57f7765a205126d2e77096b0ba26dd003216 Mon Sep 17 00:00:00 2001
From: Ethan Buchman <ethan@coinculture.info>
Date: Thu, 14 Apr 2016 18:02:34 -0400
Subject: [PATCH] vm log config opt

---
 erisdb/serve.go  |  3 +++
 evm/vm.go        | 17 +++++++++++------
 server/config.go |  1 +
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/erisdb/serve.go b/erisdb/serve.go
index 478ae9aa..ec998c56 100644
--- a/erisdb/serve.go
+++ b/erisdb/serve.go
@@ -19,6 +19,7 @@ import (
 	"github.com/tendermint/tendermint/node"
 
 	ep "github.com/eris-ltd/eris-db/erisdb/pipe"
+	evm "github.com/eris-ltd/eris-db/evm"
 	"github.com/eris-ltd/eris-db/server"
 
 	edbapp "github.com/eris-ltd/eris-db/tmsp"
@@ -105,6 +106,8 @@ func ServeErisDB(workDir string) (*server.ServeProcess, error) {
 	app := edbapp.NewErisDBApp(state, evsw)
 	app.SetHostAddress(sConf.Consensus.TendermintHost)
 
+	evm.SetDebug(sConf.Logging.VMLog)
+
 	// Start the tmsp listener for state update commands
 	go func() {
 		// TODO config
diff --git a/evm/vm.go b/evm/vm.go
index af947fbc..656350bf 100644
--- a/evm/vm.go
+++ b/evm/vm.go
@@ -36,15 +36,20 @@ func (err ErrPermission) Error() string {
 	return fmt.Sprintf("Contract does not have permission to %s", err.typ)
 }
 
-type Debug bool
-
 const (
-	dataStackCapacity       = 1024
-	callStackCapacity       = 100         // TODO ensure usage.
-	memoryCapacity          = 1024 * 1024 // 1 MB
-	dbg               Debug = true
+	dataStackCapacity = 1024
+	callStackCapacity = 100         // TODO ensure usage.
+	memoryCapacity    = 1024 * 1024 // 1 MB
 )
 
+type Debug bool
+
+var dbg Debug
+
+func SetDebug(d bool) {
+	dbg = Debug(d)
+}
+
 func (d Debug) Printf(s string, a ...interface{}) {
 	if d {
 		fmt.Printf(s, a...)
diff --git a/server/config.go b/server/config.go
index 7354408f..24b94892 100644
--- a/server/config.go
+++ b/server/config.go
@@ -54,6 +54,7 @@ type (
 		ConsoleLogLevel string `toml:"console_log_level"`
 		FileLogLevel    string `toml:"file_log_level"`
 		LogFile         string `toml:"log_file"`
+		VMLog           bool   `toml:"vm_log"`
 	}
 
 	Consensus struct {
-- 
GitLab