本文整理匯總了Golang中github.com/evergreen-ci/evergreen.SetLogger函數的典型用法代碼示例。如果您正苦於以下問題:Golang SetLogger函數的具體用法?Golang SetLogger怎麽用?Golang SetLogger使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了SetLogger函數的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(
taskImportanceCmpTestConf))
if taskImportanceCmpTestConf.Scheduler.LogFile != "" {
evergreen.SetLogger(taskImportanceCmpTestConf.Scheduler.LogFile)
}
}
示例2: init
func init() {
db.SetGlobalSessionProvider(
db.SessionFactoryFromConfig(hostAllocatorTestConf))
if hostAllocatorTestConf.Scheduler.LogFile != "" {
evergreen.SetLogger(hostAllocatorTestConf.Scheduler.LogFile)
}
}
示例3: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(
taskQueuePersisterTestConf))
if taskQueuePersisterTestConf.Scheduler.LogFile != "" {
evergreen.SetLogger(taskQueuePersisterTestConf.Scheduler.LogFile)
}
}
示例4: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(
taskDurationEstimatorTestConf))
if taskDurationEstimatorTestConf.Scheduler.LogFile != "" {
evergreen.SetLogger(taskDurationEstimatorTestConf.Scheduler.LogFile)
}
}
示例5: main
func main() {
settings := evergreen.GetSettingsOrExit()
if settings.Runner.LogFile != "" {
evergreen.SetLogger(settings.Runner.LogFile)
}
go util.DumpStackOnSIGQUIT(os.Stdout)
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(settings))
// just run one process if an argument was passed in
if flag.Arg(0) != "" {
err := runProcessByName(flag.Arg(0), settings)
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "Error: %v", err)
os.Exit(1)
}
return
}
if settings.Runner.IntervalSeconds <= 0 {
evergreen.Logger.Logf(slogger.WARN, "Interval set to %vs (<= 0s) using %vs instead",
settings.Runner.IntervalSeconds, runInterval)
} else {
runInterval = settings.Runner.IntervalSeconds
}
// start and schedule runners
wg := &sync.WaitGroup{}
ch := startRunners(wg, settings)
go listenForSIGTERM(ch)
// wait for all the processes to exit
wg.Wait()
evergreen.Logger.Logf(slogger.INFO, "Cleanly terminated all %v processes", len(Runners))
}
示例6: main
func main() {
settings := evergreen.GetSettingsOrExit()
if settings.Ui.LogFile != "" {
evergreen.SetLogger(settings.Ui.LogFile)
}
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(settings))
home := evergreen.FindEvergreenHome()
userManager, err := auth.LoadUserManager(settings.AuthConfig)
if err != nil {
fmt.Println("Failed to create user manager:", err)
os.Exit(1)
}
cookieStore := sessions.NewCookieStore([]byte(settings.Ui.Secret))
uis := ui.UIServer{
nil, // render
settings.Ui.Url, // RootURL
userManager, // User Manager
*settings, // mci settings
cookieStore, // cookiestore
nil, // plugin panel manager
}
router, err := uis.NewRouter()
if err != nil {
fmt.Println("Failed to create router:", err)
os.Exit(1)
}
webHome := filepath.Join(home, "public")
functionOptions := ui.FuncOptions{webHome, settings.Ui.HelpUrl, true, router}
functions, err := ui.MakeTemplateFuncs(functionOptions, settings.SuperUsers)
if err != nil {
fmt.Println("Failed to create template function map:", err)
os.Exit(1)
}
uis.Render = render.New(render.Options{
Directory: filepath.Join(home, ui.WebRootPath, ui.Templates),
DisableCache: !settings.Ui.CacheTemplates,
Funcs: functions,
})
err = uis.InitPlugins()
if err != nil {
fmt.Println("WARNING: Error initializing plugins:", err)
}
n := negroni.New()
n.Use(negroni.NewStatic(http.Dir(webHome)))
n.Use(ui.NewLogger())
n.Use(negroni.HandlerFunc(ui.UserMiddleware(userManager)))
n.UseHandler(router)
graceful.Run(settings.Ui.HttpListenAddr, requestTimeout, n)
evergreen.Logger.Logf(slogger.INFO, "UI server cleanly terminated")
}
示例7: NewUIServer
func NewUIServer(settings *evergreen.Settings, home string) (*UIServer, error) {
uis := &UIServer{}
if settings.Ui.LogFile != "" {
evergreen.SetLogger(settings.Ui.LogFile)
}
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(settings))
uis.Settings = *settings
uis.Home = home
userManager, err := auth.LoadUserManager(settings.AuthConfig)
if err != nil {
return nil, err
}
uis.UserManager = userManager
uis.CookieStore = sessions.NewCookieStore([]byte(settings.Ui.Secret))
uis.PluginTemplates = map[string]*htmlTemplate.Template{}
return uis, nil
}
示例8: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(conf))
evergreen.SetLogger("/tmp/task_test.log")
}
示例9: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(testConfig))
if testConfig.RepoTracker.LogFile != "" {
evergreen.SetLogger(testConfig.RepoTracker.LogFile)
}
}
示例10: TestNotify
func TestNotify(t *testing.T) {
if evergreen.TestConfig().Notify.LogFile != "" {
evergreen.SetLogger(evergreen.TestConfig().Notify.LogFile)
}
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(TestConfig))
emailSubjects = make([]string, 0)
emailBodies = make([]string, 0)
Convey("When running notification handlers", t, func() {
ae, err := createEnvironment(TestConfig, map[string]interface{}{})
So(err, ShouldBeNil)
Convey("Build-specific handlers should return the correct emails", func() {
cleanupdb()
timeNow := time.Now()
// insert the test documents
insertBuildDocs(timeNow)
version := &version.Version{Id: "version"}
So(version.Insert(), ShouldBeNil)
Convey("BuildFailureHandler should return 1 email per failed build", func() {
handler := BuildFailureHandler{}
emails, err := handler.GetNotifications(ae, "config_test",
&buildFailureNotificationKey)
So(err, ShouldBeNil)
// check that we only returned 2 failed notifications
So(len(emails), ShouldEqual, 2)
So(emails[0].GetSubject(), ShouldEqual,
"[MCI-FAILURE ] Build #build1 failed on displayName")
So(emails[1].GetSubject(), ShouldEqual,
"[MCI-FAILURE ] Build #build9 failed on displayName")
})
Convey("BuildSuccessHandler should return 1 email per successful build", func() {
handler := BuildSuccessHandler{}
emails, err := handler.GetNotifications(ae, "config_test",
&buildSucceessNotificationKey)
So(err, ShouldBeNil)
// check that we only returned 2 success notifications
So(len(emails), ShouldEqual, 2)
So(emails[0].GetSubject(), ShouldEqual,
"[MCI-SUCCESS ] Build #build3 succeeded on displayName")
So(emails[1].GetSubject(), ShouldEqual,
"[MCI-SUCCESS ] Build #build8 succeeded on displayName")
})
Convey("BuildCompletionHandler should return 1 email per completed build", func() {
handler := BuildCompletionHandler{}
emails, err := handler.GetNotifications(ae, "config_test",
&buildCompletionNotificationKey)
So(err, ShouldBeNil)
// check that we only returned 6 completed notifications
So(len(emails), ShouldEqual, 4)
So(emails[0].GetSubject(), ShouldEqual,
"[MCI-COMPLETION ] Build #build1 completed on displayName")
So(emails[1].GetSubject(), ShouldEqual,
"[MCI-COMPLETION ] Build #build3 completed on displayName")
So(emails[2].GetSubject(), ShouldEqual,
"[MCI-COMPLETION ] Build #build8 completed on displayName")
So(emails[3].GetSubject(), ShouldEqual,
"[MCI-COMPLETION ] Build #build9 completed on displayName")
})
Convey("BuildSuccessToFailureHandler should return 1 email per "+
"build success to failure transition", func() {
handler := BuildSuccessToFailureHandler{}
emails, err := handler.GetNotifications(ae, "config_test",
&buildSuccessToFailureNotificationKey)
So(err, ShouldBeNil)
// check that we only returned 1 success_to_failure notifications
So(len(emails), ShouldEqual, 1)
So(emails[0].GetSubject(), ShouldEqual,
"[MCI-FAILURE ] Build #build9 transitioned to failure on displayName")
})
})
Convey("Task-specific handlers should return the correct emails", func() {
cleanupdb()
timeNow := time.Now()
// insert the test documents
insertTaskDocs(timeNow)
v := &version.Version{Id: "version"}
So(v.Insert(), ShouldBeNil)
Convey("TaskFailureHandler should return 1 email per task failure", func() {
handler := TaskFailureHandler{}
emails, err := handler.GetNotifications(ae, "config_test",
&taskFailureNotificationKey)
So(err, ShouldBeNil)
// check that we only returned 2 failed notifications
So(len(emails), ShouldEqual, 2)
So(emails[0].GetSubject(), ShouldEqual,
"[MCI-FAILURE ] possible MCI failure in displayName (failed on build1)")
So(emails[1].GetSubject(), ShouldEqual,
"[MCI-FAILURE ] possible MCI failure in displayName (failed on build1)")
})
Convey("TaskSuccessHandler should return 1 email per task success", func() {
handler := TaskSuccessHandler{}
emails, err := handler.GetNotifications(ae, "config_test",
//.........這裏部分代碼省略.........
示例11: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(taskRunnerTestConf))
if taskRunnerTestConf.TaskRunner.LogFile != "" {
evergreen.SetLogger(taskRunnerTestConf.TaskRunner.LogFile)
}
}
示例12: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(taskFinderTestConf))
if setupFuncsTestConf.Scheduler.LogFile != "" {
evergreen.SetLogger(setupFuncsTestConf.Scheduler.LogFile)
}
}
示例13: init
func init() {
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(evergreen.TestConfig()))
evergreen.SetLogger("/tmp/version_test.log")
}
示例14: main
func main() {
settings := evergreen.GetSettingsOrExit()
if settings.Api.LogFile != "" {
evergreen.SetLogger(settings.Api.LogFile)
}
db.SetGlobalSessionProvider(db.SessionFactoryFromConfig(settings))
tlsConfig, err := util.MakeTlsConfig(settings.Expansions["api_httpscert"], settings.Api.HttpsKey)
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "Failed to make TLS config: %v", err)
os.Exit(1)
}
nonSSL, err := apiserver.GetListener(settings.Api.HttpListenAddr)
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "Failed to get HTTP listener: %v", err)
os.Exit(1)
}
ssl, err := apiserver.GetTLSListener(settings.Api.HttpsListenAddr, tlsConfig)
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "Failed to get HTTPS listener: %v", err)
os.Exit(1)
}
// Start SSL and non-SSL servers in independent goroutines, but exit
// the process if either one fails
as, err := apiserver.New(settings, plugin.Published)
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "Failed to create API server: %v", err)
os.Exit(1)
}
handler, err := as.Handler()
if err != nil {
evergreen.Logger.Logf(slogger.ERROR, "Failed to get API route handlers: %v", err)
os.Exit(1)
}
server := &http.Server{Handler: handler}
errChan := make(chan error, 2)
go func() {
evergreen.Logger.Logf(slogger.INFO, "Starting non-SSL API server")
err := graceful.Serve(server, nonSSL, requestTimeout)
if err != nil {
if opErr, ok := err.(*net.OpError); !ok || (ok && opErr.Op != "accept") {
evergreen.Logger.Logf(slogger.WARN, "non-SSL API server error: %v", err)
} else {
err = nil
}
}
evergreen.Logger.Logf(slogger.INFO, "non-SSL API server cleanly terminated")
errChan <- err
}()
go func() {
evergreen.Logger.Logf(slogger.INFO, "Starting SSL API server")
err := graceful.Serve(server, ssl, requestTimeout)
if err != nil {
if opErr, ok := err.(*net.OpError); !ok || (ok && opErr.Op != "accept") {
evergreen.Logger.Logf(slogger.WARN, "SSL API server error: %v", err)
} else {
err = nil
}
}
evergreen.Logger.Logf(slogger.INFO, "SSL API server cleanly terminated")
errChan <- err
}()
exitCode := 0
for i := 0; i < 2; i++ {
if err := <-errChan; err != nil {
evergreen.Logger.Logf(slogger.ERROR, "Error returned from API server: %v", err)
exitCode = 1
}
}
os.Exit(exitCode)
}