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


Scala LazyLogging类代码示例

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


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

示例1: StorageLocation

//设置package包名称以及导入依赖的类
package hu.blackbelt.cd.bintray.deploy

import java.io.InputStream
import java.nio.file.Path

import com.typesafe.scalalogging.LazyLogging

case class StorageLocation(bucket: String, key: String) {
  override def toString = s"s3://$bucket/$key"
}

case class Project(location: StorageLocation, name: String, version: String)

class Deploy(project: Project) extends LazyLogging {

  logger.info("collecting access properties")
  Access.collect
  logger.info("access info in possession")


  def fetch = S3Get.get(project.location.bucket, project.location.key) _

  private def selectArt(art: Art)(selector: Art => Path) = {
    val subject = selector(art)
    val key = s"${art.groupId.replace('.', '/')}/${art.artifactId}/${art.version}/${subject.getFileName}"
    (key, subject)
  }

  def upload(archive: InputStream, batchSize: Int = 30) = {
    val artifacts = TarGzExtract.getArtifacts(archive)
    val batches = artifacts.sliding(batchSize, batchSize).map(arts => {
      val mapped = arts.flatMap { art =>
        val select = selectArt(art) _
        List(select(_.artifact), select(_.pomFile))
      }
      Batch(mapped)
    }

    ).toList

    val b = new Btray
    val ver = b.version("releases", project.name, project.version)

    ver.map(
      b.uploadTo(_, batches)
    )
  }
} 
开发者ID:tsechov,项目名称:s3-bintray-deploy,代码行数:49,代码来源:Deploy.scala

示例2: Flows

//设置package包名称以及导入依赖的类
package com.stulsoft.akka.stream

import akka.NotUsed
import akka.stream.OverflowStrategy
import akka.stream.scaladsl.{Flow, Sink, Source}
import com.typesafe.scalalogging.LazyLogging


object Flows extends App with LazyLogging {
  logger.info("start")

  // Explicitly creating and wiring up a Source, Sink and Flow
  Source(1 to 6).via(Flow[Int].map(_ * 2)).to(Sink.foreach(println(_)))

  // Starting from a Source
  val source = Source(1 to 6).map(_ * 2)
  source.to(Sink.foreach(println(_)))

  // Starting from a Sink
  val sink: Sink[Int, NotUsed] = Flow[Int].map(_ * 2).to(Sink.foreach(println(_)))
  Source(1 to 6).to(sink)

  // Broadcast to a sink inline
  val otherSink: Sink[Int, NotUsed] =
  Flow[Int].alsoTo(Sink.foreach(println(_))).to(Sink.ignore)
  Source(1 to 6).to(otherSink)

  val flowDoublingElements = Flow[Int].map(_ * 2)
  val flowFilteringOutOddElements = Flow[Int].filter(_ % 2 == 0)
  val flowBatchingElements = Flow[Int].grouped(10)
  val flowBufferingElements = Flow[String].buffer(1000, OverflowStrategy.backpressure) // back-pressures the source if the buffer is full
  logger.info("end")
} 
开发者ID:ysden123,项目名称:poc,代码行数:34,代码来源:Flows.scala

示例3: Consumer

//设置package包名称以及导入依赖的类
package com.softwaremill.modemconnector

import java.util.concurrent.BlockingQueue

import com.typesafe.scalalogging.LazyLogging

abstract class Consumer[T](queue: BlockingQueue[T]) extends Runnable with LazyLogging {

  override def run(): Unit = {
    logger.info("Starting Consumer....")
    try {
      while (!Thread.currentThread.isInterrupted) {
        val sample = queue.take()
        consume(sample)
      }
    } catch {
      case ie: InterruptedException => logger.info("Consumer stopped with interrupt")
    }
  }

  def consume(sample: T): Unit

} 
开发者ID:softwaremill,项目名称:modem-connector,代码行数:24,代码来源:Consumer.scala

示例4: DatabaseInitializer

//设置package包名称以及导入依赖的类
package essentials.petstore.database

import slick.basic.DatabaseConfig
import slick.jdbc.meta.MTable
import slick.jdbc.JdbcProfile
import com.typesafe.scalalogging.LazyLogging

import scala.concurrent.duration._
import scala.concurrent.Await


class DatabaseInitializer(val dbConfig: DatabaseConfig[JdbcProfile], petsRepo: PetsRepository, recordsRepo: PetRecordsRepository) extends Db with LazyLogging {
  import dbConfig.profile.api._

