Skip to content

Commit 4593a82

Browse files
committed
wllvm and gllvm have the same logging API. I need it to see why gllvm, clang, and wllvm get different results when configuring musllvm.
1 parent cd809b3 commit 4593a82

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

README.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,17 +241,25 @@ Debugging
241241
---------
242242

243243
The WLLVM tools can show various levels of output to aid with debugging.
244-
To show this output set WLLVM_OUTPUT to one of the following levels:
244+
To show this output set the `WLLVM_OUTPUT_LEVEL` environment
245+
variable to one of the following levels:
245246

246-
* `CRITICAL`
247247
* `ERROR`
248248
* `WARNING`
249249
* `INFO`
250250
* `DEBUG`
251251

252-
For example
252+
For example:
253+
```
254+
export WLLVM_OUTPUT_LEVEL=DEBUG
255+
```
256+
Output will be directed to the standard error stream, unless you specify the
257+
path of a logfile via the `WLLVM_OUTPUT_FILE` environment variable.
253258

254-
export WLLVM_OUTPUT=DEBUG
259+
For example:
260+
```
261+
export WLLVM_OUTPUT_FILE=/tmp/wllvm.log
262+
```
255263

256264

257265
Sanity Checking

wllvm/compilers.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def wcompile(mode):
3535
except Exception as e:
3636
_logger.debug('%s: exception case: %s', mode, str(e))
3737

38+
_logger.info('Calling %s returned %d', list(sys.argv), rc)
3839
return rc
3940

4041

@@ -204,9 +205,9 @@ def getBuilder(cmd, mode):
204205
compilerEnv = 'LLVM_COMPILER'
205206
cstring = os.getenv(compilerEnv)
206207
pathPrefix = os.getenv(llvmCompilerPathEnv) # Optional
207-
_logger.info('WLLVM compiler using %s', cstring)
208+
_logger.debug('WLLVM compiler using %s', cstring)
208209
if pathPrefix:
209-
_logger.info('WLLVM compiler path prefix "%s"', pathPrefix)
210+
_logger.debug('WLLVM compiler path prefix "%s"', pathPrefix)
210211

211212
if cstring == 'clang':
212213
return ClangBuilder(cmd, mode, pathPrefix)

wllvm/logconfig.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,32 @@
77
import os
88
import sys
99

10-
_loggingEnv = 'WLLVM_OUTPUT'
10+
# iam: 6/30/2017 decided to move to a gllvm style where we can set the level and the output file
11+
_loggingEnvLevel_old = 'WLLVM_OUTPUT'
12+
_loggingEnvLevel_new = 'WLLVM_OUTPUT_LEVEL'
1113

12-
_validLogLevels = ['CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG']
14+
_loggingDestination = 'WLLVM_OUTPUT_FILE'
15+
16+
_validLogLevels = ['ERROR', 'WARNING', 'INFO', 'DEBUG']
1317

1418
def logConfig(name):
1519

16-
logging.basicConfig(level=logging.WARNING, format='%(levelname)s:%(message)s')
20+
destination = os.getenv(_loggingDestination)
21+
22+
if destination:
23+
logging.basicConfig(filename=destination, level=logging.WARNING, format='%(levelname)s:%(message)s')
24+
else:
25+
logging.basicConfig(level=logging.WARNING, format='%(levelname)s:%(message)s')
1726

1827
retval = logging.getLogger(name)
1928

20-
level = os.getenv(_loggingEnv)
29+
level = os.getenv(_loggingEnvLevel_old) or os.getenv(_loggingEnvLevel_new)
2130

2231
if level:
2332
level = level.upper()
2433
if not level in _validLogLevels:
25-
logging.error('"%s" is not a valid value for %s. Valid values are %s',
26-
level, _loggingEnv, _validLogLevels)
34+
logging.error('"%s" is not a valid value for %s or %s. Valid values are %s',
35+
level, _loggingEnvLevel_old, _loggingEnvLevel_new, _validLogLevels)
2736
sys.exit(1)
2837
else:
2938
retval.setLevel(getattr(logging, level))

0 commit comments

Comments
 (0)