package bitcoin

import (
	"fmt"
	"runtime"
	"strings"
	"time"
)

type config struct {
	Title      string
	WalletInfo walletinfo   `toml:"walletinfo"`
	Limit      limit        `toml:"limit"`
	Rpc        rpc          `toml:"rpc"`
	Db         databaseinfo `toml:"db"`
	Sleeptime  sleeptime    `toml:"sleeptime"`
}
type limit struct {
	Fee string
}

type walletinfo struct {
	WalletKey string
}
type rpc struct {
	Rpcuser     string
	Rpcpassword string
	Rpchost     string
	Rpcport     int
}

type sleeptime struct {
	Blockinterval    int
	Transferinterval int
}

type databaseinfo struct {
	DbPath string
}

func LOG(info string, format string, v ...interface{}) {

	_, file, line, _ := runtime.Caller(1)
	fpaths := strings.Split(file, "/")
	size := len(fpaths)
	var sysflag = "lite package"
	if format == "" {
		fmt.Printf("%v |%v|%v|%v()|%v|%v\n", time.Now().Format("2006-01-02 15:04:05"), info, sysflag, fpaths[size-1], line, fmt.Sprintln(v...))
	} else {
		fmt.Printf("%v|%v|%v|%v|%v|%v\n", time.Now().Format("2006-01-02 15:04:05"), info, sysflag, fpaths[size-1], line, fmt.Sprintf(format, v...))
	}

}
