• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Scala Logger类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Scala中grizzled.slf4j.Logger的典型用法代码示例。如果您正苦于以下问题:Scala Logger类的具体用法?Scala Logger怎么用?Scala Logger使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: PublishedStoryDAOImpl

//设置package包名称以及导入依赖的类
package io.soheila.cms.daos

import javax.inject.Inject

import grizzled.slf4j.Logger
import io.soheila.cms.daos.exceptions.DAOException
import io.soheila.cms.entities.Story
import play.api.libs.json.Json
import play.modules.reactivemongo.ReactiveMongoApi
import reactivemongo.play.json.collection.JSONCollection

import scala.concurrent.{ ExecutionContext, Future }

class PublishedStoryDAOImpl @Inject() (override val reactiveMongoApi: ReactiveMongoApi)(implicit override val ec: ExecutionContext) extends StoryDAOImpl(reactiveMongoApi) {
  private val logger = Logger[this.type]

  override def collection: Future[JSONCollection] = reactiveMongoApi.database.map(_.collection[JSONCollection]("published_stories"))

  override def findAndUpdateLatest(story: Story, upsert: Boolean): Future[Either[DAOException, Option[Story]]] = {
    findAndUpdateByCriteria(Json.obj("uuid" -> story.uuid.get), story, upsert)
      .map {
        case Left(err) => Left(DAOException(err.getMessage, err))
        case Right(res) => Right(res)
      }
  }
} 
开发者ID:esfand-r,项目名称:soheila-cm,代码行数:27,代码来源:PublishedStoryDAOImpl.scala


示例2: Of

//设置package包名称以及导入依赖的类
package org.leialearns.crystallize.util

import java.io.{FileInputStream, File}
import java.util.logging.LogManager

import grizzled.slf4j.Logger

trait LoggingConfiguration {
  val logConfigFile = "logging.properties"
  val current = new File(".", logConfigFile)
  val logConfigStream = if (current.exists()) new FileInputStream(current) else classOf[LoggingConfiguration].getResourceAsStream("/" + logConfigFile)
  val logManager: LogManager = LogManager.getLogManager
  logManager.readConfiguration(logConfigStream)

  def getLogger(category: Class[_]): Logger = {
    Logger(category)
  }
} 
开发者ID:jeroenvanmaanen,项目名称:crystallize,代码行数:19,代码来源:LoggingConfiguration.scala


示例3: DataSourceParams

//设置package包名称以及导入依赖的类
package com.lavsurgut.vizr.engine

import grizzled.slf4j.Logger
import org.apache.predictionio.controller.{EmptyActualResult, EmptyEvaluationInfo, PDataSource, Params}
import org.apache.predictionio.data.storage.Event
import org.apache.predictionio.data.store.PEventStore
import org.apache.spark.SparkContext
import org.apache.spark.rdd.RDD

case class DataSourceParams(appName: String, entityType: String) extends Params

class DataSource(val dsp: DataSourceParams)
  extends PDataSource[TrainingData,
    EmptyEvaluationInfo, Query, EmptyActualResult] {

  @transient lazy val logger = Logger[this.type]

  override
  def readTraining(sc: SparkContext): TrainingData = {

    // read all events of EVENT involving ENTITY_TYPE and TARGET_ENTITY_TYPE
    val eventsRDD: RDD[Event] = PEventStore.find(
      appName = dsp.appName,
      entityType = Some(dsp.entityType),
      eventNames = Some(List("data-upload")) // ,
      // targetEntityType = Some(Some("TARGET_ENTITY_TYPE"))
    )(sc)

    new TrainingData(eventsRDD)
  }
}

class TrainingData(
                    val events: RDD[Event]
                  ) extends Serializable {
  override def toString = {
    s"events: [${events.count()}] (${events.take(2).toList}...)"
  }
} 
开发者ID:lavsurgut,项目名称:vizr,代码行数:40,代码来源:DataSource.scala


示例4: nearPoint

//设置package包名称以及导入依赖的类
package io.soheila.commons.geospatials

import grizzled.slf4j.Logger
import io.soheila.commons.crud.MongoCRUDDAO
import io.soheila.commons.entities.{ Locatable, Page }
import io.soheila.commons.exceptions.{ ErrorCode, MongoDAOException, MongoExceptionBuilder }
import play.api.libs.json.{ Json, Reads }
import play.modules.reactivemongo.json._
import reactivemongo.api.indexes.Index
import reactivemongo.api.indexes.IndexType.Geo2DSpherical
import reactivemongo.api.{ Cursor, ReadPreference }

