var _     = require('lodash');

var start = function(tag, args){
    var profile = {
        _target: tag,
        _start: (new Date()).toString(),
        _time: Date.now()
    };

    // data
    if(!_.isObject(args)){
        profile._un = args;
        return profile;
    }

    return _.assignIn(args, profile);
};

var land = function(args){
    var ts = Date.now();
    var profile = {
        _target: args._target || 'NONE',
        _network1: ts - args._time || 0,
        _fn: ts,
        _start: args._start
    };

    if(args._un !== undefined){
        return [profile, args._un];
    }

    delete args._target;
    delete args._time;
    delete args._start;

    return [profile, args];
};

var wrap_reply = function(p, reply){
    return function(data){
        var ts = Date.now();
        p._fn = ts - p._fn || 0;
        p._network2 = ts;

        reply([p, data]);
    };
};

var show = function(p){
    p._network2 = Date.now() - p._network2 || 0;
    console.log('Service: ' + (process.title || 'None') +
                ', Target: ' + p._target + 
                ', Start: ' + p._start +
                ', Network1: ' + p._network1 + 
                'ms, Fn: ' + p._fn + 
                'ms, Network2: ' + p._network2 + 
                'ms, Attach: ' + (process.attach || 'None'));
};

exports.start = start;
exports.land = land;
exports.wrap_reply = wrap_reply;
exports.show = show;
@@ -513,16 +513,53 @@
 s._start
+,%0A        _attach: args._attach %7C%7C ''
 %0A    %7D;%0A
@@ -705,16 +705,41 @@
 ._start;
+%0A    delete args._attach;
 %0A%0A    re
@@ -1341,23 +1341,18 @@
 : ' + (p
-rocess
 .
+_
 attach %7C

add _attach