diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-03-13 21:59:23 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-03-13 21:59:23 +0100 |
commit | 3d534375c79d521c9fa747efceb09b5115b94010 (patch) | |
tree | 5fb28dbe8c2b94b586d90115d31db1659cf4c817 | |
parent | 2430fc7d82d54bb10b540ac6498520c116536a6f (diff) | |
download | Nim-3d534375c79d521c9fa747efceb09b5115b94010.tar.gz |
nimsuggest: logging enable when compiled with -d:logging
-rw-r--r-- | nimsuggest/nimsuggest.nim | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/nimsuggest/nimsuggest.nim b/nimsuggest/nimsuggest.nim index 188d7fb5a..2cf19925c 100644 --- a/nimsuggest/nimsuggest.nim +++ b/nimsuggest/nimsuggest.nim @@ -62,7 +62,7 @@ var gAddress = "" gMode: Mode gEmitEof: bool # whether we write '!EOF!' dummy lines - gLogging = false + gLogging = defined(logging) gRefresh: bool requests: Channel[string] @@ -79,6 +79,9 @@ proc errorHook(info: TLineInfo; msg: string; sev: Severity) = line: toLinenumber(info), column: toColumn(info), doc: msg, forth: $sev)) +proc myLog(s: string) = + if gLogging: log(s) + const seps = {':', ';', ' ', '\t'} 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; graph: ModuleGraph; cache: IdentCache) = - if gLogging: - log("cmd: " & $cmd & ", file: " & file & ", dirtyFile: " & dirtyfile & - "[" & $line & ":" & $col & "]") + myLog("cmd: " & $cmd & ", file: " & file & ", dirtyFile: " & dirtyfile & + "[" & $line & ":" & $col & "]") gIdeCmd = cmd if cmd == ideChk: msgs.structuredErrorHook = errorHook - msgs.writelnHook = proc (s: string) = discard + msgs.writelnHook = myLog else: msgs.structuredErrorHook = nil - msgs.writelnHook = proc (s: string) = discard + msgs.writelnHook = myLog if cmd == ideUse and suggestVersion != 0: graph.resetAllModules() var isKnownFile = true @@ -353,8 +355,7 @@ proc replEpc(x: ThreadParams) {.thread.} = setVerbosity(0) else: discard let cmd = $gIdeCmd & " " & args.argsToStr - if gLogging: - log "MSG CMD: " & cmd + myLog "MSG CMD: " & cmd requests.send(cmd) toEpc(client, uid) of "methods": @@ -583,8 +584,7 @@ proc handleCmdLine(cache: IdentCache; config: ConfigRef) = "Cannot find Nim standard library: Nim compiler not in PATH") gPrefixDir = binaryPath.splitPath().head.parentDir() #msgs.writelnHook = proc (line: string) = log(line) - if gLogging: - log("START " & gProjectFull) + myLog("START " & gProjectFull) loadConfigs(DefaultConfig, cache, config) # load all config files # now process command line arguments again, because some options in the |