當前位置: 首頁>>代碼示例>>Golang>>正文


Golang logger.Info函數代碼示例

本文整理匯總了Golang中github.com/GoogleCloudPlatform/compute-user-accounts/logger.Info函數的典型用法代碼示例。如果您正苦於以下問題:Golang Info函數的具體用法?Golang Info怎麽用?Golang Info使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Info函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: users

func (s *Server) users() string {
	logger.Info("Getting users.")
	users, err := s.Provider.Users()
	if err != nil {
		return marshalError(err)
	}
	var buf bytes.Buffer
	buf.WriteString("200")
	for _, u := range users {
		buf.WriteString("\n")
		buf.WriteString(marshalUser(u))
	}
	logger.Info("Request succeeded.")
	return buf.String()
}
開發者ID:aulanov,項目名稱:compute-user-accounts,代碼行數:15,代碼來源:server.go

示例2: groups

func (s *Server) groups() string {
	logger.Info("Getting groups.")
	groups, err := s.Provider.Groups()
	if err != nil {
		return marshalError(err)
	}
	var buf bytes.Buffer
	buf.WriteString("200")
	for _, g := range groups {
		buf.WriteString("\n")
		buf.WriteString(marshalGroup(g))
	}
	logger.Info("Request succeeded.")
	return buf.String()
}
開發者ID:aulanov,項目名稱:compute-user-accounts,代碼行數:15,代碼來源:server.go

示例3: names

func (s *Server) names() string {
	logger.Info("Getting names.")
	names, err := s.Provider.Names()
	if err != nil {
		return marshalError(err)
	}
	var buf bytes.Buffer
	buf.WriteString("200")
	for _, n := range names {
		buf.WriteString("\n")
		buf.WriteString(n)
	}
	logger.Info("Request succeeded.")
	return buf.String()
}
開發者ID:aulanov,項目名稱:compute-user-accounts,代碼行數:15,代碼來源:server.go

示例4: main

func main() {
	flag.Parse()
	logger.Info("Starting daemon.")
	interrupt := make(chan os.Signal, 1)
	signal.Notify(interrupt, os.Interrupt, os.Kill, syscall.SIGTERM)
	api, err := apiclient.New(&apiclient.Config{
		APIBase:      *apiBase,
		InstanceBase: *instanceBase,
		UserAgent:    userAgent,
		Timeout:      apiTimeout,
	})
	if err != nil {
		logger.Fatalf("Init failed: %v.", err)
	}
	srv := &server.Server{store.New(api, &store.Config{
		AccountRefreshFrequency: accountRefreshFrequency,
		AccountRefreshCooldown:  accountRefreshCooldown,
		KeyRefreshFrequency:     keyRefreshFrequency,
		KeyRefreshCooldown:      keyRefreshCooldown,
	})}
	go func() {
		err := srv.Serve()
		logger.Fatalf("Server failed: %v.", err)
	}()

	for {
		select {
		case sig := <-interrupt:
			logger.Fatalf("Got interrupt: %v.", sig)
		}
	}
}
開發者ID:Derekolds,項目名稱:compute-user-accounts,代碼行數:32,代碼來源:gcua.go

示例5: isName

func (s *Server) isName(args []string) string {
	name, err := parseName(args)
	if err != nil {
		logger.Errorf("Invalid name: %v.", err)
		return "400"
	}
	logger.Infof("Checking name: %v.", name)
	is, err := s.Provider.IsName(name)
	if err != nil {
		return marshalError(err)
	} else if is {
		logger.Info("Valid name.")
		return "200"
	} else {
		logger.Info("Invalid name.")
		return "404"
	}
}
開發者ID:aulanov,項目名稱:compute-user-accounts,代碼行數:18,代碼來源:server.go

示例6: GroupByName

// GroupByName satisfies AccountProvider.
func (s *cachingStore) GroupByName(name string) (*accounts.Group, error) {
	s.RLock()
	defer s.RUnlock()
	g, ok := s.groupsByName[name]
	if ok {
		return g, nil
	}
	ch := make(chan struct{})
	logger.Info("Triggering refresh due to missing group.")
	go func() { s.updateWaiters <- ch }()
	// Do not block on update.
	return nil, accounts.GroupNameNotFound(name)
}
開發者ID:Derekolds,項目名稱:compute-user-accounts,代碼行數:14,代碼來源:store.go

示例7: userByName

func (s *Server) userByName(args []string) string {
	name, err := parseName(args)
	if err != nil {
		logger.Errorf("Invalid name for user: %v.", err)
		return "400"
	}
	logger.Infof("Getting user by name: %v.", name)
	user, err := s.Provider.UserByName(name)
	if err != nil {
		return marshalError(err)
	}
	logger.Info("Request succeeded.")
	return fmt.Sprintf("200\n%v", marshalUser(user))
}
開發者ID:aulanov,項目名稱:compute-user-accounts,代碼行數:14,代碼來源:server.go

示例8: groupByGID

func (s *Server) groupByGID(args []string) string {
	gid, err := parseID(args)
	if err != nil {
		logger.Errorf("Invalid GID for group: %v.", err)
		return "400"
	}
	logger.Infof("Getting group by GID: %v.", gid)
	group, err := s.Provider.GroupByGID(gid)
	if err != nil {
		return marshalError(err)
	}
	logger.Info("Request succeeded.")
	return fmt.Sprintf("200\n%v", marshalGroup(group))
}
開發者ID:aulanov,項目名稱:compute-user-accounts,代碼行數:14,代碼來源:server.go

示例9: groupByName

