Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use builtin python logging module instead of Logger

Logger was defined in ensime-common
  • Loading branch information...
commit 1fe27e793d6012ee8b2557d11f5027fb06d71732 1 parent 5eee082
Jeanluc Chasseriau authored
View
2  .gitignore
@@ -1,2 +1,4 @@
*.pyc
*.swp
+*.swo
+*.swn
View
6 autoload/envim.vim
@@ -50,6 +50,7 @@ python << endpython
import os
import vim
import sys
+import logging
# retrieve paths on the python side of the force
ensimePath = vim.eval("g:envim['path-ensime']")
@@ -77,9 +78,8 @@ ensimeDistPath = ensimePath + os.path.sep + lastDist
vim.command("let g:envim['path-ensime-dist'] = get(g:envim, 'path-ensime-dist', '"+ensimeDistPath+"')")
# setup logger
-Logger().setOutput("./envim.log")
-Logger().useStdOut(False)
-Logger().info('-'*50)
+initLog('ensime-common', 'envim.log')
+initLog('envim', 'envim.log')
# not ready to send anything to ensime yet
SwankProcessor().setSendFunction(None)
View
10 python/Envim.py
@@ -29,20 +29,16 @@
# - update QuickFixList only when received FullTypecheck done
# - test if Analyzer is ready before use TypecheckFile / TypecheckAll
+import logging
from VimHelpers import *
+from Helper import *
-from Helper import Logger
from SwankProtocol import *
from Responses import *
from Events import *
-def setupEnsime():
- Logger().setOutput("./vim_envim.log")
- Logger().useStdOut(False)
- Logger().info('-'*30)
-
- SwankProcessor().setSendFunction(None)
+log = logging.getLogger('envim')
@CatchAndLogException
def envimConnectionAndProjectInit():
View
12 python/Events.py
@@ -25,12 +25,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import logging
from VimHelpers import *
-from Helper import SimpleSingleton, Logger
+
+log = logging.getLogger('envim')
@SwankEventBackgroundMessage
def backgroundMessage(code, details):
- Logger().debug('Background message: '+codeDetailsString(code, details))
+ log.debug('Background message: '+codeDetailsString(code, details))
echo(details)
@SwankEventReaderError
@@ -57,11 +59,11 @@ def scalaNotes(notes):
# notes.notes = []
if (notes.is_full):
- Logger().debug("Full scala notes list, clear previous list")
+ log.debug("Full scala notes list, clear previous list")
qflist = notesToQuickFixList(notes.notes)
else:
- Logger().debug("Partial scala notes list")
+ log.debug("Partial scala notes list")
# here we prepend existing notes
notes.notes.reverse()
@@ -78,7 +80,7 @@ def scalaNotes(notes):
@SwankEventClearAllScalaNotes
def clearAllScalaNotes():
- Logger().debug("Clear all Scala notes")
+ log.debug("Clear all Scala notes")
setQuickFixList([])
View
7 python/Responses.py
@@ -25,8 +25,11 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+import logging
from VimHelpers import *
-from Helper import SimpleSingleton, Logger
+from Helper import SimpleSingleton
+
+log = logging.getLogger('envim')
@SimpleSingleton
class ConnectionInfoHandler(SwankCallHandler):
@@ -60,7 +63,7 @@ def response(self, r):
echo("Initializing project: "+str(r.project_name))
for src in r.source_roots:
- Logger().debug("project source roots: "+src)
+ log.debug("project source roots: "+src)
State().initialized = True
View
30 python/VimHelpers.py
@@ -30,10 +30,12 @@
import mmap
import types
import vim
-from Helper import Logger
+import logging
from SExpression import *
from SwankProtocol import *
+log = logging.getLogger('envim')
+
@SimpleSingleton
class State(object):
def __init__(self):
@@ -64,17 +66,17 @@ def checkCompilerReady():
# normal echo (in vim command line)
def echo(s):
- Logger().info(s)
+ log.info(s)
vim.command("echo('"+s+"')")
# error echo (highlighted in vim command line)
def echoe(s):
- Logger().error(s)
+ log.error(s)
vim.command("echoe('"+s+"')")
# debug echo (as provided by Decho addon: open a new window)
def decho(s):
- Logger().debug(s)
+ log.debug(s)
vim.command("Decho('"+s+"')")
def writeToEnsimeClient(data):
@@ -118,8 +120,8 @@ def listOfDictToString(li):
return o
o = listOfDictToString(qflist)
- Logger().debug("Quick fix list: ")
- Logger().debug(o)
+ log.debug("Quick fix list: ")
+ log.debug(o)
vim.command("call setqflist("+o+")")
@@ -148,7 +150,7 @@ def codeDetailsString(code, detail):
def ensimeConfigToPython(filename):
try: f = file(filename)
except:
- Logger().error("ensimeConfigToPython: unable to open ensime config file ("+filename+")")
+ log.error("ensimeConfigToPython: unable to open ensime config file ("+filename+")")
return None
outlist = []
@@ -170,8 +172,8 @@ def ensimeConfigToPython(filename):
out = ' '.join(outlist)
- Logger().debug("ensimeConfigToPython: reading conf:")
- Logger().debug(out)
+ log.debug("ensimeConfigToPython: reading conf:")
+ log.debug(out)
sexp = SExpParser().parse(out)
py = sexp.toPy()
@@ -179,8 +181,8 @@ def ensimeConfigToPython(filename):
if not py.has('root_dir'):
setattr(py, 'root_dir', os.getcwd())
- Logger().debug("ensimeConfigToPython: python object:")
- Logger().debug(py.debugString())
+ log.debug("ensimeConfigToPython: python object:")
+ log.debug(py.debugString())
return py
@@ -210,7 +212,7 @@ def notesToQuickFixList(notes):
debugs = '['+note.severity+'] '+os.path.basename(note.file)+' l.'+str(note.line)+' c.'+str(note.col)
debugs += ' : '+note.msg
- Logger().debug(debugs)
+ log.debug(debugs)
return qflist
@@ -221,7 +223,7 @@ def offsetToLineCol(filename, offset):
buf = mmap.mmap(f.fileno(), 0)
f.close()
except Exception as detail:
- Logger().error("offsetToLineCol: unable to open file ("+filename+") : "+str(detail))
+ log.error("offsetToLineCol: unable to open file ("+filename+") : "+str(detail))
return None
found = False
@@ -246,7 +248,7 @@ def offsetToLineCol(filename, offset):
if found:
return (line, lineno, col)
- Logger().debug("offsetToLineCol: line and column not found for "+filename+":"+str(offset))
+ log.debug("offsetToLineCol: line and column not found for "+filename+":"+str(offset))
return None
def rangePosToQuickFixList(rangePosList):
Please sign in to comment.
Something went wrong with that request. Please try again.