Exemplo n.º 1
0
ret_t
cherokee_logger_ncsa_write_access (cherokee_logger_ncsa_t *logger, cherokee_connection_t *cnt)
{
	ret_t              ret;
	cherokee_buffer_t *log;

	/* Get the buffer
	 */
	cherokee_logger_writer_get_buf (logger->writer_access, &log);

	/* Add the new string
	 */
	ret = build_log_string (logger, cnt, log);
	if (unlikely (ret != ret_ok)) {
		goto error;
	}

	/* Flush buffer if full
	 */
	if (log->len < logger->writer_access->max_bufsize)
		goto ok;

	ret = cherokee_logger_writer_flush (logger->writer_access, true);
	if (unlikely (ret != ret_ok)) {
		goto error;
	}

ok:
	cherokee_logger_writer_release_buf (logger->writer_access);
	return ret_ok;

error:
	cherokee_logger_writer_release_buf (logger->writer_access);
	return ret_error;
}
Exemplo n.º 2
0
static ret_t
report_error (cherokee_buffer_t *buf)
{
	cherokee_logger_writer_t *writer = NULL;

	/* 1st Option, the thread variable
	 */
	writer = LOGGER_WRITER (CHEROKEE_THREAD_PROP_GET (thread_error_writer_ptr));

	/* 2nd, the default error logger
	 */
	if (writer == NULL) {
		writer = default_error_writer;
	}

	/* Last resource: Print it to stderr.
	 */
	if ((writer == NULL) || (! writer->initialized)) {
		fprintf (stderr, "%s\n", buf->buf);
		fflush (stderr);
		return ret_ok;
	}

	/* Do logging
	 */
	if (writer->initialized) {
		cherokee_buffer_t *writer_log = NULL;

		cherokee_logger_writer_get_buf (writer, &writer_log);
		cherokee_buffer_add_buffer (writer_log, buf);
		cherokee_logger_writer_flush (writer, true);
		cherokee_logger_writer_release_buf (writer);

		return ret_ok;
	}

	return ret_ok;
}