1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/mirrors-Molten

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
molten_log.h 3.6 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
silkCut Отправлено 27.09.2017 11:41 3f0c261
/**
* Copyright 2017 chuan-yun silkcutKs <silkcutbeta@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef MOLTEN_LOG_H
#define MOLTEN_LOG_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdint.h>
#include <limits.h>
#include <string.h>
#include <libgen.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <errno.h>
#include <fcntl.h>
#include <time.h>
#include <sys/types.h>
# if defined(__linux__)
#include <linux/limits.h>
# endif
#ifdef HAS_CURL
#include "curl/curl.h"
#include "curl/easy.h"
#endif
#ifdef HAS_KAFKA
#include "librdkafka/rdkafka.h"
#endif
#include "php.h"
#include "Zend/zend_llist.h"
#include "molten_log.h"
#include "molten_util.h"
#include "php7_wrapper.h"
#include "molten_slog.h"
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif
#define ALLOC_LOG_SIZE 1024
#define DEFAULT_LOG_DIR "/var/wd/log/tracing/php/"
#define DEFAULT_PREFIX "tracing"
#define LOG_FORMAT "%Y%m%d"
#define SINK_NONE 0
#define SINK_LOG 1
#define SINK_STD 2
#define SINK_SYSLOG 8 /* only for unx domain udp syslog */
#ifdef HAS_CURL
#define SINK_HTTP 4
#endif
#ifdef HAS_KAFKA
#define SINK_KAFKA 16
#endif
#define SPANS_WRAP 1<<0
#define SPANS_BREAK 1<<1
/* http sink */
/* current use php_stream or libcurl, we can check */
/* not use union, there has other fields */
typedef struct {
uint8_t type;
char *post_uri;
/*
struct {
php_stream_context *c;
php_stream *s;
} stream;
*/
} mo_http_sink_t;
/* chain log */
typedef struct {
uint8_t sink_type; /* log sink type */
uint8_t output_type; /* sink output type */
uint16_t support_type; /* sink support type */
char *host_name; /* link to global host name */
/* sink log file */
char *path;
char real_path[128]; /* log real path */
int tm_yday; /* day in year, get by ctime */
int fd;
ino_t ino;
char *format;
/* sink syslog */
char *unix_socket; /* unix domain udp syslog */
int sfd; /* unix domain syslog fd */
struct sockaddr_un server; /* server addr */
/* sink http */
char *post_uri; /* post uri */
/* kafka */
char *brokers; /* brokers */
char *topic; /* topic */
char *buf;
uint64_t total_size;
uint64_t alloc_size;
zval *spans;
} mo_chain_log_t;
/* function */
void mo_chain_log_init(mo_chain_log_t *log);
void mo_chain_log_ctor(mo_chain_log_t *log, char *host_name, char *log_path, long sink_type, long output_type, char *post_uri, char *syslog_unix_socket);
int mo_chain_log_set_file_path(char *new_path);
void mo_chain_log_add(mo_chain_log_t *log, char *buf, size_t size);
void mo_chain_log_flush(mo_chain_log_t *log);
void mo_chain_log_dtor(mo_chain_log_t *log);
void mo_chain_add_span(mo_chain_log_t *log, zval *span);
void mo_log_write(mo_chain_log_t *log, char *bytes, int size);
#ifdef HAS_CURL
void send_data_by_http(char *post_uri, char *post_data);
#endif
#endif

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/mirrors-Molten.git
git@api.gitlife.ru:oschina-mirror/mirrors-Molten.git
oschina-mirror
mirrors-Molten
mirrors-Molten
master