# API

These methods are called as `revdebug.clear()` for example.

<table data-header-hidden><thead><tr><th width="320.72290006047353"></th><th></th></tr></thead><tbody><tr><td><code>flush()</code></td><td>Flush the record buffers of all threads to network if live recording, otherwise does nothing.</td></tr><tr><td><code>exception(type, value, traceback)</code></td><td>Signal an unhandled exception to be recorded in a live recording and sent as a crash event. If three parameters are specified they must be the exception type, value and traceback as returned by <code>sys.exc_info()</code>.</td></tr><tr><td><code>exception(exc)</code></td><td>If a single argument is passed then it must be a valid <code>BaseException</code> object as would received by <code>except BaseException as exc</code>.</td></tr><tr><td><code>exception()</code></td><td>If no arguments are present then the function assumes it is being called from an <code>except</code> handler and gets the exception information the Python interpreter.</td></tr><tr><td><code>setrecmode(mode)</code></td><td>Set the current recording mode to Continuous / Live, OnEvent / Crash or Off. The recording mode can only be set as high as the server allows, so if the server does not allow continuous recording then that will not happen and only unhandled exceptions will be sent to the server. The available recording modes are <code>revdebug.Off</code>, <code>revdebug.Continuous</code>, <code>revdebug.Live</code>, <code>revdebug.OnEvent</code> and <code>revdebug.Crash</code>. <code>Continuous</code> and <code>Live</code> are aliases as are <code>OnEvent</code> and <code>Crash</code>.</td></tr><tr><td><code>block([clear])</code></td><td>Isolate the currently execution async task context (if any) from other recordings. If the optional positional argument <code>clear</code> is <code>True</code> (default) then if this recording block already exists it will be cleared, which mimics the behavior of a newly created isolation block which starts out empty.</td></tr><tr><td><code>snapshot(name)</code></td><td>Send a snapshot of the current thread execution recording, <code>name</code> is optional and will be an automatically generated increasing sequence name if not provided.</td></tr><tr><td><code>snapshotall(name)</code></td><td>Same as <code>snapshot()</code> except sends all threads.</td></tr><tr><td><code>clear([flush])</code></td><td>Clear the record buffer for the current thread. This can be useful if you want to get rid of any references that might be recorded but you don't want RevDeBug to hold for other reasons. If optional positional argument <code>flush</code> is <code>True</code> (default) then if currently live recording then the buffer will be flushed before clearing and no data is lost, otherwise there will be a hole in the live recording where this function cleared the record buffer.</td></tr><tr><td><code>clearall([flush])</code></td><td>Same as <code>clear()</code> except clears all thread buffers.</td></tr><tr><td><code>record(obj or path)</code></td><td>Turn on recording for a code object, function, class, module, filename or entire path. This may be useful if you want to record a certain system library or site-package that is normally not recorded by default rules. Don't try to record really low level system libraries like <code>gc</code> or <code>weakref</code>, bad things will happen. If you turn on recording for a file or a path then that will be remembered so that even if the file or path is not loaded yet, when it gets loaded it will be set accordingly. Turning on recording for a path automatically turns on recording for anything below that path as well. All currently loaded code objects are checked at time of this call and if they match the path they are turned on for recording. This method can also be used as a decorator for functions or classes in the form of <code>@revdebug.record</code>.</td></tr><tr><td><code>norecord(obj or path)</code></td><td>Same as <code>record</code> except turns off recording.</td></tr><tr><td><code>setrecord(obj or path, record)</code></td><td>Same as <code>record</code> and <code>norecord</code> except that you pass if you wish to turn on or off recording as the bool <code>record</code>, this function can not be used as a decorator.</td></tr><tr><td><code>recrepr(type, func)</code></td><td>This allows you to attach a record stringification function to ANY type, whether native Python, external library, extension C type or even internal Python. This is to allow recording of types RevDeBug does not know anything about. When the object representation is needed the object <code>.func()</code> method will be called with <code>self</code> as the object and should return a string. Exceptions in this function are suppressed. Also, when writing this simple function for stringifying an object please do not to start a new thread, process, or execute another program from within it. Also please avoid interactions with locks, semaphores and or thread-safe queues or other objects. This is all because this function is called from a critical section with thread switching disabled to avoid buffer corruption while serializing, so anything that waits for something from another thread will block indefinitely.</td></tr></tbody></table>

