packages/git-remote-ipld: init at 0.1.0

This commit is contained in:
Max Headroom 2022-06-17 23:26:08 +02:00
parent d65def9009
commit b1563a0cd9
3 changed files with 69 additions and 0 deletions

View file

@ -17,6 +17,8 @@ in
doom-one-vim = pkgs.callPackage ./vim-plugins/doom-one-vim.nix { };
git-remote-ipld = pkgs.callPackage ./tools/git-remote-ipld { };
hyprspace = pkgs.callPackage ./networking/hyprspace { iproute2mac = null; };
identity = pkgs.callPackage ./apps/identity { };

View file

@ -0,0 +1,19 @@
{ buildGoModule, fetchFromGitHub }:
buildGoModule rec {
pname = "git-remote-ipld";
version = "0.1.0";
patches = [
./silence-logger.patch
];
src = fetchFromGitHub {
owner = "ipfs-shipyard";
repo = pname;
rev = "2f4756ae2c5df8c8276dbca94038e3eaffac3a95";
sha256 = "sha256-0BxDEghcTEpge1KIQ6s7+/XMVHcTnmWRtMaQEHLaQ+M=";
};
vendorSha256 = "sha256-LpQYi8pqMIiNjDyXiNSEF8kwciK6eQq/yyPsgsArHko=";
doCheck = false;
}

View file

@ -0,0 +1,48 @@
diff --git a/core/tracker.go b/core/tracker.go
index cb4e8b0..43a6b1d 100644
--- a/core/tracker.go
+++ b/core/tracker.go
@@ -2,6 +2,7 @@ package core
import (
"fmt"
+ "log"
"os"
"path"
@@ -15,6 +16,26 @@ type Tracker struct {
txn *badger.Txn
}
+type logger struct {
+ *log.Logger
+}
+
+func (l *logger) Debugf(f string, v ...interface{}) {
+ return
+}
+
+func (l *logger) Infof(f string, v ...interface{}) {
+ return
+}
+
+func (l *logger) Warningf(f string, v ...interface{}) {
+ l.Printf("WARNING: "+f, v...)
+}
+
+func (l *logger) Errorf(f string, v ...interface{}) {
+ l.Printf("ERROR: "+f, v...)
+}
+
func NewTracker(gitPath string) (*Tracker, error) {
ipldDir := path.Join(gitPath, "ipld")
err := os.MkdirAll(ipldDir, 0755)
@@ -22,7 +43,7 @@ func NewTracker(gitPath string) (*Tracker, error) {
return nil, err
}
- opt := badger.DefaultOptions(ipldDir)
+ opt := badger.DefaultOptions(ipldDir).WithLogger(&logger{Logger: log.New(os.Stderr, "badger ", log.LstdFlags)})
db, err := badger.Open(opt)
if err != nil {