Skip to content

Commit

Permalink
添加日志
Browse files Browse the repository at this point in the history
  • Loading branch information
Liloupar committed Dec 24, 2019
1 parent df8f3a4 commit 90ac535
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 23 deletions.
5 changes: 5 additions & 0 deletions src/main/java/org/lightink/reader/api/HoumoApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ class HoumoApi : BaseApi {
router.post("/houmo/getBookInfo").handler { getBookInfo(it) }
router.post("/houmo/getChapterList").handler { getChapterList(it) }
router.post("/houmo/getContent").handler { getContent(it) }
router.get("/houmo/md5").handler { getMd5(it) }
}

private fun getMd5(it: RoutingContext) {
it.success(YueduSchedule.Shuyuan.shuyuanlist)
}

private fun getBookInfo(context: RoutingContext) {
Expand Down
8 changes: 6 additions & 2 deletions src/main/java/org/lightink/reader/service/yuedu/Debug.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ private val logger = KotlinLogging.logger {}

object Debug {
private var debugSource: String? = null
var callback: Callback? = null
var callback: Callback? = object : Callback {
override fun printLog(state: Int, msg: String) {
logger.info("state: {}, msg: {}", state, msg)
}
}
private val tasks: CompositeCoroutine = CompositeCoroutine()

private val DEBUG_TIME_FORMAT = SimpleDateFormat("[mm:ss.SSS]", Locale.getDefault())
Expand All @@ -30,7 +34,7 @@ object Debug {
showTime: Boolean = true,
state: Int = 1
) {
if (debugSource != sourceUrl || callback == null || !print) return
// if (debugSource != sourceUrl || callback == null || !print) return
var printMsg = msg ?: ""
if (isHtml) {
printMsg = printMsg.htmlFormat()
Expand Down
49 changes: 28 additions & 21 deletions src/test/java/org/lightink/reader/service/yuedu/DebugTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,34 @@ class DebugTest {
@Test
fun startDebug() {
val bookSource = OldRule.jsonToBookSource("{\n" +
" \"bookSourceGroup\": \"✯༇薅白魔人♪\",\n" +
" \"bookSourceName\": \"有兔\",\n" +
" \"bookSourceUrl\": \"http://app.youzibank.com\",\n" +
" \"enable\": true,\n" +
" \"ruleBookContent\": \"@Js:result\",\n" +
" \"ruleBookName\": \"\",\n" +
" \"ruleChapterList\": \"data.*\",\n" +
" \"ruleChapterName\": \"name\",\n" +
" \"ruleContentUrl\": \"https://book.chengxinqinye.com/book{\$.filePath}\",\n" +
" \"ruleFindUrl\": \"历史传记::/book/list?selectionModuleId=0&fullFlag=0&orderBy=read_cnt&clsIdFirst=193&clsIdSecond=0&gender=-1&pageNo=searchPage\\n经济管理::/book/list?selectionModuleId=0&fullFlag=0&orderBy=read_cnt&clsIdFirst=205&clsIdSecond=0&gender=-1&pageNo=searchPage\\n社科心理::/book/list?selectionModuleId=0&fullFlag=0&orderBy=read_cnt&clsIdFirst=212&clsIdSecond=0&gender=-1&pageNo=searchPage\\n艺术生活::/book/list?selectionModuleId=0&fullFlag=0&orderBy=read_cnt&clsIdFirst=245&clsIdSecond=0&gender=-1&pageNo=searchPage\\n历史著作::/book/list?selectionModuleId=0&fullFlag=0&orderBy=read_cnt&clsIdFirst=258&clsIdSecond=0&gender=-1&pageNo=searchPage\\n成功励志::/book/list?selectionModuleId=0&fullFlag=0&orderBy=read_cnt&clsIdFirst=269&clsIdSecond=0&gender=-1&pageNo=searchPage\\n英文著作::/book/list?selectionModuleId=0&fullFlag=0&orderBy=read_cnt&clsIdFirst=276&clsIdSecond=0&gender=-1&pageNo=searchPage\\n儿童读物::/book/list?selectionModuleId=0&fullFlag=0&orderBy=read_cnt&clsIdFirst=280&clsIdSecond=0&gender=-1&pageNo=searchPage\\n古典文学::/book/list?selectionModuleId=0&fullFlag=0&orderBy=read_cnt&clsIdFirst=283&clsIdSecond=0&gender=-1&pageNo=searchPage\\n现代文学::/book/list?selectionModuleId=0&fullFlag=0&orderBy=read_cnt&clsIdFirst=287&clsIdSecond=0&gender=-1&pageNo=searchPage\\n商业思维::/book/list?selectionModuleId=0&fullFlag=0&orderBy=read_cnt&clsIdFirst=291&clsIdSecond=0&gender=-1&pageNo=searchPage\\n其他::/book/list?selectionModuleId=0&fullFlag=0&orderBy=read_cnt&clsIdFirst=116&clsIdSecond=0&gender=2&pageNo=searchPage\",\n" +
" \"ruleSearchAuthor\": \"author\",\n" +
" \"ruleSearchCoverUrl\": \"https://book.banquanzhuce.com/book{\$.photoPath}\",\n" +
" \"ruleSearchIntroduce\": \"intro\",\n" +
" \"ruleSearchKind\": \"clsName\",\n" +
" \"ruleSearchLastChapter\": \"lastUpdate\",\n" +
" \"ruleSearchList\": \"data.*\",\n" +
" \"ruleSearchName\": \"name\",\n" +
" \"ruleSearchNoteUrl\": \"/book/chapter/listAll?bookId={\$.id}\",\n" +
" \"ruleSearchUrl\": \"http://app.youzibank.com:80/es/search/book?q=searchKey&pageNo=searchPage&pageSize=10@header:{Seq:'2482380c2df68970a7833191e8193316'}\",\n" +
" \"serialNumber\": 1,\n" +
" \"weight\": 0\n" +
"\t\"bookSourceGroup\": \"S级\",\n" +
"\t\"bookSourceName\": \"百合小说网\",\n" +
"\t\"bookSourceUrl\": \"https://www.baihexs.com\",\n" +
"\t\"enable\": true,\n" +
"\t\"httpUserAgent\": \"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko, By Black Prism) Chrome/99.0 Safari/537.36\",\n" +
"\t\"loginUrl\": \"\",\n" +
"\t\"ruleBookAuthor\": \"\",\n" +
"\t\"ruleBookContent\": \"id.content@textNodes#请牢记:.*百合小说网.*\",\n" +
"\t\"ruleBookName\": \"\",\n" +
"\t\"ruleChapterList\": \"[email protected]!0\",\n" +
"\t\"ruleChapterName\": \"tag.a@text\",\n" +
"\t\"ruleChapterUrl\": \"[email protected]@href\",\n" +
"\t\"ruleChapterUrlNext\": \"\",\n" +
"\t\"ruleContentUrl\": \"tag.a@href\",\n" +
"\t\"ruleContentUrlNext\": \"\",\n" +
"\t\"ruleCoverUrl\": \"[email protected]@src\",\n" +
"\t\"ruleFindUrl\": \"\",\n" +
"\t\"ruleIntroduce\": \"id.bookintro@text\",\n" +
"\t\"ruleSearchAuthor\": \"class.odd.1@text|[email protected]@text\",\n" +
"\t\"ruleSearchCoverUrl\": \"\",\n" +
"\t\"ruleSearchKind\": \"\",\n" +
"\t\"ruleSearchLastChapter\": \"[email protected]@text|[email protected]@tag.a.0@text\",\n" +
"\t\"ruleSearchList\": \"[email protected]!0|id.conn\",\n" +
"\t\"ruleSearchName\": \"[email protected]@text|tag.h1@text\",\n" +
"\t\"ruleSearchNoteUrl\": \"[email protected]@href\",\n" +
"\t\"ruleSearchUrl\": \"https://www.baihexs.com/modules/article/search.php@searchkey=searchKey|char=gbk\",\n" +
"\t\"serialNumber\": 15,\n" +
"\t\"weight\": 0\n" +
"}")
val webBook = WebBook(bookSource)
Debug.startDebug(webBook, "剑来")
Expand Down

0 comments on commit 90ac535

Please sign in to comment.