5 Star 6 Fork 3

Gitee 极速下载 / Molten

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/chuan-yun/Molten
克隆/下载
molten_log.h 3.60 KB
一键复制 编辑 原始数据 按行查看 历史
silkCut 提交于 2017-09-27 16:41 . add debg
/**
* 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
PHP
1
https://gitee.com/mirrors/Molten.git
git@gitee.com:mirrors/Molten.git
mirrors
Molten
Molten
master

搜索帮助