// AfterInit demonstrates the usage of PluginLogger API.
504330
func (plugin *ExamplePlugin) AfterInit() (err error) {
	late := plugin.Log.NewLogger("late")
	late.Debugf("late debug message")

	// End the example
	plugin.Log.Info("logs in plugin example finished, sending shutdown ...")
	close(plugin.exampleFinished)

	return nil
}
715393
func (p *Plugin) Init() (err error) {
	if p.Config == nil {
		p.Config, err = p.getConfig()
		if err != nil || p.disabled {
			return err
		}
	}

	clientCfg, err := ConfigToClient(p.Config)
	if err != nil {
		return err
	}
	p.client, err = NewClient(clientCfg)
	if err != nil {
		p.Log.Errorf("Err: %v", err)
		return err
	}

	p.reconnectResync = p.Config.ReconnectResync
	p.protoWrapper = kvproto.NewProtoWrapper(p.client, &keyval.SerializerJSON{})

	// Register for providing status reports (polling mode)
	if p.StatusCheck != nil {
		p.StatusCheck.Register(p.PluginName, p.statusCheckProbe)
	} else {
		p.Log.Warnf("Unable to start status check for consul")
	}

	return nil
}
1058746
func (l *PluginLoader) initInternal(plugins map[PluginID]*InternalPluginConfig, configs map[string]*config.PluginConfig) (map[PluginID]*pluginInfo, error) {
	var mErr multierror.Error
	fingerprinted := make(map[PluginID]*pluginInfo, len(plugins))
	for k, config := range plugins {
		// Create an instance
		raw := config.Factory(l.logger)
		base, ok := raw.(base.BasePlugin)
		if !ok {
			multierror.Append(&mErr, fmt.Errorf("internal plugin %s doesn't meet base plugin interface", k))
			continue
		}

		info := &pluginInfo{
			factory: config.Factory,
			config:  config.Config,
		}

		// Try to retrieve a user specified config
		if userConfig, ok := configs[k.Name]; ok && userConfig.Config != nil {
			info.config = userConfig.Config
		}

		// Fingerprint base info
		i, err := base.PluginInfo()
		if err != nil {
			multierror.Append(&mErr, fmt.Errorf("PluginInfo info failed for internal plugin %s: %v", k, err))
			continue
		}
		info.baseInfo = i

		// Parse and set the plugin version
		v, err := version.NewVersion(i.PluginVersion)
		if err != nil {
			multierror.Append(&mErr, fmt.Errorf("failed to parse version %q for internal plugin %s: %v", i.PluginVersion, k, err))
			continue
		}
		info.version = v

		// Detect the plugin API version to use
		av, err := l.selectApiVersion(i)
		if err != nil {
			multierror.Append(&mErr, fmt.Errorf("failed to validate API versions %v for internal plugin %s: %v", i.PluginApiVersions, k, err))
			continue
		}
		if av == "" {
			l.logger.Warn("skipping plugin because supported API versions for plugin and Nomad do not overlap", "plugin", k)
			continue
		}
		info.apiVersion = av

		// Get the config schema
		schema, err := base.ConfigSchema()
		if err != nil {
			multierror.Append(&mErr, fmt.Errorf("failed to retrieve config schema for internal plugin %s: %v", k, err))
			continue
		}
		info.configSchema = schema

		// Store the fingerprinted config
		fingerprinted[k] = info
	}

	if err := mErr.ErrorOrNil(); err != nil {
		return nil, err
	}

	return fingerprinted, nil
}
544668
func (p *Plugin) Init() error {
	// Read fileDB configuration file
	var err error
	p.config, err = p.getFileDBConfig()
	if err != nil || p.disabled {
		return err
	}

	// Register decoders
	decoders := []decoder.API{decoder.NewJSONDecoder(), decoder.NewYAMLDecoder()}
	if p.client, err = NewClient(p.config.ConfigPaths, p.config.StatusPath, decoders, filesystem.NewFsHandler(), p.Log); err != nil {
		return err
	}

	p.protoWrapper = kvproto.NewProtoWrapper(p.client, &keyval.SerializerJSON{})

	return nil
}
27771
func (i pluginInitializer) Initialize(plugin admission.Interface) {
	if wants, ok := plugin.(WantsInternalWardleInformerFactory); ok {
		wants.SetInternalWardleInformerFactory(i.informers)
	}
}
1117462
func (s *Service) initLogger() {
	log.SetLevel(s.options.LogSeverity.S)
	// If LogFormatter is specified then Log is ignored.
	if s.options.LogFormatter != nil {
		log.SetOutput(os.Stdout)
		log.SetFormatter(s.options.LogFormatter)
		return
	}
	if s.options.Log == "console" {
		log.SetOutput(os.Stdout)
		log.SetFormatter(&log.TextFormatter{})
		return
	}
	var err error
	if s.options.Log == "syslog" {
		var devNull *os.File
		devNull, err = os.OpenFile("/dev/null", os.O_WRONLY, 0)
		if err == nil {
			var hook *logrus_syslog.SyslogHook
			hook, err = logrus_syslog.NewSyslogHook("udp", "127.0.0.1:514", syslog.LOG_INFO|syslog.LOG_MAIL, "vulcand")
			if err == nil {
				log.SetOutput(devNull)
				log.SetFormatter(&log.TextFormatter{DisableColors: true})
				log.AddHook(hook)
				return
			}
		}
	}
	if s.options.Log == "json" {
		log.SetOutput(os.Stdout)
		log.SetFormatter(&log.JSONFormatter{})
		return
	}
	if s.options.Log == "logstash" {
		log.SetOutput(os.Stdout)
		log.SetFormatter(&logrus_logstash.LogstashFormatter{Fields: log.Fields{"type": "logs"}})
		return
	}
	log.SetOutput(os.Stdout)
	log.SetFormatter(&log.TextFormatter{})
	log.Warnf("Failed to initialized logger. Fallback to default: logger=%s, err=(%s)", s.options.Log, err)
}
115258
func (p *ExamplePlugin) Init() error {
	p.Log.Info("Init plugin..")
	// Initialize plugin fields.
	p.resyncChannel = make(chan datasync.ResyncEvent)
	p.changeChannel = make(chan datasync.ChangeEvent)

	p.context, p.cancel = context.WithCancel(context.Background())

	// Start the consumer (ETCD watcher).
	p.wg.Add(1)
	go p.consumer()

	// Subscribe watcher to be able to watch on data changes and resync events.
	err := p.subscribeWatcher()
	if err != nil {
		return err
	}

	p.Log.Info("Plugin Init for datasync example done")

	return nil
}
647602
func (p *Plugin) Init() error {
	if p.MicroserviceLabel == "" {
		p.MicroserviceLabel = microserviceLabelFlag
	}
	logrus.DefaultLogger().Debugf("Microservice label is set to %v", p.MicroserviceLabel)
	return nil
}
921574
func (p *Plugin) Init() (err error) {
	// Get GRPC configuration file
	if p.Config == nil {
		p.Config, err = p.getGrpcConfig()
		if err != nil || p.disabled {
			return err
		}
	}

	// Prepare GRPC server
	if p.grpcServer == nil {
		opts := p.Config.getGrpcOptions()
		if p.tlsConfig != nil {
			opts = append(opts, grpc.Creds(credentials.NewTLS(p.tlsConfig)))
		}
		if p.auther != nil {
			p.Log.Info("Token authentication for gRPC enabled")
			opts = append(opts, grpc.StreamInterceptor(grpc_auth.StreamServerInterceptor(p.auther.Authenticate)))
			opts = append(opts, grpc.UnaryInterceptor(grpc_auth.UnaryServerInterceptor(p.auther.Authenticate)))
		}
		p.grpcServer = grpc.NewServer(opts...)

		//grpclog.SetLogger(p.Log.NewLogger("grpc-server"))
	}

	return nil
}
295933
func (plugin *ExamplePlugin) Init() (err error) {
	// handle flags
	flag.Parse()

	// sync/async offset flag
	if *offsetMsg != "" {
		messageOffset, err = resolveOffset(*offsetMsg)
		if err != nil {
			return fmt.Errorf("incorrect sync offset value %v", *offsetMsg)
		}
	} else {
		plugin.Log.Info("offset arg not set, using default value")
	}

	// message count flag
	if *messageCount != "" {
		messageCountNum, err = resolveMsgCount(*messageCount)
		if err != nil {
			return fmt.Errorf("'messageCount' has to be a number, not %v", *messageCount)
		}
		if messageCountNum < 0 {
			plugin.Log.Warnf("'messageCount' %v is not a positive number, defaulting to 0")
			messageCountNum = 0
		}
	} else {
		plugin.Log.Info("messageCount arg not set, using default value")
	}

	plugin.Log.Infof("Offset: %v, message count: %v", messageOffset, messageCountNum)

	// Create a synchronous and asynchronous publisher.
	// In the manual mode, every publisher has selected its target partition.
	plugin.kafkaSyncPublisher, err = plugin.Kafka.NewSyncPublisherToPartition(connection, topic1, syncMessagePartition)
	if err != nil {
		return err
	}

	// Async publisher requires two more channels to send success/error callback.
	plugin.asyncSuccessChannel = make(chan messaging.ProtoMessage)
	plugin.asyncErrorChannel = make(chan messaging.ProtoMessageErr)
	plugin.kafkaAsyncPublisher, err = plugin.Kafka.NewAsyncPublisherToPartition(connection, topic2, asyncMessagePartition,
		messaging.ToProtoMsgChan(plugin.asyncSuccessChannel), messaging.ToProtoMsgErrChan(plugin.asyncErrorChannel))
	if err != nil {
		return err
	}

	// Initialize sync watcher.
	plugin.kafkaWatcher = plugin.Kafka.NewPartitionWatcher(subscriber)

	// Prepare subscription channel. Relevant kafka messages are send to this
	// channel so that the watcher can read it.
	plugin.subscription = make(chan messaging.ProtoMessage)
	// The watcher is consuming messages on a custom partition and an offset.
	// If there is a producer who stores message to the same partition under
	// the same or a newer offset, the message will be consumed.
	err = plugin.kafkaWatcher.WatchPartition(messaging.ToProtoMsgChan(plugin.subscription), topic1,
		syncMessagePartition, messageOffset)
	if err != nil {
		plugin.Log.Error(err)
	}

	// Prepare subscription channel. Relevant kafka messages are send to this
	// channel so that the watcher can read it
	plugin.asyncSubscription = make(chan messaging.ProtoMessage)
	// The watcher is consuming messages on custom partition and offset.
	// If there is a producer who stores message to the same partition under
	// the same or a newer offset, the message will be consumed.
	err = plugin.kafkaWatcher.WatchPartition(messaging.ToProtoMsgChan(plugin.asyncSubscription), topic2,
		asyncMessagePartition, messageOffset)
	if err != nil {
		plugin.Log.Error(err)
	}

	plugin.Log.Info("Initialization of the custom plugin for the Kafka example is completed")

	// Run sync and async kafka consumers.
	go plugin.syncEventHandler()
	go plugin.asyncEventHandler()

	// Run the producer.
	go plugin.producer()

	// Verify results and close the example if successful.
	go plugin.closeExample()

	return err
}
725518
func (i *PluginInitializer) Initialize(plugin admission.Interface) {
	if wants, ok := plugin.(WantsCloudConfig); ok {
		wants.SetCloudConfig(i.cloudConfig)
	}

	if wants, ok := plugin.(WantsRESTMapper); ok {
		wants.SetRESTMapper(i.restMapper)
	}

	if wants, ok := plugin.(WantsQuotaConfiguration); ok {
		wants.SetQuotaConfiguration(i.quotaConfiguration)
	}
}
599770
func (c *cinderPlugin) Init(cloud cloudprovider.Interface) {
	c.cloud = cloud.(*openstack.OpenStack)
}
1092683
func (plugin *ExamplePlugin) Init() (err error) {
	plugin.Log.Info("Loading plugin config ", plugin.PluginConfig.GetConfigName())

	if plugin.Conf == nil {
		plugin.Conf = &Conf{Field1: "some default value"}
	}

	found, err := plugin.PluginConfig.LoadValue(plugin.Conf)
	if err != nil {
		plugin.Log.Error("Error loading config", err)
	} else if found {
		plugin.Log.Info("Loaded plugin config - found external configuration ", plugin.PluginConfig.GetConfigName())
	} else {
		plugin.Log.Info("Loaded plugin config - default")
	}
	plugin.Log.Info("Plugin Config ", plugin.Conf)

	time.Sleep(plugin.Conf.Sleep)
	close(plugin.exampleFinished)

	return nil
}
1028654
func (_m *Plugin) Init(dependencies ...endorsement.Dependency) error {
	_va := make([]interface{}, len(dependencies))
	for _i := range dependencies {
		_va[_i] = dependencies[_i]
	}
	var _ca []interface{}
	_ca = append(_ca, _va...)
	ret := _m.Called(_ca...)

	var r0 error
	if rf, ok := ret.Get(0).(func(...endorsement.Dependency) error); ok {
		r0 = rf(dependencies...)
	} else {
		r0 = ret.Error(0)
	}

	return r0
}
1270975
func (p *priorityPlugin) ValidateInitialization() error {
	if p.client == nil {
		return fmt.Errorf("%s requires a client", PluginName)
	}
	if p.lister == nil {
		return fmt.Errorf("%s requires a lister", PluginName)
	}
	return nil
}
798223
func InitLogger(handle io.Writer, prefix string) *log.Logger {
	return log.New(handle, strings.Join([]string{prefix, ": "}, ""), log.Ldate|log.Ltime|log.Lshortfile)
}
677366
func (r *registry) initDecoratorPlugin(p *plugin.Plugin) {
	constructorSymbol, err := p.Lookup(decoratorPluginFactory)
	if err != nil {
		panicWithLookupError(decoratorPluginFactory, err)
	}
	constructor, ok := constructorSymbol.(func() decoration.Decorator)
	if !ok {
		panicWithDefinitionError(decoratorPluginFactory)
	}
	decorator := constructor()
	if decorator != nil {
		r.decorators = append(r.decorators, constructor())
	}
}