nimsuggest: logging enable when compiled with -d:logging
This commit is contained in:
parent
2430fc7d82
commit
3d534375c7
1 changed files with 10 additions and 10 deletions
|
|
@ -62,7 +62,7 @@ var
|
||||||
gAddress = ""
|
gAddress = ""
|
||||||
gMode: Mode
|
gMode: Mode
|
||||||
gEmitEof: bool # whether we write '!EOF!' dummy lines
|
gEmitEof: bool # whether we write '!EOF!' dummy lines
|
||||||
gLogging = false
|
gLogging = defined(logging)
|
||||||
gRefresh: bool
|
gRefresh: bool
|
||||||
|
|
||||||
requests: Channel[string]
|
requests: Channel[string]
|
||||||
|
|
@ -79,6 +79,9 @@ proc errorHook(info: TLineInfo; msg: string; sev: Severity) =
|
||||||
line: toLinenumber(info), column: toColumn(info), doc: msg,
|
line: toLinenumber(info), column: toColumn(info), doc: msg,
|
||||||
forth: $sev))
|
forth: $sev))
|
||||||
|
|
||||||
|
proc myLog(s: string) =
|
||||||
|
if gLogging: log(s)
|
||||||
|
|
||||||
const
|
const
|
||||||
seps = {':', ';', ' ', '\t'}
|
seps = {':', ';', ' ', '\t'}
|
||||||
Help = "usage: sug|con|def|use|dus|chk|mod|highlight|outline|known file.nim[;dirtyfile.nim]:line:col\n" &
|
Help = "usage: sug|con|def|use|dus|chk|mod|highlight|outline|known file.nim[;dirtyfile.nim]:line:col\n" &
|
||||||
|
|
@ -155,16 +158,15 @@ proc symFromInfo(graph: ModuleGraph; gTrackPos: TLineInfo): PSym =
|
||||||
|
|
||||||
proc execute(cmd: IdeCmd, file, dirtyfile: string, line, col: int;
|
proc execute(cmd: IdeCmd, file, dirtyfile: string, line, col: int;
|
||||||
graph: ModuleGraph; cache: IdentCache) =
|
graph: ModuleGraph; cache: IdentCache) =
|
||||||
if gLogging:
|
myLog("cmd: " & $cmd & ", file: " & file & ", dirtyFile: " & dirtyfile &
|
||||||
log("cmd: " & $cmd & ", file: " & file & ", dirtyFile: " & dirtyfile &
|
|
||||||
"[" & $line & ":" & $col & "]")
|
"[" & $line & ":" & $col & "]")
|
||||||
gIdeCmd = cmd
|
gIdeCmd = cmd
|
||||||
if cmd == ideChk:
|
if cmd == ideChk:
|
||||||
msgs.structuredErrorHook = errorHook
|
msgs.structuredErrorHook = errorHook
|
||||||
msgs.writelnHook = proc (s: string) = discard
|
msgs.writelnHook = myLog
|
||||||
else:
|
else:
|
||||||
msgs.structuredErrorHook = nil
|
msgs.structuredErrorHook = nil
|
||||||
msgs.writelnHook = proc (s: string) = discard
|
msgs.writelnHook = myLog
|
||||||
if cmd == ideUse and suggestVersion != 0:
|
if cmd == ideUse and suggestVersion != 0:
|
||||||
graph.resetAllModules()
|
graph.resetAllModules()
|
||||||
var isKnownFile = true
|
var isKnownFile = true
|
||||||
|
|
@ -353,8 +355,7 @@ proc replEpc(x: ThreadParams) {.thread.} =
|
||||||
setVerbosity(0)
|
setVerbosity(0)
|
||||||
else: discard
|
else: discard
|
||||||
let cmd = $gIdeCmd & " " & args.argsToStr
|
let cmd = $gIdeCmd & " " & args.argsToStr
|
||||||
if gLogging:
|
myLog "MSG CMD: " & cmd
|
||||||
log "MSG CMD: " & cmd
|
|
||||||
requests.send(cmd)
|
requests.send(cmd)
|
||||||
toEpc(client, uid)
|
toEpc(client, uid)
|
||||||
of "methods":
|
of "methods":
|
||||||
|
|
@ -583,8 +584,7 @@ proc handleCmdLine(cache: IdentCache; config: ConfigRef) =
|
||||||
"Cannot find Nim standard library: Nim compiler not in PATH")
|
"Cannot find Nim standard library: Nim compiler not in PATH")
|
||||||
gPrefixDir = binaryPath.splitPath().head.parentDir()
|
gPrefixDir = binaryPath.splitPath().head.parentDir()
|
||||||
#msgs.writelnHook = proc (line: string) = log(line)
|
#msgs.writelnHook = proc (line: string) = log(line)
|
||||||
if gLogging:
|
myLog("START " & gProjectFull)
|
||||||
log("START " & gProjectFull)
|
|
||||||
|
|
||||||
loadConfigs(DefaultConfig, cache, config) # load all config files
|
loadConfigs(DefaultConfig, cache, config) # load all config files
|
||||||
# now process command line arguments again, because some options in the
|
# now process command line arguments again, because some options in the
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue