refactor: added standard nim logging library
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
import asyncdispatch, times, strformat, strutils, tables, hashes
|
||||
import asyncdispatch, times, strformat, strutils, tables, hashes, logging
|
||||
import redis, redpool, flatty, supersnappy
|
||||
|
||||
import types, api
|
||||
@@ -59,8 +59,7 @@ proc initRedisPool*(cfg: Config) {.async.} =
|
||||
await r.configSet("hash-max-ziplist-entries", "1000")
|
||||
|
||||
except OSError:
|
||||
stdout.write "Failed to connect to Redis.\n"
|
||||
stdout.flushFile
|
||||
fatal "Failed to connect to Redis."
|
||||
quit(1)
|
||||
|
||||
template uidKey(name: string): string = "pid:" & $(hash(name) div 1_000_000)
|
||||
@@ -112,7 +111,7 @@ template deserialize(data, T) =
|
||||
try:
|
||||
result = fromFlatty(uncompress(data), T)
|
||||
except:
|
||||
echo "Decompression failed($#): '$#'" % [astToStr(T), data]
|
||||
error "Decompression failed($#): '$#'" % [astToStr(T), data]
|
||||
|
||||
proc getUserId*(username: string): Future[string] {.async.} =
|
||||
let name = toLower(username)
|
||||
@@ -189,6 +188,6 @@ proc getCachedRss*(key: string): Future[Rss] {.async.} =
|
||||
let feed = await r.hGet(k, "rss")
|
||||
if feed.len > 0 and feed != redisNil:
|
||||
try: result.feed = uncompress feed
|
||||
except: echo "Decompressing RSS failed: ", feed
|
||||
except: error "Decompressing RSS failed: ", feed
|
||||
else:
|
||||
result.cursor.setLen 0
|
||||
|
||||
Reference in New Issue
Block a user