  def initDatabaseTables(): Unit = {
    logger.info("Setting up database")
    // Get all existing tables
    val tables = Await.result(db.run(MTable.getTables), 10 seconds)

    val petsTableName = petsRepo.pets.baseTableRow.tableName
    if (!tables.exists(existingTable => existingTable.name.name == petsTableName)) {
      logger.info(s"Creating table '$petsTableName'")
      Await.result(db.run(petsRepo.pets.schema.create), 10 seconds)
    } else {
      logger.info(s"Table '$petsTableName' already exists")
    }

    val recordsTableName = recordsRepo.records.baseTableRow.tableName
    if (!tables.exists(existingTable => existingTable.name.name == recordsTableName)) {
      logger.info(s"Creating table '$recordsTableName'")
      Await.result(db.run(recordsRepo.records.schema.create), 10 seconds)
    } else {
      logger.info(s"Table '$recordsTableName' already exists")
    }

    logger.info("Finished setting up database")
  }
} 
开发者ID:littlenag,项目名称:scala-essentials-petstore,代码行数:39,代码来源:DatabaseInitializer.scala

示例5: write

//设置package包名称以及导入依赖的类
package com.jetprobe.fastgen.io

import com.typesafe.scalalogging.LazyLogging


trait DataSink extends LazyLogging {
  def write(data: Array[String]): Unit
}

object DataSinkBuilder {
  def apply(out: String): DataSink = out match {
    case uri if uri.startsWith("rabbit")  => RabbitMQSink(uri)
    case uri if uri.startsWith("file")    => FileSink(uri)
    case uri if uri.startsWith("mongodb") => MongoDBSink(uri)
  }
} 
开发者ID:amezng,项目名称:fastgen,代码行数:17,代码来源:DataSink.scala

示例6: RobotsTxtLookUp

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

import java.net.URI

import akka.actor.{ActorRef, ActorSystem, Cancellable}
import bridgeapp.crawler.execution._
import com.typesafe.scalalogging.LazyLogging

import scala.concurrent.duration._
import scala.util.control.NonFatal


class RobotsTxtLookUp(throttling: ActorRef) extends Runnable with LazyLogging {
  override def run(): Unit = {
    logger.warn(s" Lookup robots.txt")
    val uri = new URI("https://rutracker.org/robots.txt")

    val parser = new ResponseParser {
      override def ->(response: Response): Unit = {
        val body = new String(response.body)
        Robots.parse(body) match {
          case Left(error) =>
            logger.error(s"Error parse robots txt file, $error ")
          case Right(robots) =>
            robots.nonGroupFields.map(s => (s.key, s.value)).toMap[String, String].get("Crawl-delay").fold() { delay =>
              try {
                val rate = Rate(1, delay.toFloat.second)
                throttling ! SetRate(rate)
              } catch {
                case NonFatal(e) => logger.error("Error parse crawl delay directive in robots.txt. ", e)
              }
            }
        }
      }
    }
    val request = Request(uri, parser)

    //throttling !! request
  }
}

class RobotsTXTScheduleExecutor(robotsTxtLookUp: RobotsTxtLookUp)(implicit val actorSystem: ActorSystem) {

  private implicit val prep = actorSystem.dispatcher.prepare()

  private var instance: Cancellable = _

  def execute(duration: FiniteDuration) = {
    instance = actorSystem.scheduler.schedule(duration, duration, robotsTxtLookUp)
  }

  def cancel(): Unit = {
    instance.cancel()
  }
} 
开发者ID:bridge-app,项目名称:crawler,代码行数:56,代码来源:RobotsTxtLookUp.scala

示例7: MainPageResponseParser

//设置package包名称以及导入依赖的类
package bridgeapp.crawler.parsers

import java.net.URL

import akka.actor.{Props, ActorSystem, Actor, ActorRef}
import bridgeapp.crawler.Config
import bridgeapp.crawler.execution.{Response, ResponseParser}
import bridgeapp.crawler.storage.{DiskForumsStorage, ForumsStorage}
import com.typesafe.scalalogging.LazyLogging
import org.jsoup.Jsoup

import scala.collection.JavaConverters._


class MainPageResponseParser(parser: ActorRef) extends ResponseParser {
  override def ->(response: Response): Unit = parser ! response
}

object MainPageResponseParser {

