Go to the documentation of this file.00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 #ifndef LOG_UTILS_H
00024 #define LOG_UTILS_H
00025 
00026 #include "time.h"
00027 
00028 #include "libts.h"
00029 #include "Arena.h"
00030 
00031 namespace LogUtils
00032 {
00033   enum AlarmType
00034   {
00035     LOG_ALARM_ERROR = 0,
00036     LOG_ALARM_WARNING,
00037     LOG_ALARM_N_TYPES
00038   };
00039 
00040   static inline long timestamp() { return (long)time(0); }
00041 
00042   int timestamp_to_str(long timestamp, char *buf, int size);
00043   char *timestamp_to_netscape_str(long timestamp);
00044   char *timestamp_to_date_str(long timestamp);
00045   char *timestamp_to_time_str(long timestamp);
00046   unsigned ip_from_host(char *host);
00047   void manager_alarm(AlarmType alarm_type, const char *msg, ...) TS_PRINTFLIKE(2, 3);
00048   void strip_trailing_newline(char *buf);
00049   char *escapify_url(Arena * arena, char *url, size_t len_in, int *len_out, char *dst=NULL, size_t dst_size=0, const unsigned char *map=NULL);
00050   char *int64_to_str(char *buf, unsigned int buf_size, int64_t val, unsigned int *total_chars, unsigned int req_width=0, char pad_char='0');
00051   void remove_content_type_attributes(char *type_str, int *type_len);
00052   int timestamp_to_hex_str(unsigned timestamp, char *str, size_t len, size_t * n_chars = 0);
00053   int seconds_to_next_roll(time_t time_now, int rolling_offset, int rolling_interval);
00054   int file_is_writeable(const char *full_filename,
00055                                off_t * size_bytes = 0,
00056                                bool * has_size_limit = 0, uint64_t * current_size_limit_bytes = 0);
00057 
00058 };
00059 #endif