openPMD / openPMD-api

:floppy_disk: C++ & Python API for Scientific I/O
https://openpmd-api.readthedocs.io
GNU Lesser General Public License v3.0
134 stars 51 forks source link

Optional debugging output for AbstractIOHandlerImpl::flush() #1495

Closed franzpoeschel closed 11 months ago

franzpoeschel commented 11 months ago

I've used something like this probably a hundred times already, this PR puts debugging output (disabled by default) for the backend IO tasks into AbstractIOHandlerImpl::flush().

To be enabled by manually putting a #define OPENPMD_DEBUG 1 in the corresponding .cpp file. This can be seen as a first step toward proper debug logging that users can enable e.g. via an environment variable.

Sample output:

Filters: write_test                                                                                 [1185/1896]
[0->0xe1e938] CREATE_FILE: serial_write
[0xe1e938->0xe1eb08] CREATE_PATH: /data/
[0xe1eb08->0xe32088] CREATE_PATH: 1
[0->0xe1e938] WRITE_ATT: (STRING) particlesPath
[0xe32088->0xe31fb8] CREATE_PATH: particles/
[0xe31fb8->0xe16f88] CREATE_PATH: e
[0xe16f88->0xe2e768] CREATE_PATH: position
[0xe2e768->0xe2d598] CREATE_DATASET: x
[0xe2e768->0xe2d598] WRITE_DATASET
[0xe2e768->0xe2d598] WRITE_DATASET
[0xe2e768->0xe2d598] WRITE_DATASET
[0xe2e768->0xe2d598] WRITE_DATASET
[0xe2e768->0xe2d598] WRITE_ATT: (DOUBLE) unitSI
[0xe16f88->0xe2e768] WRITE_ATT: (FLOAT) timeOffset
[0xe16f88->0xe2e768] WRITE_ATT: (ARR_DBL_7) unitDimension
[0xe16f88->0xe2df78] CREATE_PATH: positionOffset
[0xe2df78->0xe2fa18] CREATE_DATASET: x
[0xe2df78->0xe2fa18] WRITE_DATASET
[0xe2df78->0xe2fa18] WRITE_DATASET
[0xe2df78->0xe2fa18] WRITE_DATASET
[0xe2df78->0xe2fa18] WRITE_DATASET
[0xe2df78->0xe2fa18] WRITE_ATT: (DOUBLE) unitSI
[0xe16f88->0xe2df78] WRITE_ATT: (FLOAT) timeOffset
[0xe16f88->0xe2df78] WRITE_ATT: (ARR_DBL_7) unitDimension
[0xe1eb08->0xe32088] WRITE_ATT: (DOUBLE) dt
[0xe1eb08->0xe32088] WRITE_ATT: (DOUBLE) time
[0xe1eb08->0xe32088] WRITE_ATT: (DOUBLE) timeUnitSI
[0xe1eb08->0xe1b8a8] CREATE_PATH: 2
[0xe1b8a8->0xe30498] CREATE_PATH: particles/
[0xe30498->0xe1a6b8] CREATE_PATH: e
[0xe1a6b8->0xe2f0d8] CREATE_PATH: position
[0xe2f0d8->0xe2f3a8] CREATE_DATASET: x
[0xe2f0d8->0xe2f3a8] WRITE_DATASET
[0xe2f0d8->0xe2f3a8] WRITE_DATASET
[0xe2f0d8->0xe2f3a8] WRITE_DATASET
[0xe2f0d8->0xe2f3a8] WRITE_DATASET
[0xe2f0d8->0xe2f3a8] WRITE_ATT: (DOUBLE) unitSI
[0xe1a6b8->0xe2f0d8] WRITE_ATT: (FLOAT) timeOffset
[0xe1a6b8->0xe2f0d8] WRITE_ATT: (ARR_DBL_7) unitDimension
[0xe1a6b8->0xe32498] CREATE_PATH: positionOffset
[0xe32498->0xe32778] CREATE_DATASET: x
[0xe32498->0xe32778] WRITE_DATASET
[0xe32498->0xe32778] WRITE_DATASET
[0xe32498->0xe32778] WRITE_DATASET
[0xe32498->0xe32778] WRITE_DATASET
[0xe32498->0xe32778] WRITE_ATT: (DOUBLE) unitSI
[0xe1a6b8->0xe32498] WRITE_ATT: (FLOAT) timeOffset
[0xe1a6b8->0xe32498] WRITE_ATT: (ARR_DBL_7) unitDimension
franzpoeschel commented 11 months ago

This is great!

Since it is not performance critical, one could also consider controlling this with an environment option (verbosity).

That way, no recompile needs to be done.

I had not added that because of our plans to introduce proper logging at some point, but adding an environment variable is probably a good idea. This way, we can easily ask users to give us more details in bug reports without recompiling anything. In that case, I would maybe even include this in 0.15.2?