func initSurfacer(s *SurfacerDef) (Surfacer, error) {
	// Create a new logger
	logName := s.GetName()
	if logName == "" {
		logName = strings.ToLower(s.GetType().String())
	}

	// TODO: Plumb context here too.
	l, err := logger.New(context.TODO(), logName)
	if err != nil {
		return nil, fmt.Errorf("unable to create cloud logger: %v", err)
	}

	switch s.GetType() {
	case Type_PROMETHEUS:
		return prometheus.New(s.GetPrometheusSurfacer(), l)
	case Type_STACKDRIVER:
		return stackdriver.New(s.GetStackdriverSurfacer(), l)
	case Type_FILE:
		return file.New(s.GetFileSurfacer(), l)
	case Type_USER_DEFINED:
		userDefinedSurfacersMu.Lock()
		defer userDefinedSurfacersMu.Unlock()
		surfacer := userDefinedSurfacers[s.GetName()]
		if surfacer == nil {
			return nil, fmt.Errorf("unregistered user defined surfacer: %s", s.GetName())
		}
		return surfacer, nil
	default:
		return nil, fmt.Errorf("unknown surfacer type: %s", s.GetType())
	}
}
// initSurfacer initializes and returns a new surfacer based on the config.
initSurfacer initializes and returns a new surfacer based on the config.
// initSurfacer initializes and returns a new surfacer based on the config .
func initSurfacer(s *SurfacerDef) (Surfacer, error) {
	logName := s.GetName()
	if logName == "" {
		logName = strings.ToLower(s.GetType().String())
	}
	l, err := logger.New(context.TODO(), logName)
	if err != nil {
		return nil, fmt.Errorf("unable to create cloud logger: %v", err)
	}
	switch s.GetType() {
	case Type_PROMETHEUS:
		return prometheus.New(s.GetPrometheusSurfacer(), l)
	case Type_STACKDRIVER:
		return stackdriver.New(s.GetStackdriverSurfacer(), l)
	case Type_FILE:
		return file.New(s.GetFileSurfacer(), l)
	case Type_USER_DEFINED:
		userDefinedSurfacersMu.Lock()
		defer userDefinedSurfacersMu.Unlock()
		surfacer := userDefinedSurfacers[s.GetName()]
		if surfacer == nil {
			return nil, fmt.Errorf("unregistered user defined surfacer: %s", s.GetName())
		}
		return surfacer, nil
	default:
		return nil, fmt.Errorf("unknown surfacer type: %s", s.GetType())
	}
}
func initSurfacer ( s * SurfacerDef ) ( Surfacer , error ) { logName := s . GetName ( ) if logName == " " { logName = strings . ToLower ( s . GetType ( ) . String ( ) ) } l , err := logger . New ( context . TODO ( ) , logName ) if err != nil { return nil , fmt . Errorf ( " " , err ) } switch s . GetType ( ) { case Type_PROMETHEUS : return prometheus . New ( s . GetPrometheusSurfacer ( ) , l ) case Type_STACKDRIVER : return stackdriver . New ( s . GetStackdriverSurfacer ( ) , l ) case Type_FILE : return file . New ( s . GetFileSurfacer ( ) , l ) case Type_USER_DEFINED : userDefinedSurfacersMu . Lock ( ) defer userDefinedSurfacersMu . Unlock ( ) surfacer := userDefinedSurfacers [ s . GetName ( ) ] if surfacer == nil { return nil , fmt . Errorf ( " " , s . GetName ( ) ) } return surfacer , nil default : return nil , fmt . Errorf ( " " , s . GetType ( ) ) } }
initSurfacer initializes and returns a new surfacer based on the config.
initSurfacer initializes and returns a new surfacer based on the config .
// Create a new logger // TODO: Plumb context here too.