import aiotarantool
from datetime import datetime

from aiokts.stores.base import BaseStore
import logging

logger = logging.getLogger('tarantool')


class TarantoolStore(BaseStore):
    def __init__(self, config):
        tnt = aiotarantool.Connection(
            config['host'],
            config['port'],
            user=config.get('user'), password=config.get('password'),
            connect_now=True
        )
        super().__init__(tnt)

    def call(self, name, *args):
        start = datetime.now()
        logger.debug('{} Tarantool call begin: {}'.format(start, name))

        result = super().__getattribute__('call')(name, *args)
        end = datetime.now()
        delta = end - start
        delta = delta.seconds + (delta.microseconds / (10 ** 6))
        logger.debug('{} Tarantool call end: {}, time: {}'.format(end, name, delta))

        return result

    def __getattribute__(self, name):
        if name != 'call':
            return super().__getattribute__(name)
        else:
            def wrap(name, *args):
                return TarantoolStore.call(self, name, *args)

            return wrap

@@ -208,16 +208,45 @@
 onfig):%0A
+        logger.debug(config)%0A
         
@@ -276,16 +276,16 @@
 ection(%0A
-
         
@@ -528,32 +528,50 @@
  datetime.now()%0A
+        import os%0A
         logger.d
@@ -568,35 +568,32 @@
   logger.debug('
-%7B%7D 
 Tarantool call b
@@ -604,28 +604,64 @@
 : %7B%7D
-'.format(start, name
+, pid: %7B%7D, user: %7B%7D'.format(name, os.getpid(), self.user
 ))%0A%0A
@@ -871,11 +871,8 @@
 ug('
-%7B%7D 
 Tara
@@ -912,13 +912,8 @@
 mat(
-end, 
 name

change debug log