Commit fce94e73 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

[debug/source_highlight] rename highlight to highlight_terminal

parent e55f6f6a8d28
......@@ -12,7 +12,7 @@ except ImportError:
has_pygments = False
def highlight(code, language):
def highlight_terminal(code, language):
if not has_pygments:
return code
......
......@@ -32,7 +32,7 @@ from cubicweb import Binary, server
from cubicweb.rset import ResultSet
from cubicweb.utils import QueryCache, RepeatList
from cubicweb.misc.source_highlight import highlight
from cubicweb.misc.source_highlight import highlight_terminal
from cubicweb.server.rqlannotation import SQLGenAnnotator, set_qdata
from cubicweb.server.ssplanner import READ_ONLY_RTYPES, add_types_restriction
from cubicweb.server.edition import EditedEntity
......@@ -524,7 +524,7 @@ class QuerierHelper(object):
if server.DEBUG & (server.DBG_RQL | server.DBG_SQL):
if server.DEBUG & (server.DBG_MORE | server.DBG_SQL):
print('*'*80)
print("querier input", highlight(repr(rql)[1:-1], 'RQL'), repr(args))
print("querier input", highlight_terminal(repr(rql)[1:-1], 'RQL'), repr(args))
try:
rqlst, cachekey = self.rql_cache.get(cnx, rql, args)
except UnknownEid:
......
......@@ -27,13 +27,13 @@ from yams.schema import role_name
from cubicweb import ValidationError, set_log_methods, server, _
from cubicweb.server import SOURCE_TYPES
from cubicweb.misc.source_highlight import highlight
from cubicweb.misc.source_highlight import highlight_terminal
def dbg_st_search(uri, union, args, cachekey=None, prefix='rql for'):
if server.DEBUG & server.DBG_RQL:
global t
print(" ", prefix, uri, "source:", highlight(repr(union.as_string())[1:-1], 'RQL'))
print(" ", prefix, uri, "source:", highlight_terminal(repr(union.as_string())[1:-1], 'RQL'))
t = time()
if server.DEBUG & server.DBG_MORE:
print(' args', repr(args))
......
......@@ -50,7 +50,7 @@ from cubicweb.server.hook import CleanupDeletedEidsCacheOp
from cubicweb.server.edition import EditedEntity
from cubicweb.server.sources import AbstractSource, dbg_st_search, dbg_results
from cubicweb.server.sources.rql2sql import SQLGenerator
from cubicweb.misc.source_highlight import highlight
from cubicweb.misc.source_highlight import highlight_terminal
from cubicweb.statsd_logger import statsd_timeit
......@@ -68,12 +68,12 @@ class LogCursor(object):
it's a function just so that it shows up in profiling
"""
if server.DEBUG & server.DBG_SQL:
print('exec', highlight(query, "SQL"), args)
print('exec', highlight_terminal(query, "SQL"), args)
try:
self.cu.execute(str(query), args)
except Exception as ex:
print("sql: %r\n args: %s\ndbms message: %r" % (
highlight(query, "SQL"), args, ex.args[0]))
highlight_terminal(query, "SQL"), args, ex.args[0]))
raise
def fetchall(self):
......@@ -686,7 +686,7 @@ class NativeSQLSource(SQLAdapterMixIn, AbstractSource):
"""
cursor = cnx.cnxset.cu
if server.DEBUG & server.DBG_SQL:
print('exec', highlight(query, "SQL"), args, cnx.cnxset.cnx)
print('exec', highlight_terminal(query, "SQL"), args, cnx.cnxset.cnx)
try:
# str(query) to avoid error if it's a unicode string
cursor.execute(str(query), args)
......@@ -749,7 +749,7 @@ class NativeSQLSource(SQLAdapterMixIn, AbstractSource):
it's a function just so that it shows up in profiling
"""
if server.DEBUG & server.DBG_SQL:
print('execmany', highlight(query, "SQL"), 'with', len(args), 'arguments',
print('execmany', highlight_terminal(query, "SQL"), 'with', len(args), 'arguments',
cnx.cnxset.cnx)
cursor = cnx.cnxset.cu
try:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment