ngx_http_log_module.c

数据结构

typedef struct {
void **main_conf;
void **srv_conf;
void **loc_conf;
} ngx_http_conf_ctx_t;

typedef struct ngx_http_log_op_s ngx_http_log_op_t;

typedef u_char *(*ngx_http_log_op_run_pt) (ngx_http_request_t *r, u_char *buf,
ngx_http_log_op_t *op);

typedef size_t (*ngx_http_log_op_getlen_pt) (ngx_http_request_t *r,
uintptr_t data);

struct ngx_http_log_op_s {
size_t len;
ngx_http_log_op_getlen_pt getlen;
ngx_http_log_op_run_pt run;
uintptr_t data;
};

typedef struct {
ngx_str_t name;
ngx_array_t *flushes;
ngx_array_t *ops; /* array of ngx_http_log_op_t */
} ngx_http_log_fmt_t;

typedef struct {
ngx_array_t formats; /* array of ngx_http_log_fmt_t */
ngx_uint_t combined_used; /* unsigned combined_used:1 */
} ngx_http_log_main_conf_t;

typedef struct {
u_char *start;
u_char *pos;
u_char *last;

ngx_event_t *event;
ngx_msec_t flush;
ngx_int_t gzip;
} ngx_http_log_buf_t;

typedef struct {
ngx_array_t *lengths;
ngx_array_t *values;
} ngx_http_log_script_t;

typedef struct {
ngx_open_file_t *file;
ngx_http_log_script_t *script;
time_t disk_full_time;
time_t error_log_time;
ngx_http_log_fmt_t *format;
} ngx_http_log_t;

typedef struct {
ngx_array_t *logs; /* array of ngx_http_log_t */

ngx_open_file_cache_t *open_file_cache;
time_t open_file_cache_valid;
ngx_uint_t open_file_cache_min_uses;

ngx_uint_t off; /* unsigned off:1 */
} ngx_http_log_loc_conf_t;

typedef struct {
ngx_str_t name;
size_t len;
ngx_http_log_op_run_pt run;
} ngx_http_log_var_t;

typedef struct {
ngx_str_t name;
void *(*create_conf)(ngx_cycle_t *cycle);
char *(*init_conf)(ngx_cycle_t *cycle, void *conf);
} ngx_core_module_t;

typedef struct {
ngx_int_t (*preconfiguration)(ngx_conf_t *cf);
ngx_int_t (*postconfiguration)(ngx_conf_t *cf);

void *(*create_main_conf)(ngx_conf_t *cf);
char *(*init_main_conf)(ngx_conf_t *cf, void *conf);

void *(*create_srv_conf)(ngx_conf_t *cf); char *(*merge_srv_conf)(ngx_conf_t *cf, void *prev, void *conf);

void *(*create_loc_conf)(ngx_conf_t *cf);
char *(*merge_loc_conf)(ngx_conf_t *cf, void *prev, void *conf);
} ngx_http_module_t;

static ngx_http_module_t ngx_http_log_module_ctx = {
NULL, /* preconfiguration */
ngx_http_log_init, /* postconfiguration */

ngx_http_log_create_main_conf, /* create main configuration */
NULL, /* init main configuration */

NULL, /* create server configuration */
NULL, /* merge server configuration */

ngx_http_log_create_loc_conf, /* create location configuration */
ngx_http_log_merge_loc_conf /* merge location configuration */
};

#define NGX_MODULE_V1 0, 0, 0, 0, 0, 0, 1
#define NGX_MODULE_V1_PADDING 0, 0, 0, 0, 0, 0, 0, 0