  def apply()(implicit actorSystem: ActorSystem): MainPageResponseParser = {
    val parser = actorSystem.actorOf(Props(new MainPageParser(ForumsStorage())))
    new MainPageResponseParser(parser)
  }
}

class MainPageParser(forumsListStorage: ForumsStorage) extends Actor with LazyLogging {
  override def receive: Receive = {
    case response: Response =>

      val charset = response.charset.getOrElse("utf-8")
      val body = new String(response.body, charset)
      val document = Jsoup.parse(body, response.uri.toString)

      val forumLink = document.select("[href^=viewforum.php]").asScala.toArray

      logger.trace(s" Total url: ${forumLink.length}")

      val forumsIds: Array[Int] = forumLink.map(_.attr("abs:href")).collect {
        case href: String =>
          val s = new URL(href).getQuery.split("&").map { part =>
            val pair = part.split("=")
            pair(0) -> pair(1)
          }.toMap
          s.getOrElse("f", "0").toInt
      }

      logger.trace(s" Extracted forums ids: ${forumsIds.length}")

      forumsListStorage.write(forumsIds, Config.forumsStorageURI)(context.dispatcher)

  }
} 
开发者ID:bridge-app,项目名称:crawler,代码行数:54,代码来源:MainPageParser.scala

示例8: SupervisorActor

//设置package包名称以及导入依赖的类
package my.samples.core

import akka.actor.{ Actor, Props }
import com.typesafe.scalalogging.LazyLogging
import monix.execution.Scheduler
import monix.execution.cancelables.CompositeCancelable
import monix.reactive.observables.ConnectableObservable
import my.samples.observables.{ MyConnectableObservable, MyObservable }
import my.samples.observers.MyObserver
import my.samples.models.MyMessages.{ Destroy, Init, Tick }
import my.samples.services.ZombieConnectorService

class SupervisorActor(globalChannel: GlobalOutputChannel)(implicit s: Scheduler) extends Actor with LazyLogging {

  private[this] val subscriptions = CompositeCancelable()

  override def preStart = {
    logger.info(s"starting Supervisor Actor [$self]")
    self ! Init
  }

  override def postStop = {
    subscriptions.cancel()
    logger.info(s"cancelling all subscriptions :: isCancelled ${subscriptions.isCanceled}")
  }

  private def init(): Seq[ConnectableObservable[Long]] = {
    // 1. our Observables
    val myObservable = MyObservable.apply
    val myConnectableObservable = MyConnectableObservable.apply(ZombieConnectorService.apply)

    // 2. our Subscribers (Observers with a Scheduler)
    val mySubscriber = MyObserver.apply(self, "hot-subscriber")
    val myConnectableSubscriber = MyObserver.apply(self, "cold-subscriber")

    // 3. marry the Observers and the Observables
    subscriptions += myObservable.unsafeSubscribeFn(mySubscriber)
    subscriptions += myConnectableObservable.unsafeSubscribeFn(myConnectableSubscriber)

    // 4. return a reference to all the connectables
    Seq(myConnectableObservable)
  }

  override def receive: Receive = {
    case Init =>
      init().foreach(elem => subscriptions += elem.connect())
    case tick: Tick =>
      // TODO: is this a good practice? exposing the internals of the GlobalChannel ???
      globalChannel.publishChannel.onNext(tick)
    case Destroy =>
      subscriptions.cancel()
  }
}
object SupervisorActor {
  implicit val s = monix.execution.Scheduler.Implicits.global
  def props(globalChannel: GlobalOutputChannel) = Props(new SupervisorActor(globalChannel))
} 
开发者ID:joesan,项目名称:monix-samples,代码行数:58,代码来源:SupervisorActor.scala

示例9: MyConnectableObservable

//设置package包名称以及导入依赖的类
package my.samples.observables

import com.typesafe.scalalogging.LazyLogging
import monix.execution.{ Cancelable, Scheduler }
import monix.execution.cancelables.{ BooleanCancelable, SingleAssignmentCancelable }
import monix.reactive.Observable
import monix.reactive.observables.ConnectableObservable
import monix.reactive.observers.Subscriber
import my.samples.services.ZombieConnectorService

import scala.concurrent.duration._

class MyConnectableObservable(service: ZombieConnectorService)(implicit s: Scheduler) extends ConnectableObservable[Long] with LazyLogging {

  private[this] val connection = SingleAssignmentCancelable()
  private val serviceName = service.getClass.getName

