本文整理匯總了Golang中github.com/dgraph-io/dgraph/x.Log函數的典型用法代碼示例。如果您正苦於以下問題:Golang Log函數的具體用法?Golang Log怎麽用?Golang Log使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Log函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: main
"compress/gzip"
"flag"
"os"
"runtime"
"runtime/pprof"
"strings"
"github.com/Sirupsen/logrus"
"github.com/dgraph-io/dgraph/loader"
"github.com/dgraph-io/dgraph/posting"
"github.com/dgraph-io/dgraph/store"
"github.com/dgraph-io/dgraph/uid"
"github.com/dgraph-io/dgraph/x"
)
var glog = x.Log("uidassigner_main")
var rdfGzips = flag.String("rdfgzips", "",
"Comma separated gzip files containing RDF data")
var instanceIdx = flag.Uint64("instanceIdx", 0,
"Only pick entities, where Fingerprint % numInstance == instanceIdx.")
var numInstances = flag.Uint64("numInstances", 1,
"Total number of instances among which uid assigning is shared")
var uidDir = flag.String("uidpostings", "",
"Directory to store xid to uid posting lists")
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
var numcpu = flag.Int("numCpu", runtime.NumCPU(),
"Number of cores to be used by the process")
func main() {
flag.Parse()
示例2:
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package lex
import (
"fmt"
"unicode/utf8"
"github.com/dgraph-io/dgraph/x"
)
var glog = x.Log("lexer")
const EOF = -1
// ItemType is used to set the type of a token. These constants can be defined
// in the file containing state functions. Note that their value should be >= 5.
type ItemType int
const (
ItemEOF ItemType = iota
ItemError // error
)
// stateFn represents the state of the scanner as a function that
// returns the next state.
type StateFn func(*Lexer) StateFn
示例3: isOld
import (
"bytes"
"errors"
"math"
"sync"
"time"
"github.com/dgraph-io/dgraph/posting"
"github.com/dgraph-io/dgraph/posting/types"
"github.com/dgraph-io/dgraph/store"
"github.com/dgraph-io/dgraph/x"
"github.com/dgryski/go-farm"
)
var glog = x.Log("uid")
var lmgr *lockManager
var uidStore *store.Store
type entry struct {
sync.Mutex
ts time.Time
}
func (e entry) isOld() bool {
e.Lock()
defer e.Unlock()
return time.Now().Sub(e.ts) > time.Minute
}
type lockManager struct {
示例4:
"math/rand"
"runtime"
"strings"
"sync"
"sync/atomic"
"time"
"github.com/Sirupsen/logrus"
"github.com/dgraph-io/dgraph/posting"
"github.com/dgraph-io/dgraph/rdf"
"github.com/dgraph-io/dgraph/store"
"github.com/dgraph-io/dgraph/x"
"github.com/dgryski/go-farm"
)
var glog = x.Log("loader")
var uidStore, dataStore *store.Store
type counters struct {
read uint64
parsed uint64
processed uint64
ignored uint64
}
type state struct {
input chan string
cnq chan rdf.NQuad
ctr *counters
instanceIdx uint64
numInstances uint64
示例5:
"sync"
"sync/atomic"
"time"
"unsafe"
"github.com/Sirupsen/logrus"
"github.com/dgraph-io/dgraph/commit"
"github.com/dgraph-io/dgraph/posting/types"
"github.com/dgraph-io/dgraph/store"
"github.com/dgraph-io/dgraph/x"
"github.com/dgryski/go-farm"
"github.com/google/flatbuffers/go"
"github.com/zond/gotomic"
)
var glog = x.Log("posting")
const Set = 0x01
const Del = 0x02
var E_TMP_ERROR = errors.New("Temporary Error. Please retry.")
type buffer struct {
d []byte
}
type MutationLink struct {
idx int
moveidx int
posting *types.Posting
}
示例6: addCorsHeaders
"fmt"
"io/ioutil"
"net/http"
"runtime"
"time"
"github.com/Sirupsen/logrus"
"github.com/dgraph-io/dgraph/commit"
"github.com/dgraph-io/dgraph/gql"
"github.com/dgraph-io/dgraph/posting"
"github.com/dgraph-io/dgraph/query"
"github.com/dgraph-io/dgraph/store"
"github.com/dgraph-io/dgraph/x"
)
var glog = x.Log("server")
var postingDir = flag.String("postings", "", "Directory to store posting lists")
var mutationDir = flag.String("mutations", "", "Directory to store mutations")
var port = flag.String("port", "8080", "Port to run server on.")
func addCorsHeaders(w http.ResponseWriter) {
w.Header().Set("Access-Control-Allow-Origin", "*")
w.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS")
w.Header().Set("Access-Control-Allow-Headers",
"Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, X-Auth-Token, Cache-Control, X-Requested-With")
w.Header().Set("Access-Control-Allow-Credentials", "true")
w.Header().Set("Connection", "close")
}
func queryHandler(w http.ResponseWriter, r *http.Request) {
示例7: ToMap
*
* ALGORITHM:
* This is a rough and simple algorithm of how to process this SubGraph query
* and populate the results:
*
* For a given entity, a new SubGraph can be started off with NewGraph(id).
* Given a SubGraph, is the Query field empty? [Step a]
* - If no, run (or send it to server serving the attribute) query
* and populate result.
* Iterate over children and copy Result Uids to child Query Uids.
* Set Attr. Then for each child, use goroutine to run Step:a.
* Wait for goroutines to finish.
* Return errors, if any.
*/
var glog = x.Log("query")
type Latency struct {
Start time.Time `json:"-"`
Parsing time.Duration `json:"query_parsing"`
Processing time.Duration `json:"processing"`
Json time.Duration `json:"json_conversion"`
}
func (l *Latency) ToMap() map[string]string {
m := make(map[string]string)
j := time.Since(l.Start) - l.Processing - l.Parsing
m["parsing"] = l.Parsing.String()
m["processing"] = l.Processing.String()
m["json"] = j.String()
m["total"] = time.Since(l.Start).String()
示例8: main
import (
"compress/gzip"
"flag"
"os"
"runtime"
"runtime/pprof"
"strings"
"github.com/Sirupsen/logrus"
"github.com/dgraph-io/dgraph/loader"
"github.com/dgraph-io/dgraph/posting"
"github.com/dgraph-io/dgraph/store"
"github.com/dgraph-io/dgraph/x"
)
var glog = x.Log("loader_main")
var rdfGzips = flag.String("rdfgzips", "",
"Comma separated gzip files containing RDF data")
var mod = flag.Uint64("mod", 1, "Only pick entities, where uid % mod == 0.")
var postingDir = flag.String("postings", "", "Directory to store posting lists")
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
func main() {
flag.Parse()
if !flag.Parsed() {
glog.Fatal("Unable to parse flags")
}
if len(*cpuprofile) > 0 {
f, err := os.Create(*cpuprofile)
if err != nil {
示例9: run
itemObject // object, 8
itemLabel // label, 9
itemLiteral // literal, 10
itemLanguage // language, 11
itemObjectType // object type, 12
itemValidEnd // end with dot, 13
)
const (
AT_SUBJECT int = iota
AT_PREDICATE
AT_OBJECT
AT_LABEL
)
var glog = x.Log("rdf")
func run(l *lex.Lexer) {
for state := lexText; state != nil; {
state = state(l)
}
close(l.Items) // No more tokens.
}
func lexText(l *lex.Lexer) lex.StateFn {
Loop:
for {
switch r := l.Next(); {
case r == '<' || r == '_':
if l.Depth == AT_SUBJECT {
l.Backup()
示例10:
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package gql
import (
"errors"
"fmt"
"strconv"
"github.com/dgraph-io/dgraph/lex"
"github.com/dgraph-io/dgraph/x"
)
var glog = x.Log("gql")
// GraphQuery stores the parsed Query in a tree format. This gets
// converted to internally used query.SubGraph before processing the query.
type GraphQuery struct {
UID uint64
XID string
Attr string
Children []*GraphQuery
}
type Mutation struct {
Set string
Del string
}
示例11: Cache
"path/filepath"
"runtime/debug"
"sort"
"strconv"
"strings"
"sync"
"sync/atomic"
"time"
"unsafe"
"github.com/Sirupsen/logrus"
"github.com/dgraph-io/dgraph/x"
"github.com/willf/bloom"
)
var glog = x.Log("commitlog")
type logFile struct {
sync.RWMutex
endTs int64 // never modified after creation.
path string
size int64
cache *Cache
bf *bloom.BloomFilter
}
func (lf *logFile) Cache() *Cache {
lf.RLock()
defer lf.RUnlock()
return lf.cache
}
示例12: checkErr
"net/http"
"os"
"strconv"
"strings"
"time"
"github.com/dgraph-io/dgraph/query/graph"
"github.com/dgraph-io/dgraph/x"
"golang.org/x/net/context"
"google.golang.org/grpc"
)
var (
numsecs = flag.Float64("numsecs", 10,
"number of seconds for which to run the benchmark")
glog = x.Log("PbBenchmark")
serverAddr = flag.String("ip", "http://127.0.0.1:8080/query",
"Addr of server for http request")
)
func checkErr(err error, msg string) {
if err != nil {
glog.WithField("err", err).Fatal(msg)
}
}
func numChildren(node *graph.Node) int {
c := 0
for _, child := range node.Children {
c += numChildren(child)
}
示例13: setOpts
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package store
import (
"strconv"
"github.com/dgraph-io/dgraph/rdb"
"github.com/dgraph-io/dgraph/x"
)
var log = x.Log("store")
// Store contains some handles to RocksDB.
type Store struct {
db *rdb.DB
opt *rdb.Options // Contains blockopt.
blockopt *rdb.BlockBasedTableOptions
ropt *rdb.ReadOptions
wopt *rdb.WriteOptions
}
func (s *Store) setOpts() {
s.opt = rdb.NewDefaultOptions()
s.blockopt = rdb.NewDefaultBlockBasedTableOptions()
s.opt.SetBlockBasedTableFactory(s.blockopt)
示例14: runUser
"sync"
"time"
"github.com/dgraph-io/dgraph/x"
)
var (
numUser = flag.Int("numuser", 1, "number of users hitting simultaneously")
numReq = flag.Int("numreq", 10, "number of request per user")
serverAddr = flag.String("ip", ":8081", "IP addr of server")
avg chan float64
jsonP chan float64
serverP chan float64
parsingP chan float64
totalP chan float64
glog = x.Log("Pinger")
)
func runUser(wg *sync.WaitGroup) {
var ti, proT, parT, jsonT, totT time.Duration
var query = `{
me(_xid_: m.0f4vbz) {
type.object.name.en
film.actor.film {
film.performance.film {
type.object.name.en
}
}
}
}`
示例15:
"net"
"net/rpc"
"strconv"
"time"
"github.com/coreos/etcd/raft"
"github.com/coreos/etcd/raft/raftpb"
"github.com/dgraph-io/dgraph/conn"
"github.com/dgraph-io/dgraph/x"
"golang.org/x/net/context"
)
var (
hb = 1
pools = make(map[uint64]*conn.Pool)
glog = x.Log("RAFT")
peers = make(map[uint64]string)
confCount uint64 = 0
)
type node struct {
id uint64
addr string
ctx context.Context
pstore map[string]string
store *raft.MemoryStorage
cfg *raft.Config
raft raft.Node
ticker <-chan time.Time
done <-chan struct{}
}