[erlang-questions] Function to print a record with fieldnames?

Convey Christian J NPRI ConveyCJ@REDACTED
Tue Mar 4 15:13:37 CET 2008


I've got a record definition along the lines of:  -record(myrec, {foo = undefined, bar=undefined}).

To help with debugging, I'd like a function that will print out something like the following text:
   #record{foo = 42, bar = the_answer_to_the_question}

Does such a function exist, or must I write my own version of the function for each record type?  I know I can just use io:format("~p~n", [ MyRecord ]), but I'd really like the fieldnames to also be printed.

Christian Convey
Scientist, Naval Undersea Warfare Centers
Newport, RI




More information about the erlang-questions mailing list