  override def connect(): Cancelable = {
    logger.info(s"connecting to the service $serviceName")

    // 1. we connect to the service first
    service.connect()

    // 2. we register a callback that says what to do when we disconnect
    connection := BooleanCancelable { () =>
      service.disconnect()
    }

    connection
  }

  def close() = {
    logger.info(s"shutting down connection to service $serviceName")
    connection.cancel()
  }

  override def unsafeSubscribeFn(subscriber: Subscriber[Long]): Cancelable =
    Observable.interval(1.second).subscribe(subscriber)
}
object MyConnectableObservable {
  def apply(service: ZombieConnectorService)(implicit s: Scheduler) =
    new MyConnectableObservable(service)
} 
开发者ID:joesan,项目名称:monix-samples,代码行数:44,代码来源:MyConnectableObservable.scala

示例10: ZombieConnectorService

//设置package包名称以及导入依赖的类
package my.samples.services

import com.typesafe.scalalogging.LazyLogging
import monix.execution.atomic.AtomicBoolean

final class ZombieConnectorService extends LazyLogging {

  private[this] val connectionStatus = AtomicBoolean(false)

  def connect() =
    logger.info(s"ZombieConnectorService connection status = ${connectionStatus.get}")
  connectionStatus.compareAndSet(expect = false, update = true)

  def disconnect() =
    logger.info(s"ZombieConnectorService connection status = ${connectionStatus.get}")
  connectionStatus.compareAndSet(expect = true, update = false)
}
object ZombieConnectorService {
  def apply = new ZombieConnectorService
} 
开发者ID:joesan,项目名称:monix-samples,代码行数:21,代码来源:ZombieConnectorService.scala

示例11: __CLASSNAME__

//设置package包名称以及导入依赖的类
package __PACKAGE_NAME__

import com.atomist.rug.spi.{AnnotatedRugFunction, FunctionResponse, JsonBodyOption, StringBodyOption}
import com.atomist.rug.spi.Handlers.{Response, Status}
import com.atomist.rug.spi.annotation.{Parameter, RugFunction, Secret, Tag}
import com.atomist.rug.runtime.RugSupport
import com.typesafe.scalalogging.LazyLogging

class __CLASSNAME__
  extends AnnotatedRugFunction
    with RugSupport
    with LazyLogging{

  @RugFunction(name = "__CLASSNAME__", description = "Fancy new rug function",
    tags = Array(new Tag(name = "fancy"), new Tag(name = "rug")))
  def invoke(@Parameter(name = "somenum") number: Int,
             @Parameter(name = "somestr") repo: String,
             @Secret(name = "super_secret", path = "user/system/token?scope=theworld") token: String): FunctionResponse = {

    try {
      FunctionResponse(Status.Success, Option("Successfully ran function.."), None, JsonBodyOption(None))
    }
    catch {
      case e: Exception => FunctionResponse(Status.Failure, Some("Error running function..."), None, StringBodyOption(e.getMessage))
    }
  }
} 
开发者ID:atomist,项目名称:rug-functions-github,代码行数:28,代码来源:RugFunction.scala

示例12: CreateTagFunction

//设置package包名称以及导入依赖的类
package com.atomist.rug.function.github

import java.time.OffsetDateTime

import com.atomist.rug.spi.Handlers.Status
import com.atomist.rug.spi._
import com.atomist.rug.spi.annotation.{Parameter, RugFunction, Secret, Tag}
import com.atomist.source.git.GitHubServices
import com.atomist.source.git.domain.{CreateTagRequest, Tagger}
import com.typesafe.scalalogging.LazyLogging

import scala.util.{Failure, Success, Try}


