当前位置: 首页>>代码示例>>Golang>>正文


Golang Writer.Notice方法代码示例

本文整理汇总了Golang中log/syslog.Writer.Notice方法的典型用法代码示例。如果您正苦于以下问题:Golang Writer.Notice方法的具体用法?Golang Writer.Notice怎么用?Golang Writer.Notice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在log/syslog.Writer的用法示例。


在下文中一共展示了Writer.Notice方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: dequeue

func dequeue(syslogLog *syslog.Writer, mongoHref string, mongoDatabaseName string, mongoCollectionName string, amqpHref string, amqpExchange string, amqpExchangeType string) {

	//DEBUG
	syslogLog.Notice("[dequeue] BEGIN")
	syslogLog.Notice(fmt.Sprintf("    [dequeue]           mongoHref = [%v]", mongoHref))
	syslogLog.Notice(fmt.Sprintf("    [dequeue]   mongoDatabaseName = [%v]", mongoDatabaseName))
	syslogLog.Notice(fmt.Sprintf("    [dequeue] mongoCollectionName = [%v]", mongoCollectionName))
	syslogLog.Notice(fmt.Sprintf("    [dequeue]            amqpHref = [%v]", amqpHref))
	syslogLog.Notice(fmt.Sprintf("    [dequeue]        amqpExchange = [%v]", amqpExchange))
	syslogLog.Notice(fmt.Sprintf("    [dequeue]    amqpExchangeType = [%v]", amqpExchangeType))

	// Deal with parameters.
	if "" == mongoHref {
		errMsg := fmt.Sprintf("    [dequeue] Bad mongoHref. Received: [%v].", mongoHref)
		syslogLog.Err(errMsg)
		panic(errMsg)
		/////////////////////// RETURN
		return
	}

	if "" == mongoDatabaseName {
		errMsg := fmt.Sprintf("    [dequeue] Bad mongoDatabaseName. Received: [%v].", mongoDatabaseName)
		syslogLog.Err(errMsg)
		panic(errMsg)
		/////////////////////// RETURN
		return
	}

	if "" == mongoCollectionName {
		errMsg := fmt.Sprintf("    [dequeue] Bad mongoCollectionName. Received: [%v].", mongoCollectionName)
		syslogLog.Err(errMsg)
		panic(errMsg)
		/////////////////////// RETURN
		return
	}

	if "" == amqpHref {
		errMsg := fmt.Sprintf("    [dequeue] Bad amqpHref. Received: [%v].", amqpHref)
		syslogLog.Err(errMsg)
		panic(errMsg)
		/////////////////////// RETURN
		return
	}

	// Connect to MongoDB
	mongoSession, err := mgo.Dial(mongoHref)
	if err != nil {
		syslogLog.Err(fmt.Sprintf("    [dequeue] Could NOT connect to MongoDB at [%v], received err = [%v]", mongoHref, err))
		panic(err)
		/////////////////////// RETURN
		return
	}
	defer mongoSession.Close()

	// Optional. Switch the session to a monotonic behavior.
	mongoSession.SetMode(mgo.Monotonic, true)

	mongoCollection := mongoSession.DB(mongoDatabaseName).C(mongoCollectionName)

	//DEBUG
	syslogLog.Notice(fmt.Sprintf("    [dequeue] Connected to MongoDB with %v.%v", mongoDatabaseName, mongoCollectionName))

	// Connect to AMQP.
	amqpConnection, err := amqp.Dial(amqpHref)
	if err != nil {
		syslogLog.Err(fmt.Sprintf("    [dequeue] Could NOT connect to AMQP server (RabbitMQ?) at [%v], received err = [%v]", amqpHref, err))
		panic(err)
		/////////////////////// RETURN
		return
	}
	defer amqpConnection.Close()

	amqpChannel, err := amqpConnection.Channel()
	if err != nil {
		syslogLog.Err("    [dequeue] Could NOT get AMQP channel")
		panic(err)
		/////////////////////// RETURN
		return
	}

	//DEBUG
	syslogLog.Notice(fmt.Sprintf("    [dequeue] amqpChannel = [%v]", amqpChannel))

	//DEBUG
	syslogLog.Notice(fmt.Sprintf("    [dequeue] Connected to AMQP server (RabbitMQ?)", mongoDatabaseName, mongoCollectionName))

	// Forever
	for {

		//DEBUG
		syslogLog.Notice("    [dequeue] =-<>-=-<>-=-<>-=-<>-=-<>-=-<>-=-<>-=-<>-=-<>-=-<>-= LOOP")

		// Check MongoDB for items that are ready.
		mongoCriteria := bson.M{"when": bson.M{"$lte": bson.Now()}}

		mongoQuery := mongoCollection.Find(mongoCriteria)

		//DEBUG
		syslogLog.Notice(fmt.Sprintf("    [dequeue] mongoQuery = [%v]", mongoQuery))

//.........这里部分代码省略.........
开发者ID:reiver,项目名称:turtledq,代码行数:101,代码来源:dequeue.go

示例2: enqueue

func enqueue(syslogLog *syslog.Writer, mongoHref string, mongoDatabaseName string, mongoCollectionName string, amqpHref string, amqpExchange string, amqpExchangeType string, amqpQueue string) {

	//DEBUG
	syslogLog.Notice("[enqueue] BEGIN")
	syslogLog.Notice(fmt.Sprintf("    [enqueue]           mongoHref = [%v]", mongoHref))
	syslogLog.Notice(fmt.Sprintf("    [enqueue]   mongoDatabaseName = [%v]", mongoDatabaseName))
	syslogLog.Notice(fmt.Sprintf("    [enqueue] mongoCollectionName = [%v]", mongoCollectionName))
	syslogLog.Notice(fmt.Sprintf("    [enqueue]            amqpHref = [%v]", amqpHref))
	syslogLog.Notice(fmt.Sprintf("    [enqueue]        amqpExchange = [%v]", amqpExchange))
	syslogLog.Notice(fmt.Sprintf("    [enqueue]    amqpExchangeType = [%v]", amqpExchangeType))
	syslogLog.Notice(fmt.Sprintf("    [enqueue]           amqpQueue = [%v]", amqpQueue))

	// Deal with parameters.
	if "" == mongoHref {
		errMsg := fmt.Sprintf("    [enqueue] Bad mongoHref. Received: [%v].", mongoHref)
		syslogLog.Err(errMsg)
		panic(errMsg)
		/////////////////////// RETURN
		return
	}

	if "" == mongoDatabaseName {
		errMsg := fmt.Sprintf("    [enqueue] Bad mongoHref. Received: [%v].", mongoDatabaseName)
		syslogLog.Err(errMsg)
		panic(errMsg)
		/////////////////////// RETURN
		return
	}

	if "" == mongoCollectionName {
		errMsg := fmt.Sprintf("    [enqueue] Bad mongoHref. Received: [%v].", mongoCollectionName)
		syslogLog.Err(errMsg)
		panic(errMsg)
		/////////////////////// RETURN
		return
	}

	if "" == amqpHref {
		errMsg := fmt.Sprintf("    [enqueue] Bad amqpHref. Received: [%v].", amqpHref)
		syslogLog.Err(errMsg)
		panic(errMsg)
		/////////////////////// RETURN
		return
	}

	if "" == amqpExchange {
		errMsg := fmt.Sprintf("    [enqueue] Bad amqpExchange. Received: [%v].", amqpExchange)
		syslogLog.Err(errMsg)
		panic(errMsg)
		/////////////////////// RETURN
		return
	}

	if "" == amqpExchangeType {
		errMsg := fmt.Sprintf("    [enqueue] Bad amqpExchangeType. Received: [%v].", amqpExchangeType)
		syslogLog.Err(errMsg)
		panic(errMsg)
		/////////////////////// RETURN
		return
	}

	if "" == amqpQueue {
		errMsg := fmt.Sprintf("    [enqueue] Bad amqpQueue. Received: [%v].", amqpQueue)
		syslogLog.Err(errMsg)
		panic(errMsg)
		/////////////////////// RETURN
		return
	}

	// Connect to AMQP.
	amqpConnection, err := amqp.Dial(amqpHref)
	if err != nil {
		syslogLog.Err(fmt.Sprintf("    [enqueue] Could NOT connect to AMQP server (RabbitMQ?) at [%v], received err = [%v]", amqpHref, err))
		panic(err)
		/////////////////////// RETURN
		return
	}
	defer amqpConnection.Close()

	amqpChannel, err := amqpConnection.Channel()
	if err != nil {
		syslogLog.Err("    [enqueue] Could NOT get AMQP channel")
		panic(err)
		/////////////////////// RETURN
		return
	}

	//DEBUG
	syslogLog.Notice(fmt.Sprintf("    [enqueue] amqpChannel = [%v]", amqpChannel))

	// Connect to MongoDB
	mongoSession, err := mgo.Dial(mongoHref)
	if err != nil {
		syslogLog.Err(fmt.Sprintf("    [enqueue] Could NOT connect to MongoDB at [%v], received err = [%v]", mongoHref, err))
		panic(err)
		/////////////////////// RETURN
		return
	}
	defer mongoSession.Close()

//.........这里部分代码省略.........
开发者ID:reiver,项目名称:turtledq,代码行数:101,代码来源:enqueue.go

示例3: NewTurtleConfig

func NewTurtleConfig(syslogLog *syslog.Writer) (*TurtleConfig, error) {

	//DEBUG
	syslogLog.Notice("    [CONFIG] BEGIN.")

	cmdPath := os.Args[0]
	cmdPathLastSlash := strings.LastIndexFunc(cmdPath, func(c rune) bool {
		return '/' == c
	})

	cmdDirPath := cmdPath[0:cmdPathLastSlash]

	//DEBUG
	syslogLog.Notice(fmt.Sprintf("    [CONFIG] command path: [%v]", cmdPath))
	syslogLog.Notice(fmt.Sprintf("    [CONFIG] command path last slash: [%v]", cmdPathLastSlash))
	syslogLog.Notice(fmt.Sprintf("    [CONFIG] command dir path: [%v]", cmdDirPath))

	confRelativePath := "turtledq.ini"
	confPath := cmdDirPath + "/" + confRelativePath

	//DEBUG
	syslogLog.Notice(fmt.Sprintf("    [CONFIG] settings file relative path: [%v]", confRelativePath))
	syslogLog.Notice(fmt.Sprintf("    [CONFIG] settings file absolute path: [%v]", confPath))

	return NewTurtleConfigFromFile(syslogLog, confPath)
}
开发者ID:reiver,项目名称:turtledq,代码行数:26,代码来源:config.go


注:本文中的log/syslog.Writer.Notice方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。