mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-30 20:31:34 +02:00
reduce logging
This commit is contained in:
@@ -63,7 +63,7 @@ class ASpellRunner
|
||||
for k, v of addToCache
|
||||
cache.set(k, v)
|
||||
|
||||
logger.log hits: hits, total: words.length, hitrate: (hits/words.length).toFixed(2), "cache hit rate"
|
||||
logger.info hits: hits, total: words.length, hitrate: (hits/words.length).toFixed(2), "cache hit rate"
|
||||
callback null, results
|
||||
|
||||
getSuggestions: (language, output) ->
|
||||
|
||||
@@ -10,11 +10,11 @@ class ASpellWorker
|
||||
@language = language
|
||||
@count = 0
|
||||
@pipe = child_process.spawn("aspell", ["pipe", "-t", "--encoding=utf-8", "-d", language])
|
||||
logger.log process: @pipe.pid, lang: @language, "starting new aspell worker"
|
||||
logger.info process: @pipe.pid, lang: @language, "starting new aspell worker"
|
||||
metrics.inc "aspellWorker-start-" + @language
|
||||
@pipe.on 'exit', () =>
|
||||
@state = 'killed'
|
||||
logger.log process: @pipe.pid, lang: @language, "aspell worker has exited"
|
||||
logger.info process: @pipe.pid, lang: @language, "aspell worker has exited"
|
||||
metrics.inc "aspellWorker-exit-" + @language
|
||||
@pipe.on 'close', () =>
|
||||
@state = 'closed' unless @state == 'killed'
|
||||
@@ -30,7 +30,7 @@ class ASpellWorker
|
||||
@callback = null
|
||||
@pipe.stdin.on 'error', (err) =>
|
||||
@state = 'error' unless @state == 'killed'
|
||||
logger.log process: @pipe.pid, error: err, stdout: output.slice(-1024), stderr: error.slice(-1024), lang: @language, "aspell worker error on stdin"
|
||||
logger.info process: @pipe.pid, error: err, stdout: output.slice(-1024), stderr: error.slice(-1024), lang: @language, "aspell worker error on stdin"
|
||||
if @callback?
|
||||
@callback err, []
|
||||
@callback = null
|
||||
@@ -89,12 +89,12 @@ class ASpellWorker
|
||||
@sendCommand("$$l")
|
||||
|
||||
shutdown: (reason) ->
|
||||
logger.log process: @pipe.pid, reason: reason, 'shutting down'
|
||||
logger.info process: @pipe.pid, reason: reason, 'shutting down'
|
||||
@state = "closing"
|
||||
@pipe.stdin.end()
|
||||
|
||||
kill: (reason) ->
|
||||
logger.log process: @pipe.pid, reason: reason, 'killing'
|
||||
logger.info process: @pipe.pid, reason: reason, 'killing'
|
||||
return if @state == 'killed'
|
||||
@pipe.kill('SIGKILL')
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class ASpellWorkerPool
|
||||
if worker.idleTimer?
|
||||
clearTimeout worker.idleTimer
|
||||
worker.idleTimer = null
|
||||
logger.log process: worker.pipe.pid, lang: language, "removing aspell worker from pool"
|
||||
logger.info process: worker.pipe.pid, lang: language, "removing aspell worker from pool"
|
||||
@cleanup()
|
||||
@PROCESS_POOL.push(worker)
|
||||
metrics.gauge 'aspellWorkerPool-size', @PROCESS_POOL.length
|
||||
|
||||
@@ -5,7 +5,7 @@ metrics = require('metrics-sharelatex')
|
||||
module.exports = SpellingAPIController =
|
||||
check: (req, res, next) ->
|
||||
metrics.inc "spelling-check", 0.1
|
||||
logger.log token: req?.params?.user_id, word_count: req?.body?.words?.length, "running check"
|
||||
logger.info token: req?.params?.user_id, word_count: req?.body?.words?.length, "running check"
|
||||
SpellingAPIManager.runRequest req.params.user_id, req.body, (error, result) ->
|
||||
if error?
|
||||
logger.err err:error, user_id:req?.params?.user_id, word_count: req?.body?.words?.length, "error processing spelling request"
|
||||
@@ -14,7 +14,7 @@ module.exports = SpellingAPIController =
|
||||
|
||||
learn: (req, res, next) ->
|
||||
metrics.inc "spelling-learn", 0.1
|
||||
logger.log token: req?.params?.user_id, word: req?.body?.word, "learning word"
|
||||
logger.info token: req?.params?.user_id, word: req?.body?.word, "learning word"
|
||||
SpellingAPIManager.learnWord req.params.user_id, req.body, (error, result) ->
|
||||
return next(error) if error?
|
||||
res.sendStatus(200)
|
||||
|
||||
@@ -9,6 +9,7 @@ describe "ASpell", ->
|
||||
@ASpell = SandboxedModule.require "../../../app/js/ASpell", requires:
|
||||
"logger-sharelatex":
|
||||
log:->
|
||||
info:->
|
||||
err:->
|
||||
'metrics-sharelatex':
|
||||
gauge:->
|
||||
|
||||
Reference in New Issue
Block a user