本文整理匯總了Golang中github.com/ipfs/go-ipfs/util.Logger函數的典型用法代碼示例。如果您正苦於以下問題:Golang Logger函數的具體用法?Golang Logger怎麽用?Golang Logger使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Logger函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1:
"io/ioutil"
golog "log"
"net"
"sync"
"time"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/cryptix/mdns"
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
manet "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net"
"github.com/ipfs/go-ipfs/p2p/host"
"github.com/ipfs/go-ipfs/p2p/peer"
u "github.com/ipfs/go-ipfs/util"
)
var log = u.Logger("mdns")
const ServiceTag = "discovery.ipfs.io"
type Service interface {
io.Closer
RegisterNotifee(Notifee)
UnregisterNotifee(Notifee)
}
type Notifee interface {
HandlePeerFound(peer.PeerInfo)
}
type mdnsService struct {
server *mdns.Server
示例2:
trickle "github.com/ipfs/go-ipfs/importer/trickle"
mdag "github.com/ipfs/go-ipfs/merkledag"
pin "github.com/ipfs/go-ipfs/pin"
ft "github.com/ipfs/go-ipfs/unixfs"
uio "github.com/ipfs/go-ipfs/unixfs/io"
u "github.com/ipfs/go-ipfs/util"
)
var ErrSeekFail = errors.New("failed to seek properly")
var ErrSeekEndNotImpl = errors.New("SEEK_END currently not implemented")
var ErrUnrecognizedWhence = errors.New("unrecognized whence")
// 2MB
var writebufferSize = 1 << 21
var log = u.Logger("dagio")
// DagModifier is the only struct licensed and able to correctly
// perform surgery on a DAG 'file'
// Dear god, please rename this to something more pleasant
type DagModifier struct {
dagserv mdag.DAGService
curNode *mdag.Node
mp pin.ManualPinner
splitter chunk.BlockSplitter
ctx context.Context
readCancel func()
writeStart uint64
curWrOff uint64
示例3:
import (
"container/list"
"errors"
"time"
process "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
procctx "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
ratelimit "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/ratelimit"
blocks "github.com/ipfs/go-ipfs/blocks"
key "github.com/ipfs/go-ipfs/blocks/key"
exchange "github.com/ipfs/go-ipfs/exchange"
util "github.com/ipfs/go-ipfs/util"
)
var log = util.Logger("blockservice")
var DefaultConfig = Config{
NumWorkers: 1,
ClientBufferSize: 0,
WorkerBufferSize: 0,
}
type Config struct {
// NumWorkers sets the number of background workers that provide blocks to
// the exchange.
NumWorkers int
// ClientBufferSize allows clients of HasBlock to send up to
// |ClientBufferSize| blocks without blocking.
ClientBufferSize int
示例4: LessThan
package tour
import (
"strconv"
"strings"
u "github.com/ipfs/go-ipfs/util"
)
var log = u.Logger("tour")
// ID is a string identifier for topics
type ID string
// LessThan returns whether this ID is sorted earlier than another.
func (i ID) LessThan(o ID) bool {
return compareDottedInts(string(i), string(o))
}
// IDSlice implements the sort interface for ID slices.
type IDSlice []ID
func (a IDSlice) Len() int { return len(a) }
func (a IDSlice) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a IDSlice) Less(i, j int) bool { return a[i].LessThan(a[j]) }
// Topic is a type of objects that structures a tour topic.
type Topic struct {
ID ID
Content
}
示例5:
"sync"
"time"
ggio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/io"
proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
ctxio "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-context/io"
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
pb "github.com/ipfs/go-ipfs/diagnostics/pb"
host "github.com/ipfs/go-ipfs/p2p/host"
inet "github.com/ipfs/go-ipfs/p2p/net"
peer "github.com/ipfs/go-ipfs/p2p/peer"
protocol "github.com/ipfs/go-ipfs/p2p/protocol"
util "github.com/ipfs/go-ipfs/util"
)
var log = util.Logger("diagnostics")
// ProtocolDiag is the diagnostics protocol.ID
var ProtocolDiag protocol.ID = "/ipfs/diagnostics"
var ErrAlreadyRunning = errors.New("diagnostic with that ID already running")
const ResponseTimeout = time.Second * 10
const HopTimeoutDecrement = time.Second * 2
// Diagnostics is a net service that manages requesting and responding to diagnostic
// requests
type Diagnostics struct {
host host.Host
self peer.ID
示例6:
import (
"encoding/json"
"errors"
"fmt"
"sync"
ds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore"
nsds "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-datastore/namespace"
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
key "github.com/ipfs/go-ipfs/blocks/key"
"github.com/ipfs/go-ipfs/blocks/set"
mdag "github.com/ipfs/go-ipfs/merkledag"
"github.com/ipfs/go-ipfs/util"
)
var log = util.Logger("pin")
var recursePinDatastoreKey = ds.NewKey("/local/pins/recursive/keys")
var directPinDatastoreKey = ds.NewKey("/local/pins/direct/keys")
var indirectPinDatastoreKey = ds.NewKey("/local/pins/indirect/keys")
type PinMode int
const (
Recursive PinMode = iota
Direct
Indirect
NotPinned
)
type Pinner interface {
IsPinned(key.Key) bool
示例7: DefaultSplitter
// package chunk implements streaming block splitters
package chunk
import (
"io"
"github.com/ipfs/go-ipfs/util"
)
var log = util.Logger("chunk")
var DefaultBlockSize int64 = 1024 * 256
type Splitter interface {
NextBytes() ([]byte, error)
}
type SplitterGen func(r io.Reader) Splitter
func DefaultSplitter(r io.Reader) Splitter {
return NewSizeSplitter(r, DefaultBlockSize)
}
func SizeSplitterGen(size int64) SplitterGen {
return func(r io.Reader) Splitter {
return NewSizeSplitter(r, size)
}
}
func Chan(s Splitter) (<-chan []byte, <-chan error) {
out := make(chan []byte)
示例8:
// package config implements the ipfs config file datastructures and utilities.
package config
import (
"bytes"
"encoding/json"
"fmt"
"os"
"path/filepath"
"strings"
u "github.com/ipfs/go-ipfs/util"
)
var log = u.Logger("config")
// Config is used to load IPFS config files.
type Config struct {
Identity Identity // local node's peer identity
Datastore Datastore // local node's storage
Addresses Addresses // local node's addresses
Mounts Mounts // local node's mount points
Version Version // local node's version management
Discovery Discovery // local node's discovery mechanisms
Bootstrap []string // local nodes's bootstrap peer addresses
Tour Tour // local node's tour position
Gateway Gateway // local node's gateway server options
SupernodeRouting SupernodeClientConfig // local node's routing servers (if SupernodeRouting enabled)
API API // local node's API settings
Swarm SwarmConfig
Log Log
示例9:
"crypto/elliptic"
"crypto/hmac"
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
"crypto/sha256"
"crypto/sha512"
"hash"
proto "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/gogo/protobuf/proto"
pb "github.com/ipfs/go-ipfs/p2p/crypto/internal/pb"
u "github.com/ipfs/go-ipfs/util"
)
var log = u.Logger("crypto")
var ErrBadKeyType = errors.New("invalid or unsupported key type")
const (
RSA = iota
)
// Key represents a crypto key that can be compared to another key
type Key interface {
// Bytes returns a serialized, storeable representation of this key
Bytes() ([]byte, error)
// Hash returns the hash of this key
Hash() ([]byte, error)
示例10:
output to the user, including text, JSON, and XML marshallers.
*/
package commands
import (
"errors"
"fmt"
"io"
"reflect"
"strings"
u "github.com/ipfs/go-ipfs/util"
)
var log = u.Logger("command")
// Function is the type of function that Commands use.
// It reads from the Request, and writes results to the Response.
type Function func(Request, Response)
// Marshaler is a function that takes in a Response, and returns an io.Reader
// (or an error on failure)
type Marshaler func(Response) (io.Reader, error)
// MarshalerMap is a map of Marshaler functions, keyed by EncodingType
// (or an error on failure)
type MarshalerMap map[EncodingType]Marshaler
// HelpText is a set of strings used to generate command help text. The help
// text follows formats similar to man pages, but not exactly the same.
示例11: init
nOrDDTrWSjlF6Ms+dYGCheWIjKQcykn9IW021AzVN1P7Mt9qtmDNfZ0VQL3zl/fs
zZ1IHBW7BzriQ4GzWXg5GWpTSz/REvUEfKNVuDV9jX7hv67B5H6qTL5+2zljPEKv
lCas04cCMmEpJUj4qK95hdKQzKJ8b7MrRf/RFYyViRGdxvR+lgGqJ7Yca8es2kCe
XV6c+i6a7X89YL6ZVU+1MlvPwngu0VG+VInH/w9KrNYrLFhfVRiruRbkBkHDXjnU
b4kPqaus+7g0DynCk7A2kTMa3cgtO20CZ9MBJFEPqRRHHksjHVmlxPb42bB348aR
UVsWkRRYOmRML7avTgkX8WFsmdZ1d7E7aQLYnCIel85+5iP7hWyNtEMsAHk02XCL
AAb7RaEDNJOa7qvUFecB
=mzPY
-----END PGP SIGNATURE-----
*/
)
var log = u.Logger("updates")
var currentVersion *semver.Version
// ErrNoUpdateAvailable returned when a check fails to find a newer update.
var ErrNoUpdateAvailable = check.NoUpdateAvailable
func init() {
var err error
currentVersion, err = parseVersion()
if err != nil {
log.Fatalf("invalid version number in code (must be semver): %q", Version)
}
log.Infof("go-ipfs Version: %s", currentVersion)
}
示例12: Pretty
import (
"encoding/hex"
"encoding/json"
"fmt"
"strings"
b58 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
ma "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
mh "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multihash"
ic "github.com/ipfs/go-ipfs/p2p/crypto"
u "github.com/ipfs/go-ipfs/util"
)
var log = u.Logger("peer")
// ID represents the identity of a peer.
type ID string
// Pretty returns a b58-encoded string of the ID
func (id ID) Pretty() string {
return IDB58Encode(id)
}
func (id ID) Loggable() map[string]interface{} {
return map[string]interface{}{
"peerID": id.Pretty(),
}
}
示例13: ReadConfigFile
package fsrepo
import (
"encoding/json"
"errors"
"fmt"
"io"
"os"
"path/filepath"
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/facebookgo/atomicfile"
"github.com/ipfs/go-ipfs/repo/config"
"github.com/ipfs/go-ipfs/util"
)
var log = util.Logger("fsrepo")
// ReadConfigFile reads the config from `filename` into `cfg`.
func ReadConfigFile(filename string, cfg interface{}) error {
f, err := os.Open(filename)
if err != nil {
return err
}
defer f.Close()
if err := json.NewDecoder(f).Decode(cfg); err != nil {
return fmt.Errorf("Failure to decode config: %s", err)
}
return nil
}
// WriteConfigFile writes the config from `cfg` into `filename`.
示例14: marshalHeader
"errors"
"io"
"io/ioutil"
"strings"
importer "github.com/ipfs/go-ipfs/importer"
chunk "github.com/ipfs/go-ipfs/importer/chunk"
dag "github.com/ipfs/go-ipfs/merkledag"
dagutil "github.com/ipfs/go-ipfs/merkledag/utils"
uio "github.com/ipfs/go-ipfs/unixfs/io"
u "github.com/ipfs/go-ipfs/util"
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
)
var log = u.Logger("tarfmt")
var blockSize = 512
var zeroBlock = make([]byte, blockSize)
func marshalHeader(h *tar.Header) ([]byte, error) {
buf := new(bytes.Buffer)
w := tar.NewWriter(buf)
err := w.WriteHeader(h)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}
func ImportTar(r io.Reader, ds dag.DAGService) (*dag.Node, error) {
示例15: BuildDagFromFile
import (
"fmt"
"os"
"github.com/ipfs/go-ipfs/commands/files"
bal "github.com/ipfs/go-ipfs/importer/balanced"
"github.com/ipfs/go-ipfs/importer/chunk"
h "github.com/ipfs/go-ipfs/importer/helpers"
trickle "github.com/ipfs/go-ipfs/importer/trickle"
dag "github.com/ipfs/go-ipfs/merkledag"
"github.com/ipfs/go-ipfs/pin"
u "github.com/ipfs/go-ipfs/util"
)
var log = u.Logger("importer")
// Builds a DAG from the given file, writing created blocks to disk as they are
// created
func BuildDagFromFile(fpath string, ds dag.DAGService, mp pin.ManualPinner) (*dag.Node, error) {
stat, err := os.Lstat(fpath)
if err != nil {
return nil, err
}
if stat.IsDir() {
return nil, fmt.Errorf("`%s` is a directory", fpath)
}
f, err := files.NewSerialFile(fpath, fpath, stat)
if err != nil {