struct ngx_module_s {
ngx_uint_t ctx_index;
ngx_uint_t index;

ngx_uint_t spare0;
ngx_uint_t spare1;
ngx_uint_t spare2;
ngx_uint_t spare3;

ngx_uint_t version;

void *ctx;
ngx_command_t *commands;
ngx_uint_t type;

ngx_int_t (*init_master)(ngx_log_t *log);
ngx_int_t (*init_module)(ngx_cycle_t *cycle);

ngx_int_t (*init_process)(ngx_cycle_t *cycle);
ngx_int_t (*init_thread)(ngx_cycle_t *cycle);
void (*exit_thread)(ngx_cycle_t *cycle);
void (*exit_process)(ngx_cycle_t *cycle);

void (*exit_master)(ngx_cycle_t *cycle);

uintptr_t spare_hook0;
uintptr_t spare_hook1;
uintptr_t spare_hook2;
uintptr_t spare_hook3;
uintptr_t spare_hook4;
uintptr_t spare_hook5;
uintptr_t spare_hook6;
uintptr_t spare_hook7;
};

struct ngx_command_s {
ngx_str_t name;
ngx_uint_t type;
char *(*set)(ngx_conf_t *cf, ngx_command_t *cmd, void *conf);
ngx_uint_t conf;
ngx_uint_t offset;
void *post;
};

http:

typedef struct {
ngx_array_t servers; /* ngx_http_core_srv_conf_t */

ngx_http_phase_engine_t phase_engine;

ngx_hash_t headers_in_hash;

ngx_hash_t variables_hash;
ngx_array_t variables; /* ngx_http_variable_t */ ngx_uint_t ncaptures;

ngx_uint_t server_names_hash_max_size;
ngx_uint_t server_names_hash_bucket_size;

ngx_uint_t variables_hash_max_size; ngx_uint_t variables_hash_bucket_size;

ngx_hash_keys_arrays_t *variables_keys;

ngx_array_t *ports;
ngx_uint_t try_files; /* unsigned try_files:1 */

ngx_http_phase_t phases[NGX_HTTP_LOG_PHASE + 1];
} ngx_http_core_main_conf_t;

typedef struct {
unsigned len:28;

unsigned valid:1;
unsigned no_cacheable:1;
unsigned not_found:1;
unsigned escape:1;

u_char *data;
} ngx_variable_value_t;

struct ngx_buf_s {
u_char *pos;
u_char *last;
off_t file_pos;
off_t file_last;

u_char *start; /* start of buffer */
u_char *end; /* end of buffer */ ngx_buf_tag_t tag;
ngx_file_t *file;
ngx_buf_t *shadow;

/* the buf's content could be changed */
unsigned temporary:1;

/*
* the buf's content is in a memory cache or in a read only memory
* and must not be changed
*/
unsigned memory:1;

/* the buf's content is mmap()ed and must not be changed */
unsigned mmap:1;

unsigned recycled:1;
unsigned in_file:1;
unsigned flush:1;
unsigned sync:1;
unsigned last_buf:1;
unsigned last_in_chain:1;

unsigned last_shadow:1;
unsigned temp_file:1;

/* STUB */ int num;
};

struct ngx_chain_s {
ngx_buf_t *buf;
ngx_chain_t *next;
};

