本文整理汇总了Golang中github.com/cortesi/termlog.TermLog.Say方法的典型用法代码示例。如果您正苦于以下问题:Golang TermLog.Say方法的具体用法?Golang TermLog.Say怎么用?Golang TermLog.Say使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cortesi/termlog.TermLog
的用法示例。
在下文中一共展示了TermLog.Say方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Serve
// Serve starts the devd server. The callback is called with the serving URL
// just before service starts.
func (dd *Devd) Serve(address string, port int, certFile string, logger termlog.TermLog, callback func(string)) error {
templates, err := ricetemp.MakeTemplates(rice.MustFindBox("templates"))
if err != nil {
return fmt.Errorf("Error loading templates: %s", err)
}
mux, err := dd.Router(logger, templates)
if err != nil {
return err
}
var tlsConfig *tls.Config
var tlsEnabled bool
if certFile != "" {
tlsConfig, err = getTLSConfig(certFile)
if err != nil {
return fmt.Errorf("Could not load certs: %s", err)
}
tlsEnabled = true
}
var hl net.Listener
if port > 0 {
hl, err = net.Listen("tcp", fmt.Sprintf("%v:%d", address, port))
} else {
hl, err = pickPort(address, portLow, portHigh, tlsEnabled)
}
if err != nil {
return err
}
if tlsConfig != nil {
hl = tls.NewListener(hl, tlsConfig)
}
hl = slowdown.NewSlowListener(hl, dd.UpKbps*1024, dd.DownKbps*1024)
url := formatURL(tlsEnabled, address, hl.Addr().(*net.TCPAddr).Port)
logger.Say("Listening on %s (%s)", url, hl.Addr().String())
server := &http.Server{Addr: hl.Addr().String(), Handler: mux}
callback(url)
if dd.HasLivereload() {
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGHUP)
go func() {
for {
<-c
logger.Say("Received signal - reloading")
dd.lrserver.Reload([]string{"*"})
}
}()
}
err = server.Serve(hl)
logger.Shout("Server stopped: %v", err)
return nil
}
示例2: RunPreps
// RunPreps runs all commands in sequence. Stops if any command returns an error.
func RunPreps(b conf.Block, vars map[string]string, mod *moddwatch.Mod, log termlog.TermLog, notifiers []notify.Notifier, initial bool) error {
shell := vars[shellVarName]
vcmd := varcmd.VarCmd{Block: &b, Mod: mod, Vars: vars}
for _, p := range b.Preps {
cmd, err := vcmd.Render(p.Command)
if initial && p.Onchange {
log.Say(niceHeader("skipping prep: ", cmd))
continue
}
if err != nil {
return err
}
err = RunProc(cmd, shell, log.Stream(niceHeader("prep: ", cmd)))
if err != nil {
if pe, ok := err.(ProcError); ok {
for _, n := range notifiers {
n.Push("modd error", pe.Output, "")
}
}
return err
}
}
return nil
}