class CreateTagFunction
  extends AnnotatedRugFunction
    with LazyLogging
    with GitHubFunction {

  @RugFunction(name = "create-github-tag", description = "Creates a new tag on a commit",
    tags = Array(new Tag(name = "github"), new Tag(name = "issues")))
  def invoke(@Parameter(name = "tag") tag: String,
             @Parameter(name = "sha") sha: String,
             @Parameter(name = "message") message: String,
             @Parameter(name = "repo") repo: String,
             @Parameter(name = "owner") owner: String,
             @Parameter(name = "apiUrl") apiUrl: String,
             @Secret(name = "user_token", path = "github://user_token?scopes=repo") token: String): FunctionResponse = {

    logger.warn(s"Invoking createTag with tag '$tag', message '$message', sha '$sha', owner '$owner', repo '$repo', apiUrl '$apiUrl' and token '${safeToken(token)}'")

    val ghs = GitHubServices(token, apiUrl)
    Try {
      val ctr = CreateTagRequest(tag, message, sha, "commit", Tagger("Atomist Bot", "[email protected]", OffsetDateTime.now()))
      ghs.createTag(repo, owner, ctr)
    } match {
      case Success(newTag) =>
        Try(ghs.createReference(repo, owner, s"refs/tags/${newTag.tag}", newTag.sha))
        match {
          case Success(response) => FunctionResponse(Status.Success, Option(s"Successfully created annotated tag `$tag` in `$owner/$repo`"), None, JsonBodyOption(response))
          case Failure(e) =>
            val msg = s"Failed to create tag ref `$tag` on `$sha` in '$apiUrl' for `$owner/$repo`"
            logger.error(msg, e)
            FunctionResponse(Status.Failure, Some(msg), None, StringBodyOption(e.getMessage))
        }
      case Failure(e) =>
        val msg = s"Failed to create tag object `$tag` on `$sha` in '$apiUrl' for `$owner/$repo`"
        logger.error(msg, e)
        FunctionResponse(Status.Failure, Some(msg), None, StringBodyOption(e.getMessage))
    }
  }
} 
开发者ID:atomist,项目名称:rug-functions-github,代码行数:53,代码来源:CreateTagFunction.scala

示例13: CommentIssueFunction

//设置package包名称以及导入依赖的类
package com.atomist.rug.function.github.issue

import com.atomist.rug.function.github.GitHubFunction
import com.atomist.rug.spi.Handlers.Status
import com.atomist.rug.spi.annotation.{Parameter, RugFunction, Secret, Tag}
import com.atomist.rug.spi.{AnnotatedRugFunction, FunctionResponse, JsonBodyOption, StringBodyOption}
import com.atomist.source.git.GitHubServices
import com.typesafe.scalalogging.LazyLogging


class CommentIssueFunction
  extends AnnotatedRugFunction
    with LazyLogging
    with GitHubFunction {

  @RugFunction(name = "comment-github-issue", description = "Adds a new comment to an issue",
    tags = Array(new Tag(name = "github"), new Tag(name = "issues")))
  def invoke(@Parameter(name = "issue") number: Int,
             @Parameter(name = "comment") comment: String,
             @Parameter(name = "repo") repo: String,
             @Parameter(name = "owner") owner: String,
             @Parameter(name = "apiUrl") apiUrl: String,
             @Secret(name = "user_token", path = "github://user_token?scopes=repo") token: String): FunctionResponse = {

    logger.info(s"Invoking commentIssue with number '$number', comment '$comment', owner '$owner', repo '$repo' and token '${safeToken(token)}'")

    try {
      val ghs = GitHubServices(token, apiUrl)
      val response = ghs.createIssueComment(repo, owner, number, comment)
      FunctionResponse(Status.Success, Some(s"Successfully added comment to issue `#$number` in `$owner/$repo`"), None, JsonBodyOption(response))
    } catch {
      case e: Exception =>
        val msg = s"Failed to add comment to issue `#$number` in `$owner/$repo`"
        logger.warn(msg, e)
        FunctionResponse(Status.Failure, Some(msg), None, StringBodyOption(e.getMessage))
    }
  }
} 
开发者ID:atomist,项目名称:rug-functions-github,代码行数:39,代码来源:CommentIssueFunction.scala

示例14: AddLabelIssueFunction

//设置package包名称以及导入依赖的类
package com.atomist.rug.function.github.issue

import com.atomist.rug.function.github.GitHubFunction
import com.atomist.rug.spi.Handlers.Status
import com.atomist.rug.spi.annotation.{Parameter, RugFunction, Secret, Tag}
import com.atomist.rug.spi.{AnnotatedRugFunction, FunctionResponse, JsonBodyOption, StringBodyOption}
import com.atomist.source.git.GitHubServices
import com.typesafe.scalalogging.LazyLogging


