Callback froma the log API when data arrives
11011
def _stab_log_data(self, timestamp, data, logconf):
        """"""
        print('[%d][%s]: %s' % (timestamp, logconf.name, data))
281656
def log_to_api(self):
        
        if self.entries:
            try:
                headers = {'Content-Type': 'application/json'}
                self.session.post('/v2/logs/app', headers=headers, json=self.entries)
                # self.entries = []  # clear entries
            except Exception:
                # best effort on api logging
                pass
23248
def create_log(self):
        """"""
        return EventLog(
            self.networkapi_url,
            self.user,
            self.password,
            self.user_ldap)
971368
def callback(self, filename, lines, **kwargs):
        """"""
        timestamp = self.get_timestamp(**kwargs)
        if kwargs.get('timestamp', False):
            del kwargs['timestamp']

        for line in lines:
            try:
                import warnings
                with warnings.catch_warnings():
                    warnings.simplefilter('error')
                    #produce message
                    if self._key is None:
                        response = self._prod.send_messages(self._kafka_config['topic'], self.format(filename, line, timestamp, **kwargs))
                    else:
                        response = self._prod.send_messages(self._kafka_config['topic'], self._key, self.format(filename, line, timestamp, **kwargs))

                    if response:
                        if response[0].error:
                            self._logger.info('message error: {0}'.format(response[0].error))
                            self._logger.info('message offset: {0}'.format(response[0].offset))

            except Exception as e:
                try:
                    self._logger.error('Exception caught sending message/s : ' + str(e))
                    raise TransportException(e.strerror)
                except AttributeError:
                    raise TransportException('Unspecified exception encountered')
1088262
def log_this(cls, f):
        """"""
        @functools.wraps(f)
        def wrapper(*args, **kwargs):
            user_id = None
            if g.user:
                user_id = g.user.get_id()
            d = request.form.to_dict() or {}

            # request parameters can overwrite post body
            request_params = request.args.to_dict()
            d.update(request_params)
            d.update(kwargs)

            slice_id = d.get('slice_id')
            dashboard_id = d.get('dashboard_id')

            try:
                slice_id = int(
                    slice_id or json.loads(d.get('form_data')).get('slice_id'))
            except (ValueError, TypeError):
                slice_id = 0

            stats_logger.incr(f.__name__)
            start_dttm = datetime.now()
            value = f(*args, **kwargs)
            duration_ms = (datetime.now() - start_dttm).total_seconds() * 1000

            # bulk insert
            try:
                explode_by = d.get('explode')
                records = json.loads(d.get(explode_by))
            except Exception:
                records = [d]

            referrer = request.referrer[:1000] if request.referrer else None
            logs = []
            for record in records:
                try:
                    json_string = json.dumps(record)
                except Exception:
                    json_string = None
                log = cls(
                    action=f.__name__,
                    json=json_string,
                    dashboard_id=dashboard_id,
                    slice_id=slice_id,
                    duration_ms=duration_ms,
                    referrer=referrer,
                    user_id=user_id)
                logs.append(log)

            sesh = db.session()
            sesh.bulk_save_objects(logs)
            sesh.commit()
            return value

        return wrapper
1310232
function log(key, result, done) {
    var storage = this;
    
    // store result as JSON serialized string
    result = JSON.stringify(result);

    // generate result key from task key
    key = key + "-result";
    
    // first add the key to the log
    this.redis().rpush(this.logKey(), key, function(err) {
        if (err) done(err);

        // now store result data
        else storage.redis().set(key, result, done);
    });
}
1236420
def receive(self, data, api_context):
        """"""
        self.log.debug(f"Putting data on the pipeline: {data}")
        result = {
            "api_contexts": self.api_contexts,
            "api_context": api_context,
            "strategy": dict(),  # Shared strategy data
            "result": data,
            "log_level": api_context["log_level"],
        }
        self.strat.execute(self.strategy_context_schema().load(result).data)