nginx 日志模块的更多相关文章

  1. nginx日志模块、事件模块

    日志模块 1.access_log指令 语法: access_log path [format [buffer=size [flush=time]]]; access_log logs/access. ...

  2. nginx日志模块及日志定时切割

    一:作用 Ngx_http_log_module:定义日志格式,并且以指定的格式保存. 二:示例配置 log_format compression '$remote_addr - $remote_us ...

  3. nginx日志模块与HTTP过滤模块与sub模块修改返回内容

    日志格式使用指令 指令介绍 Syntax: log_format name [escape=default|json|none] string ...; Default: log_format com ...

  4. nginx 配置文件与日志模块

    内容概要 Nginx 虚拟主机 基于多 IP 的方式 基于多端口的方式 基于多域名的方式 日志配置(日志格式详解) Nginx 访问控制模块(可以去 Nginx.org 文档 documentatio ...

  5. nginx日志分析利器GoAccess

    面试的时候一定会被面到的问题是:给出web服务器的访问日志,请写一个脚本来统计访问前10的IP有哪些?访问前10的请求有哪些?当你领略过goaccess之后,你就明白,这些问题,除了考验你的脚本背诵记 ...

  6. elk系列3之通过json格式采集Nginx日志

    preface 公司采用的LNMP平台,跑着挺多nginx,所以可以利用elk好好分析nginx的日志.下面就聊聊它吧. 下面的所有操作都在linux-node2上操作 安装Nginx nginx是开 ...

  7. Nginx日志切割,以及脚本上传nginx的切割日志

    一:日志切割步骤 命令都在root下进行 1.创建目录 mkdir -p /etc/opt/modules/bin ## 创建文件夹 2.上传cut 3.观察目录 4.修改的cut文件 5.检测 需要 ...

  8. mac下Nginx+lua模块编译安装

    Nginx的nb之处就不说了,lua也是一个小巧的脚本语言,由标准C编写而成,几乎可以运行在所有的平台上,也非常强大,其他特性请自行度娘.nginx_lua_module是由淘宝的工程师清无(王晓哲) ...

  9. nginx日志配置[转]

     * * * sh /home/zyf/sh/cut_nginx_log.sh 这样就每天的0点1分把nginx日志重命名为日期格式,并重新生成今天的新日志文件。 日志对于统计排错来说非常有利的。本文 ...

随机推荐

  1. Web—13-判断网站请求来自手机还是pc浏览器

    判断网站请求来自手机还是pc浏览器 #判断网站来自mobile还是pc def checkMobile(request): """ demo : @app.route(' ...

  2. Python 基础 高阶函数

    python 把函数作为参数 如果传入abs 作为参数 def add(x,y,y): return f(x) + f(y) add(-5,9,abs) 根据函数的定义,函数执行的代码实际上是. ab ...

  3. 【Java项目】GUI图形用户界面(不断更新中!)

    <目录> 1 创建一个简单的窗体 2 如何进行事件监听 (1) 按钮监听 (2) 键盘监听 (3) 鼠标监听 3 容器 (1) 创建一个简单的对话框 (2) 创建一个简单的模态对话框 (3 ...

  4. ERP系统和MES系统的区别

    公司说最近要上一套erp系统,说让我比较一下,erp系统哪个好,还有mes系统,我们适合上哪个系统,其实我还真的不太懂,刚接触erp跟mes的时候,对于两者的概念总是傻傻分不清楚,总是觉得既然都是为企 ...

  5. sublime Text3安装 markdownediting 报错 解决记录

    看了一下官方文档,也是醉了,都怪自己的无知. 在安装时候不要打开.md的文件,因为你里面有可能有一些语法错误,所以会导致报错. 解决方法关闭其他文件,在重新安装! 官方解释: 参考文档:Trouble ...

  6. python 用户注册用户名

    实现用户注册网站,编辑用户名时判断是否已经存在: 若存在则提示“The name you used have already existed,please change your name” 若不存在 ...

  7. Easy-UI中datebox的默认显示当前日期的最简单的两种方法

    在中有一个Today按钮就是实现显示当前日期,所以我们在src/jquery.datebox.js文件中可以找到currentText:'Today'.所以我们可以使用'currentText'和'T ...

  8. Linux下安装spf13-vim

    前言 spf13-vim是一个集成多个非常好用的vim插件的集合,对于在众多插件中不知道该怎么做选择,并且为各个插件的安装而头疼的我们提供了一个很好的工具,让我仅仅需要安装和配置一次就能拥有众多优秀的 ...

  9. ACM1019:Least Common Multiple

    Problem Description The least common multiple (LCM) of a set of positive integers is the smallest po ...

  10. spark 例子wordcount topk

    spark 例子wordcount topk 例子描述: [单词计算wordcount ] [词频排序topk] 单词计算在代码方便很简单,基本大体就三个步骤 拆分字符串 以需要进行记数的单位为K,自 ...