本文整理匯總了Golang中github.com/gfrey/smutje/logger.Logger.Tag方法的典型用法代碼示例。如果您正苦於以下問題:Golang Logger.Tag方法的具體用法?Golang Logger.Tag怎麽用?Golang Logger.Tag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/gfrey/smutje/logger.Logger
的用法示例。
在下文中一共展示了Logger.Tag方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Provision
func (res *smResource) Provision(l logger.Logger) (err error) {
l = l.Tag(res.ID)
for _, pkg := range res.Packages {
if err := pkg.Provision(l, res.client); err != nil {
return err
}
}
return nil
}
示例2: Prepare
func (res *smResource) Prepare(l logger.Logger) error {
l = l.Tag(res.ID)
if err := res.initializeClient(); err != nil {
return err
}
for _, pkg := range res.Packages {
if err := pkg.Prepare(res.client, res.Attributes); err != nil {
return err
}
}
return nil
}
示例3: newLoggedSession
func newLoggedSession(l logger.Logger, sess Session) (Session, error) {
s := &loggedSession{Session: sess, wg: new(sync.WaitGroup)}
stdout, err := s.Session.StdoutPipe()
if err != nil {
return nil, errors.Wrap(err, "failed to build stdout pipe")
}
stderr, err := s.Session.StderrPipe()
if err != nil {
return nil, errors.Wrap(err, "failed to build stderr pipe")
}
s.wg.Add(2)
go s.readStream(l.Tag("stdout"), stdout)
go s.readStream(l.Tag("stderr"), stderr)
return s, nil
}
示例4: Provision
func (pkg *smPackage) Provision(l logger.Logger, client connection.Client) (err error) {
l = l.Tag(pkg.ID)
oldState := pkg.state
pkg.state = make([]string, len(pkg.Scripts))
allCached := true
defer func() {
if allCached {
return
}
e := pkg.writeTargetState(client)
if err == nil {
err = e
}
}()
for i, s := range pkg.Scripts {
hash := s.Hash()
if allCached && i < len(oldState) && oldState[i][1:] == hash {
l.Printf("step %d cached", i)
pkg.state[i] = "." + hash
continue
}
allCached = false
if err = s.Exec(l, client); err != nil {
l.Printf("failed in %s", hash)
pkg.state[i] = "-" + hash
pkg.state = pkg.state[:i+1]
return err
}
pkg.state[i] = "+" + hash
}
return nil
}