import scala.concurrent.{ ExecutionContext, Future }

trait Geospatial[T <: Locatable, ID] {
  self: MongoCRUDDAO[T, ID] =>

  private val logger = Logger[this.type]

  lazy val LocationField = "coordinate"

  lazy val geo2DSphericalIndex = Index(Seq((LocationField, Geo2DSpherical)), Some("geo2DSphericalIdx"))

  
  def nearPoint(lon: Double, lat: Double, minDistance: Double = 1, maxDistance: Double = 10000, page: Int = 0, limit: Int = 100, readPreference: ReadPreference = ReadPreference.primaryPreferred)(implicit ec: ExecutionContext, reads: Reads[T]): Future[Either[MongoDAOException, Page[T]]] = {
    val offset = page * limit

    val totalCount = collection.flatMap(_.count())

    val searchResult = collection.flatMap(_.find(
      Json.obj(
        LocationField -> Json.toJson(Json.obj(
          "$geoNear" -> Json.toJson(Json.obj(
            "$geometry" -> Json.toJson(Json.obj(
              "type" -> "Point",
              "coordinates" -> Json.arr(lon, lat)
            )),
            "$maxDistance" -> Json.toJson(maxDistance),
            "$minDistance" -> Json.toJson(minDistance)
          ))
        ))
      )
    ).cursor[T](readPreference).collect[Seq](limit, Cursor.FailOnError((seq: Seq[T], err) => logger.error("Error finding locations.", err))))

    totalCount.zip(searchResult).map {
      case (total, entities) =>
        Right(Page(entities, page, offset, total))
    }.recover {
      case e => Left(MongoExceptionBuilder.buildException(e))
    }
  }

} 
开发者ID:esfand-r,项目名称:play-reactivemongo-commons,代码行数:54,代码来源:Geospatial.scala


示例5: AlgorithmParams

//设置package包名称以及导入依赖的类
package org.template.classification

import org.apache.predictionio.controller.P2LAlgorithm
import org.apache.predictionio.controller.Params

import org.apache.spark.mllib.classification.NaiveBayes
import org.apache.spark.mllib.classification.NaiveBayesModel
import org.apache.spark.mllib.linalg.Vectors
import org.apache.spark.SparkContext

import grizzled.slf4j.Logger

case class AlgorithmParams(
  lambda: Double
) extends Params

// extends P2LAlgorithm because the MLlib's NaiveBayesModel doesn't contain RDD.
class NaiveBayesAlgorithm(val ap: AlgorithmParams)
  extends P2LAlgorithm[PreparedData, NaiveBayesModel, Query, PredictedResult] {

  @transient lazy val logger = Logger[this.type]

  def train(sc: SparkContext, data: PreparedData): NaiveBayesModel = {
    // MLLib NaiveBayes cannot handle empty training data.
    require(data.labeledPoints.take(1).nonEmpty,
      s"RDD[labeledPoints] in PreparedData cannot be empty." +
      " Please check if DataSource generates TrainingData" +
      " and Preparator generates PreparedData correctly.")

    NaiveBayes.train(data.labeledPoints, ap.lambda)
  }

  def predict(model: NaiveBayesModel, query: Query): PredictedResult = {
    val features = SyntheticFeatures.transform(
      Vectors.dense(
        Array(query.voice_usage, query.data_usage, query.text_usage)
      )
    )
    val label = model.predict(features)
    new PredictedResult(label)
  }

} 
开发者ID:wmfongsf,项目名称:predictionio-engine-classification,代码行数:44,代码来源:NaiveBayesAlgorithm.scala


示例6: RandomForestAlgorithmParams

//设置package包名称以及导入依赖的类
package org.template.classification

import org.apache.predictionio.controller.P2LAlgorithm
import org.apache.predictionio.controller.Params

import org.apache.spark.mllib.tree.RandomForest
import org.apache.spark.mllib.tree.model.RandomForestModel
import org.apache.spark.mllib.linalg.Vectors
import org.apache.spark.SparkContext

import grizzled.slf4j.Logger

case class RandomForestAlgorithmParams(
  numClasses: Int,
  numTrees: Int,
  featureSubsetStrategy: String,
  impurity: String,
  maxDepth: Int,
  maxBins: Int
) extends Params