503744
def process_log_event(event, context):
    
    init()
    # Grab the actual error log payload
    serialized = event['awslogs'].pop('data')
    data = json.loads(zlib.decompress(
        base64.b64decode(serialized), 16 + zlib.MAX_WBITS))
    msg = get_sentry_message(config, data)
    if msg is None:
        return
    if config['sentry_dsn']:
        # Deliver directly to sentry
        send_sentry_message(config['sentry_dsn'], msg)
    elif config['sentry_sqs']:
        # Delivery indirectly via sqs
        sqs.send_message(
            QueueUrl=config['sentry_sqs'])
41364
def on_log(self):
        # type: () -> Callable
        
        def decorator(handler):
            # type: (Callable) -> Callable
            self.client.on_log = handler
            return handler

        return decorator
377973
def print_callback(msg):
    """"""
    json.dump(msg, stdout)
    stdout.write('\n')
    stdout.flush()
844315
def a_message_callback(ctx):
    """"""
    message = ctx.ctrl.after.strip().splitlines()[-1]
    ctx.device.chain.connection.emit_message(message, log_level=logging.INFO)
    return True
913227
function(loggingEvent) {
		log4jsLogger.trace("> AjaxAppender.append");
	
		if (this.loggingEventMap.length() <= this.threshold || this.isInProgress === true) {
			this.loggingEventMap.push(loggingEvent);
		}
		
		if(this.loggingEventMap.length() >= this.threshold && this.isInProgress === false) {
			//if threshold is reached send the events and reset current threshold
			this.send();
		}
		
		log4jsLogger.trace("< AjaxAppender.append");
	}
1057312
function _logProgress(req) {
  req.on('response', function(resp) {
    var len = parseInt(resp.headers['content-length'], 10),
      bar = new ProgressBar('[:bar]', {
        complete: '=',
        incomplete: ' ',
        total: len,
        width: 100, // just use 100
      });

    req.on('data', function(chunk) {
      bar.tick(chunk.length);
    });
  });

  req.on('error', function(err) {
    console.log(err);
    _log('error', 'failed to download node sources,');
    process.exit(1);
  });

  return req;
}
60143
def _handle_callback(self, data):
        """"""

        cb_id = data.get("id")
        args = data.get("args")
        event = self.__callbacks.pop(cb_id, None)
        if not event:
            return
        if not args:
            event.put(args)
            return
        err, info = args
        if err is None:
            event.put(info)
        else:
            LOGGER.warning("Callback returned error of %s", str(err))
            event.put(err)
93716
function log(conn, name, message) {
    if (! show_sql) {
        return;
    }
    function padding(n, len) {
        var
            s = n.toString(),
            p = len - s.length;
        while (p > 0) {
            s = '0' + s;
            p--;
        }
        return s;
    }
    var
        d = new Date(),
        h = d.getHours(),
        m = d.getMinutes(),
        s = d.getSeconds(),
        ms = d.getMilliseconds(),
        date = padding(h, 2) + ':' + padding(m, 2) + ':' + padding(s, 2) + '.' + padding(ms, 3);
    console.log(date + (conn ? (' [Warp@' + conn.__objectId + '] ') : ' ') + name + ': ' + message);
}
1122480
def logs(self, container=None, pretty=None, previous=False,
             since_seconds=None, since_time=None, timestamps=False,
             tail_lines=None, limit_bytes=None):
        
        log_call = "log"
        params = {}
        if container is not None:
            params["container"] = container
        if pretty is not None:
            params["pretty"] = pretty
        if previous:
            params["previous"] = "true"
        if since_seconds is not None and since_time is None:
            params["sinceSeconds"] = int(since_seconds)
        elif since_time is not None and since_seconds is None:
            params["sinceTime"] = since_time
        if timestamps:
            params["timestamps"] = "true"
        if tail_lines is not None:
            params["tailLines"] = int(tail_lines)
        if limit_bytes is not None:
            params["limitBytes"] = int(limit_bytes)

        query_string = urlencode(params)
        log_call += "?{}".format(query_string) if query_string else ""
        kwargs = {
            "version": self.version,
            "namespace": self.namespace,
            "operation": log_call,
        }
        r = self.api.get(**self.api_kwargs(**kwargs))
        r.raise_for_status()
        return r.text
278135
def _log(self):
        """"""
        self._log_platform()
        self._log_app_data()
        self._log_python_version()
        self._log_tcex_version()
        self._log_tc_proxy()