func (s *Server) groupByName(args []string) string {
	name, err := parseName(args)
	if err != nil {
		logger.Errorf("Invalid name for group: %v.", err)
		return "400"
	}
	logger.Infof("Getting group by name: %v.", name)
	group, err := s.Provider.GroupByName(name)
	if err != nil {
		return marshalError(err)
	}
	logger.Info("Request succeeded.")
	return fmt.Sprintf("200\n%v", marshalGroup(group))
}
開發者ID:aulanov,項目名稱:compute-user-accounts,代碼行數:14,代碼來源:server.go

示例10: userByUID

func (s *Server) userByUID(args []string) string {
	uid, err := parseID(args)
	if err != nil {
		logger.Errorf("Invalid UID for user: %v.", err)
		return "400"
	}
	logger.Infof("Getting user by UID: %v.", uid)
	user, err := s.Provider.UserByUID(uid)
	if err != nil {
		return marshalError(err)
	}
	logger.Info("Request succeeded.")
	return fmt.Sprintf("200\n%v", marshalUser(user))
}
開發者ID:aulanov,項目名稱:compute-user-accounts,代碼行數:14,代碼來源:server.go

示例11: GroupByName

// GroupByName satisfies AccountProvider.
func (s *cachingStore) GroupByName(name string) (*accounts.Group, error) {
	s.RLock()
	defer s.RUnlock()
	if name == sudoersGroupName {
		return s.sudoersGroup(), nil
	}
	g, ok := s.groupsByName[name]
	if ok {
		return g, nil
	}
	logger.Info("Triggering refresh due to missing group.")
	// Do not block on update.
	go func() { s.updateWaiters <- nil }()
	return nil, accounts.GroupNameNotFound(name)
}
開發者ID:dcarlino,項目名稱:compute-user-accounts,代碼行數:16,代碼來源:store.go

示例12: UsersAndGroups

// UsersAndGroups satisfies APIClient.
func (c *googleAPIClient) UsersAndGroups() ([]*cua.LinuxUserView, []*cua.LinuxGroupView, error) {
	logger.Info("Fetching users and groups.")
	p, z, i, err := c.instanceInfo()
	if err != nil {
		return nil, nil, err
	}
	view, err := c.service.Linux.GetLinuxAccountViews(p, z, i).Do()
	if err != nil {
		return nil, nil, err
	} else if view.Resource == nil {
		// No users or groups.
		return nil, nil, nil
	} else {
		return view.Resource.UserViews, view.Resource.GroupViews, nil
	}
}
開發者ID:Derekolds,項目名稱:compute-user-accounts,代碼行數:17,代碼來源:apiclient.go

示例13: handle

func (s *Server) handle(conn net.Conn) {
	defer conn.Close()
	deadline := time.Now().Add(serverTimeout)
	conn.SetReadDeadline(deadline)
	data := make([]byte, maxRequestSize)
	n, err := conn.Read(data)
	if err != nil {
		logger.Errorf("Failed to read request: %v.", err)
		return
	}
	resp := s.respond(string(data[:n]))
	deadline = time.Now().Add(serverTimeout)
	conn.SetWriteDeadline(deadline)
	_, err = conn.Write([]byte(resp))
	if err != nil {
		logger.Errorf("Failed to write response: %v.", err)
	}
	logger.Info("Request completed.")
}
開發者ID:Derekolds,項目名稱:compute-user-accounts,代碼行數:19,代碼來源:server.go

示例14: updateTask

func updateTask(s *cachingStore) {
	var lastRefresh time.Time
	for {
		var ch chan struct{}
		select {
		case ch = <-s.updateWaiters:
		case <-timeAfter(s.config.AccountRefreshFrequency):
		}
		if nowOutsideTimespan(lastRefresh, s.config.AccountRefreshCooldown) {
			logger.Info("Refreshing users and groups.")
			updateAccounts(s)
			lastRefresh = timeNow()
		}
		go updateKeys(s)
		if ch != nil {
			close(ch)
		}
	}
}
開發者ID:dcarlino,項目名稱:compute-user-accounts,代碼行數:19,代碼來源:store.go

示例15: updateAccounts

func updateAccounts(s *cachingStore) {
	users, groups, err := s.apiClient.UsersAndGroups()
	if err != nil {
		logger.Errorf("Failed refresh: %v.", err)
		return
	}
	s.Lock()
	defer s.Unlock()
	oldUsers := s.usersByName
	s.usersByName = make(map[string]*cachedUser)
	s.usersByUID = make(map[uint32]*cachedUser)
	s.groupsByName = make(map[string]*accounts.Group)
	s.groupsByGID = make(map[uint32]*accounts.Group)
	for _, u := range users {
		user := &accounts.User{
			Name:          u.Username,
			UID:           uint32(u.Uid),
			GID:           uint32(u.Gid),
			Gecos:         u.Gecos,
			HomeDirectory: u.HomeDirectory,
			Shell:         u.Shell,
		}
		cu := &cachedUser{user: user}
		if old, ok := oldUsers[user.Name]; ok {
			cu.keyRefreshTime = old.keyRefreshTime
			cu.keys = old.keys
			cu.sudoer = old.sudoer
		}
		s.usersByName[user.Name] = cu
		s.usersByUID[user.UID] = cu
	}
	for _, g := range groups {
		group := &accounts.Group{
			Name:    g.GroupName,
			GID:     uint32(g.Gid),
			Members: g.Members,
		}
		s.groupsByName[group.Name] = group
		s.groupsByGID[group.GID] = group
	}
	logger.Info("Refreshing users and groups succeeded.")
}
開發者ID:dcarlino,項目名稱:compute-user-accounts,代碼行數:42,代碼來源:store.go


注:本文中的github.com/GoogleCloudPlatform/compute-user-accounts/logger.Info函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。