// InitLogs initializes logs the way we want for kubernetes.
163916
func InitLogs() {
	log.SetOutput(KlogWriter{})
	log.SetFlags(0)
	// The default glog flush interval is 5 seconds.
	go wait.Until(klog.Flush, *logFlushFreq, wait.NeverStop)
}
382583
func init() {
	for _, arg := range os.Args {
		flag := strings.TrimLeft(arg, "-")

		for _, enabler := range enablerFlags {
			if !Enabled && flag == enabler {
				log.Info("Enabling metrics collection")
				Enabled = true
			}
		}
		for _, enabler := range expensiveEnablerFlags {
			if !EnabledExpensive && flag == enabler {
				log.Info("Enabling expensive metrics collection")
				EnabledExpensive = true
			}
		}
	}
}
1048513
func (s *Server) getLogs(request *restful.Request, response *restful.Response) {
	s.host.ServeLogs(response, request.Request)
}
658129
func (w *fileLogWriter) Init(jsonConfig string) error {
	err := json.Unmarshal([]byte(jsonConfig), w)
	if err != nil {
		return err
	}
	if len(w.Filename) == 0 {
		return errors.New("jsonconfig must have filename")
	}
	w.suffix = filepath.Ext(w.Filename)
	w.fileNameOnly = strings.TrimSuffix(w.Filename, w.suffix)
	if w.suffix == "" {
		w.suffix = ".log"
	}
	err = w.startLogger()
	return err
}
1197198
func Init(l ...Logger) {
	for _, logger := range l {
		gl.loggers = append(gl.loggers, logger)
	}
}
976428
func (c *ServicedCli) initLog() {
	c.app.Commands = append(c.app.Commands, cli.Command{
		Name:        "log",
		Usage:       "Administers logs",
		Description: "",
		Subcommands: []cli.Command{
			{
				Name:        "export",
				Usage:       "Exports application log data",
				Description: "serviced log export",
				// TODO: BashComplete: c.printLogExportCompletion,
				Action: c.cmdExportLogs,
				Flags: []cli.Flag{
					cli.StringFlag{
						Name:  "from",
						Value: "",
						Usage: "yyyy.mm.dd",
					},
					cli.StringFlag{
						Name:  "to",
						Value: "",
						Usage: "yyyy.mm.dd",
					},
					cli.StringSliceFlag{
						Name:  "service",
						Value: &cli.StringSlice{},
						Usage: "service ID or name (includes all child services)",
					},
					cli.StringSliceFlag{
						Name:  "file",
						Value: &cli.StringSlice{},
						Usage: "the application log filename",
					},
					cli.StringFlag{
						Name:  "out",
						Value: "",
						Usage: "path to output file",
					},
					cli.BoolFlag{
						Name:  "debug, d",
						Usage: "Show additional diagnostic messages",
					},
					cli.StringFlag{
						Name:  "group-by",
						Value: "container",
						Usage: "Group results either by container, service or day",
					},
					cli.BoolFlag{
						Name:  "no-children, n",
						Usage: "Do not export child services",
					},
				},
			},
		},
	})
}
1310171
func Init(enableLog bool) *echo.Echo {
	e := echo.New()
	if enableLog {
		e.Use(middleware.Logger())
	}
	e.Pre(middleware.RemoveTrailingSlash())

	// Create the Authorization server for OAuth2
	authConfig := osin.NewServerConfig()
	// Configure the Authorization server
	authConfig.AllowedAuthorizeTypes = osin.AllowedAuthorizeType{osin.CODE, osin.TOKEN}
	authConfig.AllowedAccessTypes = osin.AllowedAccessType{
		osin.AUTHORIZATION_CODE,
		osin.REFRESH_TOKEN,
		osin.PASSWORD,
		osin.CLIENT_CREDENTIALS,
	}
	authConfig.AllowGetAccessRequest = true
	authConfig.AllowClientSecretInParams = true

	// Create the storage for osin (where to save oauth infos)
	var authStorage nerdz.OAuth2Storage
	authorizationServer := osin.NewServer(authConfig, &authStorage)

	// Initialize oauth2 server implementation
	oauth2.Init(authorizationServer)

	basePath := e.Group("/v" + strconv.Itoa(VERSION))

	/**************************************************************************
	* ROUTE /oauth2
	* Authorization not required.
	***************************************************************************/
	o := basePath.Group("/oauth2")
	o.GET("/authorize", oauth2.Authorize())
	o.POST("/authorize", oauth2.Authorize())
	o.GET("/token", oauth2.Token())
	o.GET("/info", oauth2.Info())

	/**************************************************************************
	* ROUTE /users/:id
	* Authorization required
	***************************************************************************/
	usersG := basePath.Group("/users") // users Group
	usersG.Use(authorization())
	usersG.Use(user.SetOther())
	usersG.GET("/:id", user.Info())
	usersG.GET("/:id/friends", user.Friends())
	usersG.GET("/:id/followers", user.Followers())
	usersG.GET("/:id/whitelist", user.Whitelist())
	usersG.GET("/:id/whitelisting", user.Whitelisting())
	usersG.GET("/:id/blacklist", user.Blacklist())
	usersG.GET("/:id/blacklisting", user.Blacklisting())
	usersG.GET("/:id/following/users", user.UserFollowing())
	usersG.GET("/:id/following/projects", user.ProjectFollowing())
	// uses setPostlist middleware
	usersG.GET("/:id/posts", user.Posts(), setPostlist())
	usersG.POST("/:id/posts", user.NewPost())
	// requests below uses the user.SetPost() middleware to refer to the requested post
	usersG.GET("/:id/posts/:pid", user.Post(), user.SetPost())
	usersG.PUT("/:id/posts/:pid", user.EditPost(), user.SetPost())
	usersG.DELETE("/:id/posts/:pid", user.DeletePost(), user.SetPost())
	// Votes
	usersG.GET("/:id/posts/:pid/votes", user.PostVotes(), user.SetPost())
	// Vote can be used to add/edit/delete the vote, just changing the vote value
	usersG.POST("/:id/posts/:pid/votes", user.NewPostVote(), user.SetPost())
	// Bookmark
	usersG.GET("/:id/posts/:pid/bookmarks", user.PostBookmarks(), user.SetPost())
	usersG.POST("/:id/posts/:pid/bookmarks", user.NewPostBookmark(), user.SetPost())
	usersG.DELETE("/:id/posts/:pid/bookmarks", user.DeletePostBookmark(), user.SetPost())
	// Lurk
	usersG.GET("/:id/posts/:pid/lurks", user.PostLurks(), user.SetPost())
	usersG.POST("/:id/posts/:pid/lurks", user.NewPostLurk(), user.SetPost())
	usersG.DELETE("/:id/posts/:pid/lurks", user.DeletePostLurk(), user.SetPost())
	// Lock
	usersG.GET("/:id/posts/:pid/locks", user.PostLock(), user.SetPost())
	usersG.POST("/:id/posts/:pid/locks", user.NewPostLock(), user.SetPost())
	usersG.DELETE("/:id/posts/:pid/locks", user.DeletePostLock(), user.SetPost())
	usersG.POST("/:id/posts/:pid/locks/:target", user.NewPostUserLock(), user.SetPost())
	usersG.DELETE("/:id/posts/:pid/locks/:target", user.DeletePostUserLock(), user.SetPost())
	// uses setCommentList middleware
	usersG.GET("/:id/posts/:pid/comments", user.PostComments(), user.SetPost(), setCommentList())
	usersG.POST("/:id/posts/:pid/comments", user.NewPostComment(), user.SetPost())
	// requests below uses user.SetComment middleware
	usersG.GET("/:id/posts/:pid/comments/:cid", user.PostComment(), user.SetPost(), user.SetComment())
	usersG.PUT("/:id/posts/:pid/comments/:cid", user.EditPostComment(), user.SetPost(), user.SetComment())
	usersG.DELETE("/:id/posts/:pid/comments/:cid", user.DeletePostComment(), user.SetPost(), user.SetComment())
	// Votes
	usersG.GET("/:id/posts/:pid/comments/:cid/votes", user.PostCommentVotes(), user.SetPost(), user.SetComment())
	usersG.POST("/:id/posts/:pid/comments/:cid/votes", user.NewPostCommentVote(), user.SetPost(), user.SetComment())

	/**************************************************************************
	* ROUTE /me
	* Authorization required
	***************************************************************************/
	meG := basePath.Group("/me")
	meG.Use(authorization())
	meG.Use(me.SetOther())
	// Read only
	meG.GET("", me.Info())
	meG.GET("/friends", me.Friends())
	meG.GET("/followers", me.Followers())
	// Read & write
	meG.GET("/following/users", me.UserFollowing())
	meG.POST("/following/users/:target", me.NewUserFollowing())
	meG.DELETE("/following/users/:target", me.DeleteUserFollowing())
	meG.GET("/following/projects", me.ProjectFollowing())
	meG.POST("/following/projects/:target", me.NewProjectFollowing())
	meG.DELETE("/following/projects/:target", me.DeleteProjectFollowing())
	meG.GET("/whitelist", me.Whitelist())
	meG.POST("/whitelist/:target", me.NewWhitelisted())
	meG.DELETE("/whitelist/:target", me.DeleteWhitelisted())
	// Read only
	meG.GET("/whitelisting", me.Whitelisting())
	// Read & write
	meG.GET("/blacklist", me.Blacklist())
	meG.POST("/blacklist/:target", me.NewBlacklisted())
	meG.DELETE("/blacklist/:target", me.DeleteBlacklisted())
	// Read only
	meG.GET("/blacklisting", me.Blacklisting())
	meG.GET("/home", me.Home(), setPostlist())
	meG.GET("/pms", me.Conversations())
	// uses setPmsOptions middleware
	meG.GET("/pms/:other", me.Conversation(), setPmsOptions())
	meG.POST("/pms/:other", me.NewPm())
	meG.DELETE("/pms/:other", me.DeleteConversation())
	// requests below uses the user.SetPm() middleware to refer to the requested pm
	meG.GET("/pms/:other/:pmid", me.Pm(), me.SetPm())
	// Disabled. At the moment pms' edit is not supported
	//meG.PUT("/pms/:other/:pmid", me.EditPm(), me.SetPm())
	meG.DELETE("/pms/:other/:pmid", me.DeletePm(), me.SetPm())

	// uses setPostlist middleware
	meG.GET("/posts", me.Posts(), setPostlist())
	meG.POST("/posts", me.NewPost())
	// requests below uses the user.SetPost() middleware to refer to the requested post
	meG.GET("/posts/:pid", me.Post(), me.SetPost())
	meG.PUT("/posts/:pid", me.EditPost(), me.SetPost())
	meG.DELETE("/posts/:pid", me.DeletePost(), me.SetPost())
	// Votes
	meG.GET("/posts/:pid/votes", me.PostVotes(), me.SetPost())
	// Vote can be used to add/edit/delete the vote, just changing the vote value
	meG.POST("/posts/:pid/votes", me.NewPostVote(), me.SetPost())
	// Bookmark
	meG.GET("/posts/:pid/bookmarks", me.PostBookmarks(), me.SetPost())
	meG.POST("/posts/:pid/bookmarks", me.NewPostBookmark(), me.SetPost())
	meG.DELETE("/posts/:pid/bookmarks", me.DeletePostBookmark(), me.SetPost())
	// Lurk
	meG.GET("/posts/:pid/lurks", me.PostLurks(), me.SetPost())
	meG.POST("/posts/:pid/lurks", me.NewPostLurk(), me.SetPost())
	meG.DELETE("/posts/:pid/lurks", me.DeletePostLurk(), me.SetPost())
	// Lock
	meG.GET("/posts/:pid/locks", me.PostLock(), me.SetPost())
	meG.POST("/posts/:pid/locks", me.NewPostLock(), me.SetPost())
	meG.DELETE("/posts/:pid/locks", me.DeletePostLock(), me.SetPost())
	meG.POST("/posts/:pid/locks/:target", me.NewPostUserLock(), me.SetPost())
	meG.DELETE("/posts/:pid/locks/:target", me.DeletePostUserLock(), me.SetPost())
	// uses setCommentList middleware
	meG.GET("/posts/:pid/comments", me.PostComments(), me.SetPost(), setCommentList())
	meG.POST("/posts/:pid/comments", me.NewPostComment(), me.SetPost())
	// requests below uses me.SetComment middleware
	meG.GET("/posts/:pid/comments/:cid", me.PostComment(), me.SetPost(), me.SetComment())
	meG.PUT("/posts/:pid/comments/:cid", me.EditPostComment(), me.SetPost(), me.SetComment())
	meG.DELETE("/posts/:pid/comments/:cid", me.DeletePostComment(), me.SetPost(), me.SetComment())
	// Votes
	meG.GET("/posts/:pid/comments/:cid/votes", me.PostCommentVotes(), me.SetPost(), me.SetComment())
	meG.POST("/posts/:pid/comments/:cid/votes", me.NewPostCommentVote(), me.SetPost(), me.SetComment())

	/**************************************************************************
	* ROUTE /projects/:id
	* Authorization required
	***************************************************************************/
	projectG := basePath.Group("/projects") // users Group
	projectG.Use(authorization())
	projectG.Use(project.SetProject())
	projectG.GET("/:id", project.Info())
	projectG.GET("/:id/members", project.Members())
	projectG.GET("/:id/followers", project.Followers())
	// uses setPostlist middleware
	projectG.GET("/:id/posts", project.Posts(), setPostlist())
	projectG.POST("/:id/posts", project.NewPost())
	// requests below uses the project.SetPost() middleware to refer to the requested post
	projectG.GET("/:id/posts/:pid", project.Post(), project.SetPost())
	projectG.PUT("/:id/posts/:pid", project.EditPost(), project.SetPost())
	projectG.DELETE("/:id/posts/:pid", project.DeletePost(), project.SetPost())
	// Votes
	projectG.GET("/:id/posts/:pid/votes", project.PostVotes(), project.SetPost())
	// Vote can be used to add/edit/delete the vote, just changing the vote value
	projectG.POST("/:id/posts/:pid/votes", project.NewPostVote(), project.SetPost())
	// Bookmark
	projectG.GET("/:id/posts/:pid/bookmarks", project.PostBookmarks(), project.SetPost())
	projectG.POST("/:id/posts/:pid/bookmarks", project.NewPostBookmark(), project.SetPost())
	projectG.DELETE("/:id/posts/:pid/bookmarks", project.DeletePostBookmark(), project.SetPost())
	// Lurk
	projectG.GET("/:id/posts/:pid/lurks", project.PostLurks(), project.SetPost())
	projectG.POST("/:id/posts/:pid/lurks", project.NewPostLurk(), project.SetPost())
	projectG.DELETE("/:id/posts/:pid/lurks", project.DeletePostLurk(), project.SetPost())
	// Lock
	projectG.GET("/:id/posts/:pid/locks", project.PostLock(), project.SetPost())
	projectG.POST("/:id/posts/:pid/locks", project.NewPostLock(), project.SetPost())
	projectG.DELETE("/:id/posts/:pid/locks", project.DeletePostLock(), project.SetPost())
	projectG.POST("/:id/posts/:pid/locks/:target", project.NewPostUserLock(), project.SetPost())
	projectG.DELETE("/:id/posts/:pid/locks/:target", project.DeletePostUserLock(), project.SetPost())
	// uses setCommentList middleware
	projectG.GET("/:id/posts/:pid/comments", project.PostComments(), project.SetPost(), setCommentList())
	projectG.POST("/:id/posts/:pid/comments", project.NewPostComment(), project.SetPost())
	// requests below uses project.SetComment middleware
	projectG.GET("/:id/posts/:pid/comments/:cid", project.PostComment(), project.SetPost(), project.SetComment())
	projectG.PUT("/:id/posts/:pid/comments/:cid", project.EditPostComment(), project.SetPost(), project.SetComment())
	projectG.DELETE("/:id/posts/:pid/comments/:cid", project.DeletePostComment(), project.SetPost(), project.SetComment())
	// Votes
	projectG.GET("/:id/posts/:pid/comments/:cid/votes", project.PostCommentVotes(), project.SetPost(), project.SetComment())
	projectG.POST("/:id/posts/:pid/comments/:cid/votes", project.NewPostCommentVote(), project.SetPost(), project.SetComment())

	/**************************************************************************
	* Stream API
	* ROUTE /stream/me
	* Authorization required
	***************************************************************************/
	s := basePath.Group("/stream/me")
	s.Use(authorization())
	// notification for current logged in user
	s.GET("/notifications", stream.Notifications())
	// TODO
	// /stream/users group
	//streamUsers := s.Group("/users/:id")
	// live update of current open profile
	//streamUsers.GET("/", stream.UserPosts())
	// live update of comments on current post
	//streamUsers.GET("/:pid/comments", stream.UserPostComments())

	return e
}
796771
func InitLogger(logLevel int) {
	SetLogLevel(logLevel)
	if logLevel <= LDebug {
		log.SetFlags(log.LstdFlags | log.Lshortfile)
	}
}
218722
func (d *MasterDaemon) InitServices() {
	if d.ClusterMode == "kubernetes" {
		isLeader := func() bool {
			return d.currState == "leader"
		}
		networkpolicy.InitK8SServiceWatch(d.ControlURL, isLeader)
	}
}
199344
func init() {
	loggingProvider := flogging.MustGetLogger("orderer.consensus.kafka.sarama")
	saramaEventLogger := &saramaLoggerImpl{
		logger: loggingProvider.WithOptions(zap.AddCallerSkip(3)),
		eventListenerSupport: &eventListenerSupport{
			listeners: make(map[string][]chan string),
		},
	}
	sarama.Logger = saramaEventLogger
	saramaLogger = saramaEventLogger
}
1364081
func initialize() {
	defaultLogger = &Logger{
		infoLog:    log.New(os.Stderr, initText+tagInfo, flags),
		warningLog: log.New(os.Stderr, initText+tagWarning, flags),
		errorLog:   log.New(os.Stderr, initText+tagError, flags),
		fatalLog:   log.New(os.Stderr, initText+tagFatal, flags),
	}
}
254323
func generateLogs() {
	myLogger := logRegistry.NewLogger("MyLogger")

	for range time.NewTicker(10 * time.Second).C {

		myLogger.Debug("My logger")
		myLogger.Info("My logger")
		myLogger.Error("My logger")

		defaultLogger.Debug("Default logger")
		defaultLogger.Info("Default logger")
		defaultLogger.Error("Default logger")
	}
}
1192676
func InitLogrus() {
	switch {
	case bool(klog.V(4)):
		serviceability.InitLogrus("DEBUG")
	case bool(klog.V(2)):
		serviceability.InitLogrus("INFO")
	case bool(klog.V(0)):
		serviceability.InitLogrus("WARN")
	}
}
440125
func (l *Logger) SetLogInit(fn func(Log, *gear.Context)) *Logger {
	l.mu.Lock()
	defer l.mu.Unlock()
	l.init = fn
	return l
}
1115252
func (a *api) ExportLogs(configParam ExportLogsConfig) (err error) {

	startTime := time.Now().UTC()
	// time.RFC3339 = "2006-01-02T15:04:05Z07:00"
	timeLabel := strings.Replace(startTime.Format(time.RFC3339), ":", "", -1)

	e := validateConfiguration(&configParam, timeLabel)
	if e != nil {
		return e
	}

	var exporter *logExporter
	defer func() {
		if exporter != nil {
			exporter.cleanup()
		}
	}()

	exporter, e = buildExporter(configParam, startTime, timeLabel, a.GetAllServiceDetails, a.GetHostMap)
	if e != nil {
		return e
	}

	numWarnings := 0
	foundIndexedDay := false

	log := log.WithFields(logrus.Fields{
		"tmpdir": exporter.tempdir,
		"from":   exporter.FromDate,
		"to":     exporter.ToDate,
	})
	log.Info("Starting part 1 of 3: Processing Logstash Elastic results")
	foundIndexedDay, numWarnings, e = exporter.retrieveLogs()
	if e != nil {
		return e
	} else if !foundIndexedDay {
		return fmt.Errorf("no logstash indexes exist for the given date range %s - %s", exporter.FromDate, exporter.ToDate)
	}

	log.WithFields(logrus.Fields{
		"numfiles": len(exporter.outputFiles),
	}).Info("Starting part 2 of 3: Sort output files")

	indexData := []string{}
	for i, outputFile := range exporter.outputFiles {
		if e := exporter.organizeAndGroomLogFile(i, numWarnings); e != nil {
			return e
		}
		indexData = append(indexData, exporter.fileIndex.GetFileIndexData(
			i,
			outputFile,
			exporter.getHostName(outputFile.HostID),
			exporter.getServiceName(outputFile.ServiceID)))
	}
	sort.Strings(indexData)

	servicesDesc := make([]string, 0)
	for _, id := range configParam.ServiceIDs {
		servicesDesc = append(servicesDesc, fmt.Sprintf("%s (%s)", exporter.getServiceName(id), id))
	}
	indexData = append([]string{
		"LOG EXPORT SUMMARY",
		fmt.Sprintf("       Export Ran On: %s", exporter.startTime.Format(time.RFC1123)),
		fmt.Sprintf("Available Date Range: %s - %s", exporter.days[len(exporter.days)-1], exporter.days[0]),
		fmt.Sprintf("     Requested Dates: %s - %s", configParam.FromDate, configParam.ToDate),
		fmt.Sprintf("      Exported Dates: %s - %s", exporter.minDateFound, exporter.maxDateFound),
		fmt.Sprintf("          Grouped By: %s", configParam.GroupBy),
		fmt.Sprintf("Requested Service(s): %s", strings.Join(servicesDesc, ", ")),
		fmt.Sprintf("Child Svcs Excluded?: %s", strconv.FormatBool(configParam.ExcludeChildren)),
		fmt.Sprintf("   Requested File(s): %s", strings.Join(configParam.FileNames, ", ")),
		"",
		"INDEX OF LOG FILES",
		exporter.fileIndex.GetIndexHeader()},
		indexData...)
	indexData = append(indexData, "")
	indexFile := filepath.Join(exporter.tempdir, "index.txt")
	e = ioutil.WriteFile(indexFile, []byte(strings.Join(indexData, "\n")), 0644)
	if e != nil {
		return fmt.Errorf("failed writing to %s: %s", indexFile, e)
	}

	log.WithFields(logrus.Fields{
		"outfile": exporter.OutFileName,
	}).Info("Starting part 3 of 3: Generate tar file")
	gz := gzip.NewWriter(exporter.outFile)
	defer gz.Close()
	tarfile := tar.NewWriter(gz)
	defer tarfile.Close()
	if e := volume.ExportDirectory(tarfile, exporter.tempdir, filepath.Base(exporter.tempdir)); e != nil {
		return fmt.Errorf("failed to write tgz %s: %s", exporter.OutFileName, e)
	}

	if numWarnings != 0 {
		log.WithFields(logrus.Fields{
			"warnfile": filepath.Join(filepath.Base(exporter.tempdir), filepath.Base(exporter.parseWarningsFilename)),
		}).Info("Warnings for log parse are included in the tar file")
	}

	return nil
}
1125029
func AppLogs(appID string, lines int) error {
	c, appID, err := load(appID)

	if err != nil {
		return err
	}

	logs, err := apps.Logs(c, appID, lines)

	if err != nil {
		return err
	}

	return printLogs(logs)
}
798223
func InitLogger(handle io.Writer, prefix string) *log.Logger {
	return log.New(handle, strings.Join([]string{prefix, ": "}, ""), log.Ldate|log.Ltime|log.Lshortfile)
}