How can I listen the events of module/class defined

In our project, I need to listen the events of module/class defined, and record the events that include the context of the module/class defined. In ruby, I cannot add a listener for the module/class defined, only i can set a proc with set_trace_func, in the proc, I cannot get the module/class name from the parameters.