'''
The function cache system allows for data to be stored on the master so it
can be easily read by other minions
'''

# Import salt libs
import salt.crypt
import salt.payload


def _auth():
    '''
    Return the auth object
    '''
    if not 'mine.auth' in __context__:
        __context__['mine.auth'] = salt.crypt.SAuth(__opts__)
    return __context__['mine.auth']


def update():
    '''
    Execute the configured functions and send the data back up to the master
    The functions to be executed are merged from the master config, pillar and
    minion config under the option "function_cache":

    .. code-block:: yaml

        mine_functions:
          network.ip_addrs:
            - eth0
          disk.usage: []

    The function cache will be populated with information from executing these
    functions

    CLI Example::

        salt '*' mine.update
    '''
    m_data = __salt__['config.option']('mine_functions', {})
    data = {}
    for func in m_data:
        if not func in __salt__:
            continue
        try:
            if m_data[func] and isinstance(m_data[func], dict):
                data[func] = __salt__[func](**m_data[func])
            elif f_data[func] and isinstance(m_data[func], list):
                data[func] = __salt__[func](*m_data[func])
            else:
                data[func] = __salt__[func]()
        except Exception:
            continue
    load = {
            'cmd': '_mine',
            'data': data,
            'id': __opts__['id']
            }
    serial = salt.payload.Serial(__opts__)
    sreq = salt.payload.SREQ(__opts__['master_uri'])
    auth = _auth()
    try:
        sreq.send('aes', auth.crypticle.dumps(load), 1, 0)
    except Exception:
        pass


def get(tgt, fun, expr_form='glob'):
    '''
    Get data from the mine based on the target, function and expr_form

    CLI Example::

        salt '*' mine.get '*' network.interfaces
    '''
    auth = _auth()
    load = {
            'cmd': '_mine_get',
            'id': __opts__['id'],
            'tgt': tgt,
            'fun': fun,
            'expr_form': expr_form,
            }
    sreq = salt.payload.SREQ(__opts__['master_uri'])
    return sreq.send('aes', auth.crypticle.dumps(load))

@@ -113,16 +113,53 @@
 ns%0A'''%0A%0A
+# Import python libs%0Aimport logging%0A%0A
 # Import
@@ -209,16 +209,51 @@
 yload%0A%0A%0A
+log = logging.getLogger(__name__)%0A%0A
 def _aut
@@ -1072,24 +1072,199 @@
 n __salt__:%0A
+            log.error(%0A                    'Function %7B0%7D in mine_functions not available'.format(%0A                        func%0A                        )%0A                    )%0A
             
@@ -1268,24 +1268,24 @@
    continue%0A
-
         try:
@@ -1426,17 +1426,17 @@
    elif 
-f
+m
 _data%5Bfu
@@ -1598,16 +1598,16 @@
 func%5D()%0A
-
         
@@ -1616,32 +1616,211 @@
 cept Exception:%0A
+            log.error(%0A                    'Function %7B0%7D in mine_functions failed to execute'.format(%0A                        func%0A                        )%0A                    )%0A
             cont

Add logging to min.update