ethlog => logger

This commit is contained in:
obscuren
2014-10-31 12:56:05 +01:00
parent fd9da72536
commit b1c247231b
33 changed files with 146 additions and 146 deletions

View File

@@ -23,9 +23,9 @@ import (
"strconv"
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/ethlog"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/utils"
)
@@ -35,7 +35,7 @@ type plugin struct {
}
// LogPrint writes to the GUI log.
func (gui *Gui) LogPrint(level ethlog.LogLevel, msg string) {
func (gui *Gui) LogPrint(level logger.LogLevel, msg string) {
/*
str := strings.TrimRight(s, "\n")
lines := strings.Split(str, "\n")
@@ -74,14 +74,14 @@ func (gui *Gui) ToggleTurboMining() {
gui.miner.ToggleTurbo()
}
// functions that allow Gui to implement interface ethlog.LogSystem
func (gui *Gui) SetLogLevel(level ethlog.LogLevel) {
// functions that allow Gui to implement interface guilogger.LogSystem
func (gui *Gui) SetLogLevel(level logger.LogLevel) {
gui.logLevel = level
gui.stdLog.SetLogLevel(level)
gui.config.Save("loglevel", level)
}
func (gui *Gui) GetLogLevel() ethlog.LogLevel {
func (gui *Gui) GetLogLevel() logger.LogLevel {
return gui.logLevel
}
@@ -119,7 +119,7 @@ func (self *Gui) DumpState(hash, path string) {
}
if block == nil {
logger.Infof("block err: not found %s\n", hash)
guilogger.Infof("block err: not found %s\n", hash)
return
}
@@ -128,12 +128,12 @@ func (self *Gui) DumpState(hash, path string) {
file, err := os.OpenFile(path[7:], os.O_CREATE|os.O_RDWR, os.ModePerm)
if err != nil {
logger.Infoln("dump err: ", err)
guilogger.Infoln("dump err: ", err)
return
}
defer file.Close()
logger.Infof("dumped state (%s) to %s\n", hash, path)
guilogger.Infof("dumped state (%s) to %s\n", hash, path)
file.Write(stateDump)
}

View File

@@ -74,7 +74,7 @@ func (app *ExtApplication) run() {
err := app.container.Create()
if err != nil {
logger.Errorln(err)
guilogger.Errorln(err)
return
}

View File

@@ -28,7 +28,6 @@ import (
"runtime"
"bitbucket.org/kardianos/osext"
"github.com/ethereum/go-ethereum/ethlog"
"github.com/ethereum/go-ethereum/vm"
)
@@ -117,7 +116,7 @@ func Init() {
flag.StringVar(&Datadir, "datadir", defaultDataDir(), "specifies the datadir to use")
flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file")
flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)")
flag.IntVar(&LogLevel, "loglevel", int(ethlog.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)")
flag.IntVar(&LogLevel, "loglevel", int(repllogger.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)")
flag.StringVar(&AssetPath, "asset_path", defaultAssetPath(), "absolute path to GUI assets directory")

View File

@@ -33,11 +33,11 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethlog"
"github.com/ethereum/go-ethereum/ethminer"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethwire"
"github.com/ethereum/go-ethereum/logger"
"gopkg.in/qml.v1"
)
@@ -64,7 +64,7 @@ func LoadExtension(path string) (uintptr, error) {
}
*/
var logger = ethlog.NewLogger("GUI")
var guilogger = logger.NewLogger("GUI")
type Gui struct {
// The main application window
@@ -81,7 +81,7 @@ type Gui struct {
txDb *ethdb.LDBDatabase
logLevel ethlog.LogLevel
logLevel logger.LogLevel
open bool
pipe *ethpipe.JSPipe
@@ -93,7 +93,7 @@ type Gui struct {
plugins map[string]plugin
miner *ethminer.Miner
stdLog ethlog.LogSystem
stdLog logger.LogSystem
}
// Create GUI, but doesn't start it
@@ -104,7 +104,7 @@ func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, clientIden
}
pipe := ethpipe.NewJSPipe(ethereum)
gui := &Gui{eth: ethereum, txDb: db, pipe: pipe, logLevel: ethlog.LogLevel(logLevel), Session: session, open: false, clientIdentity: clientIdentity, config: config, plugins: make(map[string]plugin)}
gui := &Gui{eth: ethereum, txDb: db, pipe: pipe, logLevel: logger.LogLevel(logLevel), Session: session, open: false, clientIdentity: clientIdentity, config: config, plugins: make(map[string]plugin)}
data, _ := ethutil.ReadAllFile(path.Join(ethutil.Config.ExecPath, "plugins.json"))
json.Unmarshal([]byte(data), &gui.plugins)
@@ -155,36 +155,36 @@ func (gui *Gui) Start(assetPath string) {
addlog = true
}
if err != nil {
logger.Errorln("asset not found: you can set an alternative asset path on the command line using option 'asset_path'", err)
guilogger.Errorln("asset not found: you can set an alternative asset path on the command line using option 'asset_path'", err)
panic(err)
}
logger.Infoln("Starting GUI")
guilogger.Infoln("Starting GUI")
gui.open = true
win.Show()
// only add the gui logger after window is shown otherwise slider wont be shown
// only add the gui guilogger after window is shown otherwise slider wont be shown
if addlog {
ethlog.AddLogSystem(gui)
logger.AddLogSystem(gui)
}
win.Wait()
// need to silence gui logger after window closed otherwise logsystem hangs (but do not save loglevel)
gui.logLevel = ethlog.Silence
// need to silence gui guilogger after window closed otherwise logsystem hangs (but do not save loglevel)
gui.logLevel = logger.Silence
gui.open = false
}
func (gui *Gui) Stop() {
if gui.open {
gui.logLevel = ethlog.Silence
gui.logLevel = logger.Silence
gui.open = false
gui.win.Hide()
}
gui.uiLib.jsEngine.Stop()
logger.Infoln("Stopped")
guilogger.Infoln("Stopped")
}
func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) {
@@ -229,17 +229,17 @@ func (gui *Gui) createWindow(comp qml.Object) *qml.Window {
func (gui *Gui) ImportAndSetPrivKey(secret string) bool {
err := gui.eth.KeyManager().InitFromString(gui.Session, 0, secret)
if err != nil {
logger.Errorln("unable to import: ", err)
guilogger.Errorln("unable to import: ", err)
return false
}
logger.Errorln("successfully imported: ", err)
guilogger.Errorln("successfully imported: ", err)
return true
}
func (gui *Gui) CreateAndSetPrivKey() (string, string, string, string) {
err := gui.eth.KeyManager().Init(gui.Session, 0, true)
if err != nil {
logger.Errorln("unable to create key: ", err)
guilogger.Errorln("unable to create key: ", err)
return "", "", "", ""
}
return gui.eth.KeyManager().KeyPair().AsStrings()
@@ -387,7 +387,7 @@ func (gui *Gui) update() {
}()
for _, plugin := range gui.plugins {
logger.Infoln("Loading plugin ", plugin.Name)
guilogger.Infoln("Loading plugin ", plugin.Name)
gui.win.Root().Call("addPlugin", plugin.Path, "")
}

View File

@@ -98,12 +98,12 @@ func (app *HtmlApplication) NewWatcher(quitChan chan bool) {
app.watcher, err = fsnotify.NewWatcher()
if err != nil {
logger.Infoln("Could not create new auto-reload watcher:", err)
guilogger.Infoln("Could not create new auto-reload watcher:", err)
return
}
err = app.watcher.Watch(app.RootFolder())
if err != nil {
logger.Infoln("Could not start auto-reload watcher:", err)
guilogger.Infoln("Could not start auto-reload watcher:", err)
return
}
for _, folder := range app.RecursiveFolders() {
@@ -119,11 +119,11 @@ func (app *HtmlApplication) NewWatcher(quitChan chan bool) {
app.watcher.Close()
break out
case <-app.watcher.Event:
//logger.Debugln("Got event:", ev)
//guilogger.Debugln("Got event:", ev)
app.webView.Call("reload")
case err := <-app.watcher.Error:
// TODO: Do something here
logger.Infoln("Watcher error:", err)
guilogger.Infoln("Watcher error:", err)
}
}
}()

View File

@@ -22,7 +22,7 @@ import (
"runtime"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/ethlog"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/utils"
"gopkg.in/qml.v1"
)
@@ -108,5 +108,5 @@ func main() {
}
// this blocks the thread
ethereum.WaitForShutdown()
ethlog.Flush()
logger.Flush()
}

View File

@@ -50,7 +50,7 @@ func (app *QmlApplication) Create() error {
component, err := app.engine.LoadFile(path)
if err != nil {
logger.Warnln(err)
guilogger.Warnln(err)
}
app.win = component.CreateWindow(nil)

View File

@@ -62,7 +62,7 @@ func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib {
}
func (self *UiLib) Notef(args []interface{}) {
logger.Infoln(args...)
guilogger.Infoln(args...)
}
func (self *UiLib) LookupDomain(domain string) string {
@@ -158,7 +158,7 @@ func (ui *UiLib) OpenBrowser() {
func (ui *UiLib) Muted(content string) {
component, err := ui.engine.LoadFile(ui.AssetPath("qml/muted.qml"))
if err != nil {
logger.Debugln(err)
guilogger.Debugln(err)
return
}