本文整理匯總了Golang中github.com/Sirupsen/logrus.Debugln函數的典型用法代碼示例。如果您正苦於以下問題:Golang Debugln函數的具體用法?Golang Debugln怎麽用?Golang Debugln使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Debugln函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: run
func run(c *cli.Context) {
log.Debugln("[ENVMAN] - Work path:", envman.CurrentEnvStoreFilePath)
if len(c.Args()) > 0 {
doCmdEnvs, err := envman.ReadEnvs(envman.CurrentEnvStoreFilePath)
if err != nil {
log.Fatal("[ENVMAN] - Failed to load EnvStore:", err)
}
doCommand := c.Args()[0]
doArgs := []string{}
if len(c.Args()) > 1 {
doArgs = c.Args()[1:]
}
cmdToExecute := CommandModel{
Command: doCommand,
Environments: doCmdEnvs,
Argumentums: doArgs,
}
log.Debugln("[ENVMAN] - Executing command:", cmdToExecute)
if exit, err := runCommandModel(cmdToExecute); err != nil {
log.Error("[ENVMAN] - Failed to execute command:", err)
os.Exit(exit)
}
log.Debugln("[ENVMAN] - Command executed")
} else {
log.Fatal("[ENVMAN] - No command specified")
}
}
示例2: sendAndReceiveWithQueueInternal
func sendAndReceiveWithQueueInternal(t *testing.T, redis *Transport) {
// sender
go func() {
redis.RunSource(countingSource)
}()
// wait 2 seconds for sending to finish
select {
case res := <-senderChan:
log.Debugln(res)
case <-time.After(time.Second * 2):
t.Fatalf("Sending did not finish in time")
}
// receiver
go func() {
redis.RunSink(countingSink)
}()
// wait 2 seconds for sending to finish (it will timeout if 100 messages have not been received
select {
case res := <-receiverChan:
log.Debugln(res)
case <-time.After(time.Second * 2):
t.Fatalf("Sending and receiving did not finish in time")
}
}
示例3: Resize
// Resize handles a CLI event to resize an interactive docker run or docker exec
// window.
func (clnt *client) Resize(containerID, processFriendlyName string, width, height int) error {
// Get the libcontainerd container object
clnt.lock(containerID)
defer clnt.unlock(containerID)
cont, err := clnt.getContainer(containerID)
if err != nil {
return err
}
h, w := uint16(height), uint16(width)
if processFriendlyName == InitFriendlyName {
logrus.Debugln("libcontainerd: resizing systemPID in", containerID, cont.process.systemPid)
return cont.process.hcsProcess.ResizeConsole(w, h)
}
for _, p := range cont.processes {
if p.friendlyName == processFriendlyName {
logrus.Debugln("libcontainerd: resizing exec'd process", containerID, p.systemPid)
return p.hcsProcess.ResizeConsole(w, h)
}
}
return fmt.Errorf("Resize could not find containerID %s to resize", containerID)
}
示例4: pullFromFiles
/* Used by Remove file, this rebuilds the splice and assigns
the new array of Files to self */
func (self *Meta) pullFromFiles(node *Node, file *FilePointer) {
whole_stash := false
if file == nil {
whole_stash = true
}
var new_files []Node
for _, itr := range self.Files {
if itr.Compare(node) && whole_stash {
log.Debugln("skipping whole stash: ", itr.Id)
continue
} else if itr.Compare(node) && !whole_stash {
var new_pointers []FilePointer
for _, fitr := range itr.Pointers {
if fitr.Compare(file) {
log.Debugln("skipping file from stash")
continue
}
new_pointers = append(new_pointers, fitr)
}
itr.Pointers = new_pointers
}
new_files = append(new_files, itr)
}
self.Files = new_files
log.Debug("\n\n***\nFiles:\n\n", self.Files, "\n\n***\n\n")
self.SaveStash()
}
示例5: handleChannel
func handleChannel(s *Stream, ch ssh.Channel, reqs <-chan *ssh.Request, handle func(*Stream)) {
// handle requests receive for this Channel
go func(in <-chan *ssh.Request) {
for req := range in {
logrus.Debugln("AdminTool -> Request of type:", req.Type, "len:", len(req.Type))
logrus.Debugln("AdminTool -> Request payload:", string(req.Payload), "len:", len(req.Payload))
if req.WantReply {
req.Reply(false, nil)
}
}
logrus.Debugln("AdminTool -> End of request GO chan")
}(reqs)
// read data from channel
go func() {
for {
buffer := make([]byte, 64)
n, err := ch.Read(buffer)
if err != nil {
if err.Error() == "EOF" {
handleData(s, []byte{}, true)
// all data received: handle Stream message
handle(s)
break
} else {
logrus.Fatalln("failed to read channel : " + err.Error())
}
}
handleData(s, buffer[:n], false)
}
}()
}
示例6: executeQuery
func executeQuery(db *bolt.DB, query string) error {
selectStatement, err := boltq.NewParser(strings.NewReader(query)).ParseSelect()
if err == nil {
log.Debugf("parsed select: %v", selectStatement)
return executeSelect(selectStatement, db)
} else {
log.Debugln(err.Error())
}
updateStatement, err := boltq.NewParser(strings.NewReader(query)).ParseUpdate()
if err == nil {
log.Debugf("parsed update: %v", updateStatement)
return executeUpdate(updateStatement, db)
} else {
log.Debugln(err.Error())
}
deleteStatement, err := boltq.NewParser(strings.NewReader(query)).ParseDelete()
if err == nil {
log.Debugf("parsed delete: %v", deleteStatement)
return executeDelete(deleteStatement, db)
} else {
log.Debugln(err.Error())
}
return fmt.Errorf("cannot parse: %s", query)
}
示例7: executeSelect
func executeSelect(stmt *boltq.SelectStatement, db *bolt.DB) error {
return db.View(func(tx *bolt.Tx) error {
var bucket *bolt.Bucket
for _, name := range stmt.BucketPath {
log.Debugln("navigating to bucket", name)
bucket = tx.Bucket([]byte(name))
if bucket == nil {
return fmt.Errorf("cannot find bucket %s", name)
}
}
if containsAsterisk(stmt.Fields) {
log.Debugln("interating keys")
cursor := bucket.Cursor()
for k, v := cursor.First(); k != nil; k, v = cursor.Next() {
emitKeypair(k, v)
}
} else {
for _, k := range stmt.Fields {
keyBytes := []byte(k)
v := bucket.Get(keyBytes)
emitKeypair(keyBytes, v)
}
}
return nil
})
}
示例8: load
// load calls fn inside a View with the contents of the file. Caller
// must make a copy of the data if needed.
func (f *File) load(c context.Context, fn func([]byte)) error {
defer log.Debugln("load:", f.dir.path, f.name)
err := f.dir.fs.backend.View(c, func(ctx Context) error {
b, err := ctx.Dir(f.dir.path)
if err != nil {
return err
}
v, err := b.Get(f.name)
if err != nil {
return err
}
if v == nil {
return fuse.ESTALE
}
switch v := v.(type) {
case []byte:
fn(v)
case *File: // hard link
if !f.same_path(v) {
log.Debugln(f.dir.path, f.name, "->", v.dir.path, v.name)
return v.load(c, fn)
}
default:
}
return nil
})
return err
}
示例9: TestSendReceiveQueueSemantics2
func TestSendReceiveQueueSemantics2(t *testing.T) {
initChannels()
inputQueue0 := fmt.Sprintf("queue:input0-%d", time.Now().UnixNano())
outputQueue0 := fmt.Sprintf("queue:output0-%d", time.Now().UnixNano())
t1 := NewTransport(getKafkaBrokers(), getZookeeperHosts(), inputQueue0, outputQueue0)
t1.Connect()
defer t1.Disconnect()
inputQueue1 := outputQueue0
outputQueue1 := fmt.Sprintf("queue:output1-%d", time.Now().UnixNano())
t2 := NewTransport(getKafkaBrokers(), getZookeeperHosts(), inputQueue1, outputQueue1)
t2.Connect()
defer t2.Disconnect()
inputQueue2 := outputQueue1
outputQueue2 := fmt.Sprintf("queue:output2-%d", time.Now().UnixNano())
t3 := NewTransport(getKafkaBrokers(), getZookeeperHosts(), inputQueue2, outputQueue2)
t3.Connect()
defer t3.Disconnect()
go func() {
t1.RunSource(countingSource)
}()
// wait x seconds for sending to finish
select {
case res := <-senderChan:
log.Debugln(res)
case <-time.After(time.Second * 90):
t.Fatalf("Sending did not finish in time")
}
go func() {
t2.RunProcessor(bridgeFunc)
}()
// wait x seconds for bridge to finish
select {
case res := <-bridgeChan:
log.Debugln(res)
case <-time.After(time.Second * 90):
t.Fatalf("Bridiging did not finish in time")
}
go func() {
t3.RunSink(countingSink1)
}()
// wait x seconds for sending to finish (it will timeout if maxMessages messages have not been received)
select {
case res := <-receiverChan:
log.Debugln(res)
case <-time.After(time.Second * 90):
t.Fatalf("Receiving did not finish in time")
}
closeChannels()
}
示例10: logEnvs
func logEnvs() error {
environments, err := envman.ReadEnvs(envman.CurrentEnvStoreFilePath)
if err != nil {
return err
}
if len(environments) == 0 {
log.Info("[ENVMAN] - Empty envstore")
} else {
for _, env := range environments {
key, value, err := env.GetKeyValuePair()
if err != nil {
return err
}
opts, err := env.GetOptions()
if err != nil {
return err
}
envString := "- " + key + ": " + value
log.Debugln(envString)
if !*opts.IsExpand {
expandString := " " + "isExpand" + ": " + "false"
log.Debugln(expandString)
}
}
}
return nil
}
示例11: stdouterrAccept
// stdouterrAccept runs as a go function. It waits for the container system to
// accept our offer of a named pipe - in fact two of them - one for stdout
// and one for stderr (we are called twice). Once the named pipe is accepted,
// if we are running "attached" to the container (eg docker run -i), then we
// spin up a further thread to copy anything from the containers output channels
// to the client.
func stdouterrAccept(outerrListen *npipe.PipeListener, pipeName string, copyto io.Writer) {
// Wait for the pipe to be connected to by the shim
logrus.Debugln("out/err: Waiting on ", pipeName)
outerrConn, err := outerrListen.Accept()
if err != nil {
logrus.Errorf("Failed to accept on pipe %s %s", pipeName, err)
return
}
logrus.Debugln("Connected to ", outerrConn.RemoteAddr())
// Anything that comes from the container named pipe stdout/err should be copied
// across to the stdout/err of the client
if copyto != nil {
go func() {
defer outerrConn.Close()
logrus.Debugln("Calling io.Copy on ", pipeName)
bytes, err := io.Copy(copyto, outerrConn)
logrus.Debugf("Copied %d bytes from pipe=%s", bytes, outerrConn.RemoteAddr())
if err != nil {
// Not fatal, just debug log it
logrus.Debugf("Error hit during copy %s", err)
}
}()
} else {
defer outerrConn.Close()
}
}
示例12: getChecks
func (sr *Runner) getChecks(maxChecks int, timeout int) []stalker.Check {
log.Debugln("Getting checks off queue")
checks := make([]stalker.Check, 0)
expireTime := time.Now().Add(3 * time.Second).Unix()
for len(checks) <= maxChecks {
//we've exceeded our try time
if time.Now().Unix() > expireTime {
break
}
rconn := sr.rpool.Get()
defer rconn.Close()
res, err := redis.Values(rconn.Do("BLPOP", sr.conf.workerQueue, timeout))
if err != nil {
if err != redis.ErrNil {
log.Errorln("Error grabbing check from queue:", err.Error())
break
} else {
log.Debugln("redis result:", err)
continue
}
}
var rb []byte
res, err = redis.Scan(res, nil, &rb)
var check stalker.Check
if err := json.Unmarshal(rb, &check); err != nil {
log.Errorln("Error decoding check from queue to json:", err.Error())
break
}
checks = append(checks, check)
}
return checks
}
示例13: add
func add(c *cli.Context) {
log.Debugln("[ENVMAN] - Work path:", envman.CurrentEnvStoreFilePath)
key := c.String(KeyKey)
expand := !c.Bool(NoExpandKey)
replace := !c.Bool(AppendKey)
var value string
if stdinValue != "" {
value = stdinValue
} else if c.IsSet(ValueKey) {
value = c.String(ValueKey)
} else if c.String(ValueFileKey) != "" {
if v, err := loadValueFromFile(c.String(ValueFileKey)); err != nil {
log.Fatal("[ENVMAN] - Failed to read file value: ", err)
} else {
value = v
}
}
if err := addEnv(key, value, expand, replace); err != nil {
log.Fatal("[ENVMAN] - Failed to add env:", err)
}
log.Debugln("[ENVMAN] - Env added")
if err := logEnvs(); err != nil {
log.Fatal("[ENVMAN] - Failed to print:", err)
}
}
示例14: persist
func persist(db *bolt.DB, args []string) error {
tx, err := db.Begin(true)
if err != nil {
return err
}
log.Debugln("start transaction.")
for _, v := range args {
log.Debugln(v)
bucket := tx.Bucket([]byte(BUCKET_NAME))
if bucket == nil {
bucket, err = tx.CreateBucket([]byte(BUCKET_NAME))
if err != nil {
return err
}
count := btoi(bucket.Get([]byte(v)))
count += 1
err = bucket.Put([]byte(v), itob(count))
if err != nil {
tx.Rollback()
return err
}
}
}
tx.Commit()
return nil
}
示例15: main
func main() {
log.SetLevel(log.DebugLevel)
log.Infoln("*******************************************")
log.Infoln("Port Scanner")
log.Infoln("*******************************************")
t := time.Now()
defer func() {
if e := recover(); e != nil {
log.Debugln(e)
}
}()
log.Debugln(loadConfig("config.properties"))
log.Debugln("Parsed input data ", len(portScannerTuple.portScannerResult))
CheckPort(&portScannerTuple)
for key, value := range portScannerTuple.portScannerResult {
if value {
log.Debugln("Port Scanner Result", key, " port is open :", value)
}
}
log.Debugln("Total time taken %s to scan %d ports", time.Since(t), len(portScannerTuple.portScannerResult))
}