def _logdef(self, n, o, otype):
import re<EOL>try:<EOL><INDENT>if otype == "<STR_LIT>":<EOL><INDENT>cellno = max([int(k[<NUM_LIT:2>:]) for k in self.shell.user_ns.keys()<EOL>if re.match("<STR_LIT>", k)])<EOL><DEDENT>elif otype == "<STR_LIT>":<EOL><INDENT>cellno = int(o.__code__.co_filename.strip("<STR_LIT>").split('<STR_LIT:->')[<NUM_LIT:2>])<EOL><DEDENT><DEDENT>except:<EOL><INDENT>cellno = None<EOL>pass<EOL><DEDENT>code = "<STR_LIT>"<EOL>if cellno is not None:<EOL><INDENT>cellstr = "<STR_LIT>".format(cellno)<EOL>if cellstr in self.shell.user_ns:<EOL><INDENT>cellcode = self.shell.user_ns[cellstr]<EOL>import ast<EOL>astm = ast.parse(cellcode)<EOL>ab = astm.body<EOL>parts = {ab[i].name: (ab[i].lineno, None if i+<NUM_LIT:1> >= len(ab)<EOL>else ab[i+<NUM_LIT:1>].lineno) <EOL>for i, d in enumerate(ab)}<EOL>if n in parts:<EOL><INDENT>celllines = cellcode.split('<STR_LIT:\n>')<EOL>start, end = parts[n]<EOL>if end is not None:<EOL><INDENT>code = celllines[start-<NUM_LIT:1>:end-<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>code = celllines[start-<NUM_LIT:1>:]<EOL><DEDENT><DEDENT><DEDENT><DEDENT>from time import time<EOL>from acorn.logging.database import record<EOL>entry = {<EOL>"<STR_LIT:m>": "<STR_LIT>",<EOL>"<STR_LIT:a>": None,<EOL>"<STR_LIT:s>": time(),<EOL>"<STR_LIT:r>": None,<EOL>"<STR_LIT:c>": code,<EOL>}<EOL>from acorn import msg<EOL>record("<STR_LIT>".format(n), entry, diff=True)<EOL>msg.info(entry, <NUM_LIT:1>)<EOL>
Logs the definition of the object that was just auto-decorated inside
        the `ipython` notebook.