Dero Web Wallet derosuite. This repo contains changes required for webwallet. With this changes any Dero daemon can become web wallet. All changes are related to daemon rpc server and wallet to make it light and faster.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.4KB

  1. package globals
  2. import "os"
  3. import "path"
  4. import "github.com/romana/rlog"
  5. import "github.com/sirupsen/logrus"
  6. type RLOG_HOOK struct { // rlog HOOK
  7. dummy string
  8. formatter *logrus.TextFormatter
  9. }
  10. var HOOK RLOG_HOOK
  11. // setup default logging to current directory
  12. func Init_rlog() {
  13. HOOK.formatter = new(logrus.TextFormatter)
  14. HOOK.formatter.DisableColors = true
  15. HOOK.formatter.DisableTimestamp = true
  16. if os.Getenv("RLOG_LOG_LEVEL") == "" {
  17. os.Setenv("RLOG_LOG_LEVEL", "WARN") // default logging in debug mode
  18. }
  19. if os.Getenv("RLOG_LOG_FILE") == "" {
  20. exename, _ := os.Executable()
  21. filename := path.Base(exename) + ".log"
  22. os.Setenv("RLOG_LOG_FILE", filename) // default log file name
  23. }
  24. if os.Getenv("RLOG_LOG_STREAM") == "" {
  25. os.Setenv("RLOG_LOG_STREAM", "NONE") // do not log to stdout/stderr
  26. }
  27. if os.Getenv("RLOG_CALLER_INFO") == "" {
  28. os.Setenv("RLOG_CALLER_INFO", "RLOG_CALLER_INFO") // log caller info
  29. }
  30. //os.Setenv("RLOG_TRACE_LEVEL", "10") user can request tracing
  31. //os.Setenv("RLOG_LOG_LEVEL", "DEBUG")
  32. rlog.UpdateEnv()
  33. }
  34. // log logrus messages to rlog
  35. func (hook *RLOG_HOOK) Fire(entry *logrus.Entry) error {
  36. msg, err := hook.formatter.Format(entry)
  37. if err == nil {
  38. rlog.Infof(string(msg)) // log to file
  39. }
  40. return nil
  41. }
  42. // Levels returns configured log levels., we log everything
  43. func (hook *RLOG_HOOK) Levels() []logrus.Level {
  44. return logrus.AllLevels
  45. }