Documentation
¶
Overview ¶
package util implements various utility functions used within ipfs that do not currently have a better place to live.
Index ¶
- Variables
- func B58KeyEncode(k Key) string
- func ContextDo(ctx context.Context, f func() error) error
- func ContextWithErrorLog(parent context.Context) (context.Context, <-chan error)
- func ExpandPathnames(paths []string) ([]string, error)
- func GetenvBool(name string) bool
- func Hash(data []byte) mh.Multihash
- func IsValidHash(s string) bool
- func LogError(ctx context.Context, err error)
- func Logger(name string) *logging.Logger
- func NewByteChanReader(in chan []byte) io.Reader
- func NewTimeSeededRand() io.Reader
- func POut(format string, a ...interface{})
- func SetAllLoggers(lvl logging.Level)
- func SetLogLevel(name, level string) error
- func SetupLogging()
- func TildeExpansion(filename string) (string, error)
- func XOR(a, b []byte) []byte
- type Key
- type KeySet
Constants ¶
This section is empty.
Variables ¶
var B58KeyConverter = b58KeyConverter{}
B58KeyConverter -- for KeyTransform datastores (static as only one obj needed)
var Debug bool
Debug is a global flag for debugging.
var ErrNoSuchLogger = errors.New("Error: No such logger")
ErrNoSuchLogger is returned when the util pkg is asked for a non existant logger
var ErrNotFound = ds.ErrNotFound
ErrNotFound is returned when a search fails to find anything
var ErrNotImplemented = errors.New("Error: not implemented yet.")
ErrNotImplemented signifies a function has not been implemented yet.
var ErrSearchIncomplete = errors.New("Error: Search Incomplete.")
ErrSeErrSearchIncomplete implies that a search type operation didnt find the expected node, but did find 'a' node.
var ErrTimeout = errors.New("Error: Call timed out.")
ErrTimeout implies that a timeout has been triggered
var LogFormats = map[string]string{
"nocolor": "%{time:2006-01-02 15:04:05.000000} %{level} %{module} %{shortfile}: %{message}",
"color": ansiGray + "%{time:15:04:05.000} %{color}%{level:5.5s} " + ansiBlue +
"%{module:10.10s}: %{color:reset}%{message} " + ansiGray + "%{shortfile}%{color:reset}",
}
LogFormats is a map of formats used for our logger, keyed by name.
Functions ¶
func B58KeyEncode ¶
B58KeyEncode returns Key in a b58 encoded string
func ContextWithErrorLog ¶
ContextWithErrorLog returns a copy of parent and an error channel that can be used to receive errors sent with the LogError method.
func ExpandPathnames ¶
ExpandPathnames takes a set of paths and turns them into absolute paths
func GetenvBool ¶
GetenvBool is the way to check an env var as a boolean
func IsValidHash ¶
IsValidHash checks whether a given hash is valid (b58 decodable, len > 0)
func LogError ¶
LogError logs the error to the owner of the context.
If this context was created with ContextWithErrorLog, then this method passes the error to context creator over an unbuffered channel.
If this context was created by other means, this method is a no-op.
func NewByteChanReader ¶
func NewTimeSeededRand ¶
func POut ¶
func POut(format string, a ...interface{})
POut is a shorthand printing function to output to Stdout.
func SetAllLoggers ¶
SetAllLoggers changes the logging.Level of all loggers to lvl
func SetLogLevel ¶
SetLogLevel changes the log level of a specific subsystem name=="*" changes all subsystems
func SetupLogging ¶
func SetupLogging()
SetupLogging will initialize the logger backend and set the flags.
func TildeExpansion ¶
TildeExpansion expands a filename, which may begin with a tilde.
Types ¶
type Key ¶
type Key string
Key is a string representation of multihash for use with maps.
func B58KeyDecode ¶
B58KeyDecode returns Key from a b58 encoded string
func (*Key) MarshalJSON ¶
MarshalJSON returns a JSON-encoded Key (string)
func (*Key) UnmarshalJSON ¶
UnmarshalJSON returns a JSON-encoded Key (string)