class AddLabelIssueFunction extends AnnotatedRugFunction
  with LazyLogging
  with GitHubFunction {

  @RugFunction(name = "add-label-github-issue", description = "Adds a label to an already existing issue",
    tags = Array(new Tag(name = "github"), new Tag(name = "issues")))
  def invoke(@Parameter(name = "issue") number: Int,
             @Parameter(name = "repo") repo: String,
             @Parameter(name = "owner") owner: String,
             @Parameter(name = "label") label: String,
             @Parameter(name = "apiUrl") apiUrl: String,
             @Secret(name = "user_token", path = "github://user_token?scopes=repo") token: String): FunctionResponse = {

    logger.info(s"Invoking addLabelIssue with number '$number', label '$label', owner '$owner', repo '$repo' and token '${safeToken(token)}'")

    try {
      val ghs = GitHubServices(token, apiUrl)
      val issue = ghs.getIssue(repo, owner, number).get
      val labels = issue.labels.map(_.name) :+ label
      val response = ghs.editIssue(repo, owner, issue.number, issue.title, issue.body, issue.state, labels, issue.assignee.map(_.login).toList)
      FunctionResponse(Status.Success, Some(s"Successfully labelled issue `#$number` in `$owner/$repo`"), None, JsonBodyOption(response))
    } catch {
      case e: Exception =>
        val msg = s"Failed to label issue `#$number` in `$owner/$repo`"
        logger.warn(msg, e)
        FunctionResponse(Status.Failure, Some(msg), None, StringBodyOption(e.getMessage))
    }
  }
} 
开发者ID:atomist,项目名称:rug-functions-github,代码行数:40,代码来源:AddLabelIssueFunction.scala

示例15: SearchIssuesFunction

//设置package包名称以及导入依赖的类
package com.atomist.rug.function.github.issue

import com.atomist.rug.function.github.GitHubFunction
import com.atomist.rug.spi.Handlers.Status
import com.atomist.rug.spi.annotation.{Parameter, RugFunction, Secret, Tag}
import com.atomist.rug.spi.{AnnotatedRugFunction, FunctionResponse, JsonBodyOption, StringBodyOption}
import com.atomist.source.git.GitHubServices
import com.typesafe.scalalogging.LazyLogging

class SearchIssuesFunction
  extends AnnotatedRugFunction
    with LazyLogging
    with GitHubFunction {

  @RugFunction(name = "search-github-issues", description = "Search for GitHub issues",
    tags = Array(new Tag(name = "github"), new Tag(name = "issues")))
  def invoke(@Parameter(name = "q") q: String,
             @Parameter(name = "page") page: Int = 1,
             @Parameter(name = "perPage") perPage: Int = 10,
             @Parameter(name = "repo") repo: String,
             @Parameter(name = "owner") owner: String,
             @Parameter(name = "apiUrl") apiUrl: String,
             @Secret(name = "user_token", path = "github://user_token?scopes=repo") token: String): FunctionResponse = {

    logger.info(s"Invoking searchIssues with q '$q', owner '$owner', repo '$repo', page '$page' and prePage '$perPage' and token '${safeToken(token)}'")

    try {
      val ghs = GitHubServices(token, apiUrl)

      val params = Map("per_page" -> perPage.toString,
        "page" -> page.toString,
        "q" -> s"repo:$owner/$repo $q",
        "sort" -> "updated",
        "order" -> "desc")

      val issues = ghs.searchIssues(params).items
        .map(i => {
          val id = i.number
          val title = i.title
          val urlStr = i.url
          // https://api.github.com/repos/octocat/Hello-World/issues/1347
          val url = urlStr.replace("https://api.github.com/repos/", "https://github.com/").replace(s"/issues/$id", "")
          // https://github.com/atomisthq/bot-service/issues/72
          val issueUrl = urlStr.replace("https://api.github.com/repos/", "https://github.com/")
          // atomisthq/bot-service
          val repo = urlStr.replace("https://api.github.com/repos/", "").replace(s"/issues/$id", "")
          val ts = i.updatedAt.toInstant.getEpochSecond
          GitHubIssue(id, title, url, issueUrl, repo, ts, i.state, i.assignee.orNull)
        })
      FunctionResponse(Status.Success, Some(s"Successfully listed issues for search `$q` on `$repo/$owner`"), None, JsonBodyOption(issues))
    } catch {
      // Need to catch Throwable as Exception lets through GitHub message errors
      case t: Throwable =>
        val msg = "Failed to search issues"
        logger.warn(msg, t)
        FunctionResponse(Status.Failure, Some(msg), None, StringBodyOption(t.getMessage))
    }
  }
} 
开发者ID:atomist,项目名称:rug-functions-github,代码行数:60,代码来源:SearchIssuesFunction.scala


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