// extends P2LAlgorithm because the MLlib's RandomForestAlgorithm doesn't contain RDD.
class RandomForestAlgorithm(val ap: RandomForestAlgorithmParams)
  extends P2LAlgorithm[PreparedData, RandomForestModel, Query, PredictedResult] {

  @transient lazy val logger = Logger[this.type]

  def train(sc: SparkContext, data: PreparedData): RandomForestModel = {// Empty categoricalFeaturesInfo indicates all features are continuous.
    val categoricalFeaturesInfo = Map[Int, Int]()
    RandomForest.trainClassifier(
      data.labeledPoints,
      ap.numClasses,
      categoricalFeaturesInfo,
      ap.numTrees,
      ap.featureSubsetStrategy,
      ap.impurity,
      ap.maxDepth,
      ap.maxBins)
  }

  def predict(model: RandomForestModel, query: Query): PredictedResult = {
    val features = Vectors.dense(
      Array(query.voice_usage, query.data_usage, query.text_usage)
    )
    val label = model.predict(features)
    new PredictedResult(label)
  }

} 
开发者ID:wmfongsf,项目名称:predictionio-engine-classification,代码行数:50,代码来源:RandomForestAlgorithm.scala


示例7: PredictedResult

//设置package包名称以及导入依赖的类
package org.template

import grizzled.slf4j.Logger
import org.apache.predictionio.controller.{ EmptyActualResult, EmptyEvaluationInfo, Engine, EngineFactory }
import org.template.conversions._


case class PredictedResult(
  itemScores: Array[ItemScore])
    extends Serializable

case class ItemScore(
  item: ItemID, // item id
  score: Double, // used to rank, original score returned from teh search engine
  ranks: Option[Map[String, Double]] = None) extends Serializable

object RecommendationEngine extends EngineFactory {

  @transient lazy implicit val logger: Logger = Logger[this.type]
  drawActionML

  def apply(): Engine[TrainingData, EmptyEvaluationInfo, PreparedData, Query, PredictedResult, EmptyActualResult] = {
    new Engine(
      classOf[DataSource],
      classOf[Preparator],
      Map("ur" -> classOf[URAlgorithm]), // IMPORTANT: "ur" must be the "name" of the parameter set in engine.json
      classOf[Serving])
  }
} 
开发者ID:izzac,项目名称:predictIO,代码行数:30,代码来源:Engine.scala


示例8: sendMail

//设置package包名称以及导入依赖的类
package wuxi99
import javax.mail.Message
import javax.mail.Session
import javax.mail.Transport
import javax.mail.internet.InternetAddress
import javax.mail.internet.MimeMessage
import java.util.Date
import java.util.Properties
import grizzled.slf4j.Logger
trait Email {
	def sendMail(mailTitle:String,mailContent:String)
	def sendMailFL(mailTitle:String,fileName:String,line:Int,AppCount:Int){
		val mailContent = s"""<b>??:${fileName}</b><br>
			<b>??:${line}</b><br>
			<b>???:${AppCount}</b>"""
		sendMail(mailTitle,mailContent)
	}
 def sendMailHtml(mailTitle:String,mailContent:String){
    val mailContentHtml = s"<b>${mailContent}</b>"
    sendMail(mailTitle,mailContentHtml)
  }
}

object MailUtility extends Email {
	private val smtpServer = "smtp.exmail.qq.com"
	private val fromMail = "[email protected]"
	private val toMail = "[email protected]"
	private val user = fromMail
	private val password = "ys123456"
	@transient lazy val logger = Logger[this.type]


	def sendMail(mailTitle:String,mailContent:String) {
	  try {	
		val props = new Properties()
		props.put("mail.smtp.host",smtpServer )
		props.put("mail.smtp.auth", "true")
		val session = Session.getInstance(props)

		val message = new MimeMessage(session)
		message.setFrom(new InternetAddress(fromMail))
		message.setRecipient(Message.RecipientType.TO, new InternetAddress(toMail))
		message.setSubject(mailTitle)
		message.setContent(mailContent, "text/html;charset=utf-8")
		//message.setText(mailContent)
		message.setSentDate(new Date())
		message.saveChanges()

		val transport = session.getTransport("smtp")
		transport.connect(user, password)
		transport.sendMessage(message, message.getAllRecipients())
		transport.close()
	  } catch {
		case _ : Throwable => logger.info("This Mail Didnot Send:[ " + mailTitle + " ] [ " + mailContent + "]" )
          }	
	}

} 
开发者ID:yangshuxuan,项目名称:OptFoatSalesWithSparkAndScala,代码行数:59,代码来源:mailUtility.scala



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Scala Topic类代码示例发布时间:2022-05-23
下一篇:
Scala ArrayBuffer类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap