本文整理汇总了Golang中github.com/lxc/lxd/shared.LogDebugf函数的典型用法代码示例。如果您正苦于以下问题:Golang LogDebugf函数的具体用法?Golang LogDebugf怎么用?Golang LogDebugf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LogDebugf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: eventsSocket
func eventsSocket(r *http.Request, w http.ResponseWriter) error {
listener := eventListener{}
typeStr := r.FormValue("type")
if typeStr == "" {
typeStr = "logging,operation"
}
c, err := shared.WebsocketUpgrader.Upgrade(w, r, nil)
if err != nil {
return err
}
listener.active = make(chan bool, 1)
listener.connection = c
listener.id = uuid.NewRandom().String()
listener.messageTypes = strings.Split(typeStr, ",")
eventsLock.Lock()
eventListeners[listener.id] = &listener
eventsLock.Unlock()
shared.LogDebugf("New events listener: %s", listener.id)
<-listener.active
eventsLock.Lock()
delete(eventListeners, listener.id)
eventsLock.Unlock()
listener.connection.Close()
shared.LogDebugf("Disconnected events listener: %s", listener.id)
return nil
}
开发者ID:vahe,项目名称:lxd,代码行数:35,代码来源:events.go
示例2: ConnStateHandler
func (m *ConnPidMapper) ConnStateHandler(conn net.Conn, state http.ConnState) {
unixConn := conn.(*net.UnixConn)
switch state {
case http.StateNew:
cred, err := getCred(unixConn)
if err != nil {
shared.LogDebugf("Error getting ucred for conn %s", err)
} else {
m.m[unixConn] = cred
}
case http.StateActive:
return
case http.StateIdle:
return
case http.StateHijacked:
/*
* The "Hijacked" state indicates that the connection has been
* taken over from net/http. This is useful for things like
* developing websocket libraries, who want to upgrade the
* connection to a websocket one, and not use net/http any
* more. Whatever the case, we want to forget about it since we
* won't see it either.
*/
delete(m.m, unixConn)
case http.StateClosed:
delete(m.m, unixConn)
default:
shared.LogDebugf("Unknown state for connection %s", state)
}
}
开发者ID:vahe,项目名称:lxd,代码行数:30,代码来源:devlxd.go
示例3: Connect
func (op *operation) Connect(r *http.Request, w http.ResponseWriter) (chan error, error) {
if op.class != operationClassWebsocket {
return nil, fmt.Errorf("Only websocket operations can be connected")
}
if op.status != shared.Running {
return nil, fmt.Errorf("Only running operations can be connected")
}
chanConnect := make(chan error, 1)
op.lock.Lock()
go func(op *operation, chanConnect chan error) {
err := op.onConnect(op, r, w)
if err != nil {
chanConnect <- err
shared.LogDebugf("Failed to handle %s operation: %s: %s", op.class.String(), op.id, err)
return
}
chanConnect <- nil
shared.LogDebugf("Handled %s operation: %s", op.class.String(), op.id)
}(op, chanConnect)
op.lock.Unlock()
shared.LogDebugf("Connected %s operation: %s", op.class.String(), op.id)
return chanConnect, nil
}
开发者ID:vahe,项目名称:lxd,代码行数:32,代码来源:operations.go
示例4: RsyncSend
// RsyncSend sets up the sending half of an rsync, to recursively send the
// directory pointed to by path over the websocket.
func RsyncSend(path string, conn *websocket.Conn) error {
cmd, dataSocket, stderr, err := rsyncSendSetup(path)
if dataSocket != nil {
defer dataSocket.Close()
}
if err != nil {
return err
}
readDone, writeDone := shared.WebsocketMirror(conn, dataSocket, dataSocket)
output, err := ioutil.ReadAll(stderr)
if err != nil {
shared.LogDebugf("problem reading rsync stderr %s", err)
}
err = cmd.Wait()
if err != nil {
shared.LogDebugf("problem with rsync send of %s: %s: %s", path, err, string(output))
}
<-readDone
<-writeDone
return err
}
开发者ID:vahe,项目名称:lxd,代码行数:28,代码来源:rsync.go
示例5: containersPost
func containersPost(d *Daemon, r *http.Request) Response {
shared.LogDebugf("Responding to container create")
req := containerPostReq{}
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
return BadRequest(err)
}
if req.Name == "" {
cs, err := dbContainersList(d.db, cTypeRegular)
if err != nil {
return InternalError(err)
}
i := 0
for {
i++
req.Name = strings.ToLower(petname.Generate(2, "-"))
if !shared.StringInSlice(req.Name, cs) {
break
}
if i > 100 {
return InternalError(fmt.Errorf("couldn't generate a new unique name after 100 tries"))
}
}
shared.LogDebugf("No name provided, creating %s", req.Name)
}
if req.Devices == nil {
req.Devices = shared.Devices{}
}
if req.Config == nil {
req.Config = map[string]string{}
}
if strings.Contains(req.Name, shared.SnapshotDelimiter) {
return BadRequest(fmt.Errorf("Invalid container name: '%s' is reserved for snapshots", shared.SnapshotDelimiter))
}
switch req.Source.Type {
case "image":
return createFromImage(d, &req)
case "none":
return createFromNone(d, &req)
case "migration":
return createFromMigration(d, &req)
case "copy":
return createFromCopy(d, &req)
default:
return BadRequest(fmt.Errorf("unknown source type %s", req.Source.Type))
}
}
开发者ID:vahe,项目名称:lxd,代码行数:54,代码来源:containers_post.go
示例6: deviceEventListener
func deviceEventListener(d *Daemon) {
chNetlinkCPU, chNetlinkNetwork, chUSB, err := deviceNetlinkListener()
if err != nil {
shared.LogErrorf("scheduler: couldn't setup netlink listener")
return
}
for {
select {
case e := <-chNetlinkCPU:
if len(e) != 2 {
shared.LogErrorf("Scheduler: received an invalid cpu hotplug event")
continue
}
if !cgCpusetController {
continue
}
shared.LogDebugf("Scheduler: cpu: %s is now %s: re-balancing", e[0], e[1])
deviceTaskBalance(d)
case e := <-chNetlinkNetwork:
if len(e) != 2 {
shared.LogErrorf("Scheduler: received an invalid network hotplug event")
continue
}
if !cgNetPrioController {
continue
}
shared.LogDebugf("Scheduler: network: %s has been added: updating network priorities", e[0])
deviceNetworkPriority(d, e[0])
networkAutoAttach(d, e[0])
case e := <-chUSB:
deviceUSBEvent(d, e)
case e := <-deviceSchedRebalance:
if len(e) != 3 {
shared.LogErrorf("Scheduler: received an invalid rebalance event")
continue
}
if !cgCpusetController {
continue
}
shared.LogDebugf("Scheduler: %s %s %s: re-balancing", e[0], e[1], e[2])
deviceTaskBalance(d)
}
}
}
开发者ID:vahe,项目名称:lxd,代码行数:51,代码来源:devices.go
示例7: RsyncRecv
// RsyncRecv sets up the receiving half of the websocket to rsync (the other
// half set up by RsyncSend), putting the contents in the directory specified
// by path.
func RsyncRecv(path string, conn *websocket.Conn, writeWrapper func(io.WriteCloser) io.WriteCloser) error {
cmd := exec.Command("rsync",
"--server",
"-vlogDtpre.iLsfx",
"--numeric-ids",
"--devices",
"--partial",
".",
path)
stdin, err := cmd.StdinPipe()
if err != nil {
return err
}
stdout, err := cmd.StdoutPipe()
if err != nil {
return err
}
stderr, err := cmd.StderrPipe()
if err != nil {
return err
}
if err := cmd.Start(); err != nil {
return err
}
writePipe := io.WriteCloser(stdin)
if writeWrapper != nil {
writePipe = writeWrapper(stdin)
}
readDone, writeDone := shared.WebsocketMirror(conn, writePipe, stdout)
data, err2 := ioutil.ReadAll(stderr)
if err2 != nil {
shared.LogDebugf("error reading rsync stderr: %s", err2)
return err2
}
err = cmd.Wait()
if err != nil {
shared.LogDebugf("rsync recv error for path %s: %s: %s", path, err, string(data))
}
<-readDone
<-writeDone
return err
}
开发者ID:akshaykarle,项目名称:lxd,代码行数:54,代码来源:rsync.go
示例8: Run
func (op *operation) Run() (chan error, error) {
if op.status != shared.Pending {
return nil, fmt.Errorf("Only pending operations can be started")
}
chanRun := make(chan error, 1)
op.lock.Lock()
op.status = shared.Running
if op.onRun != nil {
go func(op *operation, chanRun chan error) {
err := op.onRun(op)
if err != nil {
op.lock.Lock()
op.status = shared.Failure
op.err = SmartError(err).String()
op.lock.Unlock()
op.done()
chanRun <- err
shared.LogDebugf("Failure for %s operation: %s: %s", op.class.String(), op.id, err)
_, md, _ := op.Render()
eventSend("operation", md)
return
}
op.lock.Lock()
op.status = shared.Success
op.lock.Unlock()
op.done()
chanRun <- nil
op.lock.Lock()
shared.LogDebugf("Success for %s operation: %s", op.class.String(), op.id)
_, md, _ := op.Render()
eventSend("operation", md)
op.lock.Unlock()
}(op, chanRun)
}
op.lock.Unlock()
shared.LogDebugf("Started %s operation: %s", op.class.String(), op.id)
_, md, _ := op.Render()
eventSend("operation", md)
return chanRun, nil
}
开发者ID:vahe,项目名称:lxd,代码行数:49,代码来源:operations.go
示例9: sendTermSize
func (c *execCmd) sendTermSize(control *websocket.Conn) error {
width, height, err := termios.GetSize(int(syscall.Stdout))
if err != nil {
return err
}
shared.LogDebugf("Window size is now: %dx%d", width, height)
w, err := control.NextWriter(websocket.TextMessage)
if err != nil {
return err
}
msg := shared.ContainerExecControl{}
msg.Command = "window-resize"
msg.Args = make(map[string]string)
msg.Args["width"] = strconv.Itoa(width)
msg.Args["height"] = strconv.Itoa(height)
buf, err := json.Marshal(msg)
if err != nil {
return err
}
_, err = w.Write(buf)
w.Close()
return err
}
开发者ID:vahe,项目名称:lxd,代码行数:28,代码来源:exec.go
示例10: filesystemDetect
/*
* filesystemDetect returns the filesystem on which
* the passed-in path sits
*/
func filesystemDetect(path string) (string, error) {
fs := syscall.Statfs_t{}
err := syscall.Statfs(path, &fs)
if err != nil {
return "", err
}
switch fs.Type {
case filesystemSuperMagicBtrfs:
return "btrfs", nil
case filesystemSuperMagicZfs:
return "zfs", nil
case filesystemSuperMagicTmpfs:
return "tmpfs", nil
case filesystemSuperMagicExt4:
return "ext4", nil
case filesystemSuperMagicXfs:
return "xfs", nil
case filesystemSuperMagicNfs:
return "nfs", nil
default:
shared.LogDebugf("Unknown backing filesystem type: 0x%x", fs.Type)
return string(fs.Type), nil
}
}
开发者ID:akshaykarle,项目名称:lxd,代码行数:30,代码来源:storage.go
示例11: UpdateMetadata
func (op *operation) UpdateMetadata(opMetadata interface{}) error {
if op.status != shared.Pending && op.status != shared.Running {
return fmt.Errorf("Only pending or running operations can be updated")
}
if op.readonly {
return fmt.Errorf("Read-only operations can't be updated")
}
newMetadata, err := shared.ParseMetadata(opMetadata)
if err != nil {
return err
}
op.lock.Lock()
op.updatedAt = time.Now()
op.metadata = newMetadata
op.lock.Unlock()
shared.LogDebugf("Updated metadata for %s operation: %s", op.class.String(), op.id)
_, md, _ := op.Render()
eventSend("operation", md)
return nil
}
开发者ID:vahe,项目名称:lxd,代码行数:25,代码来源:operations.go
示例12: dbExec
func dbExec(db *sql.DB, q string, args ...interface{}) (sql.Result, error) {
for i := 0; i < 100; i++ {
result, err := db.Exec(q, args...)
if err == nil {
return result, nil
}
if !isDbLockedError(err) {
shared.LogDebugf("DbExec: query %q error %q", q, err)
return nil, err
}
time.Sleep(100 * time.Millisecond)
}
shared.LogDebugf("DbExec: query %q args %q, DB still locked", q, args)
shared.PrintStack()
return nil, fmt.Errorf("DB is locked")
}
开发者ID:vahe,项目名称:lxd,代码行数:17,代码来源:db.go
示例13: dbQueryScan
/*
* . q is the database query
* . inargs is an array of interfaces containing the query arguments
* . outfmt is an array of interfaces containing the right types of output
* arguments, i.e.
* var arg1 string
* var arg2 int
* outfmt := {}interface{}{arg1, arg2}
*
* The result will be an array (one per output row) of arrays (one per output argument)
* of interfaces, containing pointers to the actual output arguments.
*/
func dbQueryScan(db *sql.DB, q string, inargs []interface{}, outfmt []interface{}) ([][]interface{}, error) {
for i := 0; i < 100; i++ {
result, err := doDbQueryScan(db, q, inargs, outfmt)
if err == nil {
return result, nil
}
if !isDbLockedError(err) {
shared.LogDebugf("DbQuery: query %q error %q", q, err)
return nil, err
}
time.Sleep(100 * time.Millisecond)
}
shared.LogDebugf("DbQueryscan: query %q inargs %q, DB still locked", q, inargs)
shared.PrintStack()
return nil, fmt.Errorf("DB is locked")
}
开发者ID:vahe,项目名称:lxd,代码行数:29,代码来源:db.go
示例14: txCommit
func txCommit(tx *sql.Tx) error {
for i := 0; i < 100; i++ {
err := tx.Commit()
if err == nil {
return nil
}
if !isDbLockedError(err) {
shared.LogDebugf("Txcommit: error %q", err)
return err
}
time.Sleep(100 * time.Millisecond)
}
shared.LogDebugf("Txcommit: db still locked")
shared.PrintStack()
return fmt.Errorf("DB is locked")
}
开发者ID:vahe,项目名称:lxd,代码行数:17,代码来源:db.go
示例15: dbBegin
func dbBegin(db *sql.DB) (*sql.Tx, error) {
for i := 0; i < 100; i++ {
tx, err := db.Begin()
if err == nil {
return tx, nil
}
if !isDbLockedError(err) {
shared.LogDebugf("DbBegin: error %q", err)
return nil, err
}
time.Sleep(100 * time.Millisecond)
}
shared.LogDebugf("DbBegin: DB still locked")
shared.PrintStack()
return nil, fmt.Errorf("DB is locked")
}
开发者ID:vahe,项目名称:lxd,代码行数:17,代码来源:db.go
示例16: memProfiler
func memProfiler(memProfile string) {
ch := make(chan os.Signal)
signal.Notify(ch, syscall.SIGUSR1)
for {
sig := <-ch
shared.LogDebugf("Received '%s signal', dumping memory.", sig)
doMemDump(memProfile)
}
}
开发者ID:vahe,项目名称:lxd,代码行数:9,代码来源:debug.go
示例17: controlSocketHandler
func (c *execCmd) controlSocketHandler(d *lxd.Client, control *websocket.Conn) {
// TODO: figure out what the equivalent of signal.SIGWINCH is on
// windows and use that; for now if you resize your terminal it just
// won't work quite correctly.
err := c.sendTermSize(control)
if err != nil {
shared.LogDebugf("error setting term size %s", err)
}
}
开发者ID:vahe,项目名称:lxd,代码行数:9,代码来源:exec_windows.go
示例18: doMemDump
func doMemDump(memProfile string) {
f, err := os.Create(memProfile)
if err != nil {
shared.LogDebugf("Error opening memory profile file '%s': %s", err)
return
}
pprof.WriteHeapProfile(f)
f.Close()
}
开发者ID:vahe,项目名称:lxd,代码行数:9,代码来源:debug.go
示例19: doDeleteImage
func doDeleteImage(d *Daemon, fingerprint string) error {
id, imgInfo, err := dbImageGet(d.db, fingerprint, false, false)
if err != nil {
return err
}
// get storage before deleting images/$fp because we need to
// look at the path
s, err := storageForImage(d, imgInfo)
if err != nil {
shared.LogError("error detecting image storage backend", log.Ctx{"fingerprint": imgInfo.Fingerprint, "err": err})
} else {
// Remove the image from storage backend
if err = s.ImageDelete(imgInfo.Fingerprint); err != nil {
shared.LogError("error deleting the image from storage backend", log.Ctx{"fingerprint": imgInfo.Fingerprint, "err": err})
}
}
// Remove main image file
fname := shared.VarPath("images", imgInfo.Fingerprint)
if shared.PathExists(fname) {
err = os.Remove(fname)
if err != nil {
shared.LogDebugf("Error deleting image file %s: %s", fname, err)
}
}
// Remove the rootfs file
fname = shared.VarPath("images", imgInfo.Fingerprint) + ".rootfs"
if shared.PathExists(fname) {
err = os.Remove(fname)
if err != nil {
shared.LogDebugf("Error deleting image file %s: %s", fname, err)
}
}
// Remove the DB entry
if err = dbImageDelete(d.db, id); err != nil {
return err
}
return nil
}
开发者ID:vahe,项目名称:lxd,代码行数:43,代码来源:images.go
示例20: containersGet
func containersGet(d *Daemon, r *http.Request) Response {
for i := 0; i < 100; i++ {
result, err := doContainersGet(d, d.isRecursionRequest(r))
if err == nil {
return SyncResponse(true, result)
}
if !isDbLockedError(err) {
shared.LogDebugf("DBERR: containersGet: error %q", err)
return InternalError(err)
}
// 1 s may seem drastic, but we really don't want to thrash
// perhaps we should use a random amount
time.Sleep(100 * time.Millisecond)
}
shared.LogDebugf("DBERR: containersGet, db is locked")
shared.PrintStack()
return InternalError(fmt.Errorf("DB is locked"))
}
开发者ID:vahe,项目名称:lxd,代码行数:19,代码来源:containers_get.go
注:本文中的github.com/lxc/lxd/shared.LogDebugf函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论