code: def timer(
      message="elapsed time:",
      level=logging.INFO,
      logger=None,
      librato=True,
  ):
      global _librato, _nested_timers, _previous_timer_level, _ascii_pipes, _timer_logger
  
      if logger is None:
          logger = _timer_logger
  
      if level < logger.level:
          yield
          return
      _nested_timers += 1
      start = datetime.now()
      try:
          yield
      finally:
          time = datetime.now() - start
          if librato and _librato and level >= logging.INFO:
              librato_name = "timer." + message.lower()
              librato_name = librato_name.split(":")[0]
              librato_name = re.sub(
                  r"[^A-Za-z0-9\.\-_]", "", librato_name
              )[0:255]
              librato_record(librato_name, time.total_seconds())
  
          _nested_timers -= 1
          if _nested_timers == 0 or not env.UNICODE_LOCALE:
              _ascii_pipes = ""
          else:
              delta = _nested_timers - _previous_timer_level
              length = _nested_timers * 2
              if delta < 0:
                  _ascii_pipes = _ascii_pipes[0:length]
                  join = "┌" if _ascii_pipes[-2] == " " else "├"
                  _ascii_pipes = _ascii_pipes[0:-2] + join + "─"
              else:
                  _ascii_pipes = re.sub(
                      r"[├┌]", "│", _ascii_pipes
                  ).replace("─", " ")
                  if delta == 0:
                      _ascii_pipes = _ascii_pipes[:-2] + "├─"
                  else:
                      gap = length - len(_ascii_pipes) - 2
                      _ascii_pipes = _ascii_pipes + " " * gap + "┌─"
  
          _previous_timer_level = _nested_timers
          logger.log(
              level,
              (
                  ansi.bold(_ascii_pipes + "[" + str(time) + "] ")
                  + message
              ),
          )
  
imports: from __future__ import absolute_import, unicode_literals
  import atexit
  import inspect
  import functools
  import logging
  import logging.handlers
  import os
  import re
  import shutil
  import sys
  import time
  import threading
  import traceback
  from contextlib import contextmanager
  from datetime import datetime
  from lore import ansi, env
  from urllib.parse import urlparse
label_desc: Use image node_id 6 for calling a global function with example usage: timer(message, level, logger, librato) without return types