00001 /*============================================================================= 00002 00003 Copyright 2008 Francois Laupretre (francois@tekwire.net) 00004 00005 Licensed under the Apache License, Version 2.0 (the "License"); 00006 you may not use this file except in compliance with the License. 00007 You may obtain a copy of the License at 00008 00009 http://www.apache.org/licenses/LICENSE-2.0 00010 00011 Unless required by applicable law or agreed to in writing, software 00012 distributed under the License is distributed on an "AS IS" BASIS, 00013 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 See the License for the specific language governing permissions and 00015 limitations under the License. 00016 =============================================================================*/ 00021 /* This file contains the log manager API */ 00022 00023 #ifndef __LOGMANAGER_H 00024 #define __LOGMANAGER_H 00025 00026 #include <apr.h> 00027 #include <apr_file_io.h> 00028 #include <apr_time.h> 00029 00030 #if APR_HAVE_STRING_H 00031 #include <string.h> 00032 #endif 00033 00034 /*----------------------------------------------*/ 00035 00036 #ifndef NOW 00037 00055 typedef apr_time_t TIMESTAMP; 00056 00063 #define NOW (TIMESTAMP)0 00064 #endif 00065 00066 /*===== LOGMANAGER option flags =====*/ 00067 00070 #define LMGR_ACTIVE_LINK 0x01 00071 00074 #define LMGR_BACKUP_LINKS 0x02 00075 00078 #define LMGR_HARD_LINKS 0x04 00079 00086 #define LMGR_IGNORE_EOL 0x08 00087 00102 #define LMGR_IGNORE_ENOSPC 0x10 00103 00106 #define LMGR_PID_FILE 0x20 00107 00108 /*----------------------------------------------*/ 00109 00112 #define LOGMANAGER_API_VERSION 3 00113 00114 /*----------------------------------------------*/ 00118 typedef struct 00119 { 00120 00121 unsigned int api_version; 00122 char *base_path; 00126 unsigned int flags; 00127 struct 00128 { 00129 char *type; 00130 char *level; 00133 } compress; 00134 apr_off_t file_maxsize; 00139 apr_off_t global_maxsize; 00141 unsigned int keep_count; 00143 apr_fileperms_t create_mode; 00148 char *debug_file; 00150 int debug_level; 00152 char *rotate_cmd; 00153 /* API version 1 stops here */ 00154 TIMESTAMP rotate_delay; 00156 TIMESTAMP purge_delay; 00158 /* API version 2 stops here */ 00159 char *log_path; 00162 /* API version 3 stops here */ 00163 } LOGMANAGER_OPTIONS; 00164 00165 /*----------------------------------------------*/ 00166 00167 #ifdef IN_LMGR_LIB 00168 #include "../include/logmanager_int.h" 00169 #else 00170 00175 typedef struct { int dummy; } LOGMANAGER; /* Opaque to client */ 00176 #endif 00177 00178 /*----------------------------------------------*/ 00179 /* Functions */ 00180 00200 extern LOGMANAGER *new_logmanager(LOGMANAGER_OPTIONS *opts); 00201 00202 /*----------------------------------------------*/ 00211 extern void logmanager_destroy(LOGMANAGER *mp); 00212 00213 /*----------------------------------------------*/ 00223 extern void logmanager_open(LOGMANAGER *mp,TIMESTAMP t); 00224 00225 /*----------------------------------------------*/ 00235 extern void logmanager_close(LOGMANAGER *mp); 00236 00237 /*----------------------------------------------*/ 00247 extern void logmanager_write(LOGMANAGER *mp, const char *buf, apr_off_t size 00248 , TIMESTAMP t); 00249 00250 /*----------------------------------------------*/ 00263 extern void logmanager_flush(LOGMANAGER *mp); 00264 00265 /*----------------------------------------------*/ 00276 extern void logmanager_rotate(LOGMANAGER *mp,TIMESTAMP t); 00277 00278 /*----------------------------------------------*/ 00287 extern char *logmanager_compression_list(void); 00288 00289 /*----------------------------------------------*/ 00297 extern char *logmanager_version(void); 00298 00299 /*----------------------------------------------*/ 00309 extern void logmanager_display_stats(LOGMANAGER *mp); 00310 00311 /*----------------------------------------------*/ 00313 #endif /* __LOGMANAGER_H */