comparison src/log.h @ 10822:5c5120837bab

[gaim-migrate @ 12484] sf patch #1180568, from Kevin Stange Expose Gaim Common Logger Functions committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Thu, 14 Apr 2005 03:45:39 +0000
parents d087e928ffd1
children 8d2007d738d5
comparison
equal deleted inserted replaced
10821:5533f3131582 10822:5c5120837bab
32 * DATA STRUCTURES ************************************** 32 * DATA STRUCTURES **************************************
33 ********************************************************/ 33 ********************************************************/
34 34
35 typedef struct _GaimLog GaimLog; 35 typedef struct _GaimLog GaimLog;
36 typedef struct _GaimLogLogger GaimLogLogger; 36 typedef struct _GaimLogLogger GaimLogLogger;
37 typedef struct _GaimLogCommonLoggerData GaimLogCommonLoggerData;
37 38
38 typedef enum { 39 typedef enum {
39 GAIM_LOG_IM, 40 GAIM_LOG_IM,
40 GAIM_LOG_CHAT, 41 GAIM_LOG_CHAT,
41 GAIM_LOG_SYSTEM 42 GAIM_LOG_SYSTEM
105 GaimLogLogger *logger; /**< The logging mechanism this log 106 GaimLogLogger *logger; /**< The logging mechanism this log
106 is to use */ 107 is to use */
107 void *logger_data; /**< Data used by the log logger */ 108 void *logger_data; /**< Data used by the log logger */
108 }; 109 };
109 110
111 /**
112 * A common logger_data struct containing a file handle and path, as well
113 * as a pointer to something else for additional data.
114 */
115 struct _GaimLogCommonLoggerData {
116 char *path;
117 FILE *file;
118 void *extra_data;
119 };
110 120
111 #ifdef __cplusplus 121 #ifdef __cplusplus
112 extern "C" { 122 extern "C" {
113 #endif 123 #endif
114 124
180 * @return A sorted list of GaimLogs 190 * @return A sorted list of GaimLogs
181 */ 191 */
182 GList *gaim_log_get_system_logs(GaimAccount *account); 192 GList *gaim_log_get_system_logs(GaimAccount *account);
183 193
184 /** 194 /**
185 * Returns the size of a log 195 * Returns the size of a log
186 * 196 *
187 * @param log The log 197 * @param log The log
188 * @return The size of the log, in bytes 198 * @return The size of the log, in bytes
189 */ 199 */
190 int gaim_log_get_size(GaimLog *log); 200 int gaim_log_get_size(GaimLog *log);
198 * @return The size in bytes 208 * @return The size in bytes
199 */ 209 */
200 int gaim_log_get_total_size(GaimLogType type, const char *name, GaimAccount *account); 210 int gaim_log_get_total_size(GaimLogType type, const char *name, GaimAccount *account);
201 211
202 /** 212 /**
213 * Returns the default logger directory Gaim uses for a given account
214 * and username. This would be where Gaim stores logs created by
215 * the built-in text or HTML loggers.
216 *
217 * @param type The type of the log.
218 * @param name The name of the log.
219 * @param account The account.
220 * @return The default logger directory for Gaim.
221 */
222 char *gaim_log_get_log_dir(GaimLogType type, const char *name, GaimAccount *account);
223
224 /**
203 * Implements GCompareFunc 225 * Implements GCompareFunc
204 * 226 *
205 * @param y A GaimLog 227 * @param y A GaimLog
206 * @param z Another GaimLog 228 * @param z Another GaimLog
207 * @return A value as specified by GCompareFunc 229 * @return A value as specified by GCompareFunc
208 */ 230 */
209 gint gaim_log_compare(gconstpointer y, gconstpointer z); 231 gint gaim_log_compare(gconstpointer y, gconstpointer z);
232 /*@}*/
233
234 /******************************************/
235 /** @name Common Logger Functions */
236 /******************************************/
237 /*@{*/
238
239 /**
240 * Opens a new log file in the standard Gaim log location
241 * with the given file extension, named for the current time,
242 * for writing. If a log file is already open, the existing
243 * file handle is retained. The log's logger_data value is
244 * set to a GaimLogCommonLoggerData struct containing the log
245 * file handle and log path.
246 *
247 * @param log The log to write to.
248 * @param time The time of the item being logged.
249 * @param ext The file extension to give to this log file.
250 */
251 void gaim_log_common_writer(GaimLog *log, time_t time, const char *ext);
252
253 /**
254 * Returns a sorted GList of GaimLogs of the requested type.
255 * This function should only be used with logs that are written
256 * with gaim_log_common_writer().
257 *
258 * @param type The type of the logs being listed.
259 * @param name The name of the log.
260 * @param account The account of the log.
261 * @param ext The file extension this log format uses.
262 * @param logger A reference to the logger struct for this log.
263 *
264 * @return A sorted GList of GaimLogs matching the parameters.
265 */
266 GList *gaim_log_common_lister(GaimLogType type, const char *name,
267 GaimAccount *account, const char *ext,
268 GaimLogLogger *logger);
269
270 /**
271 * Returns the size of a given GaimLog.
272 * This function should only be used with logs that are written
273 * with gaim_log_common_writer().
274 *
275 * @param log The GaimLog to size.
276 *
277 * @return An integer indicating the size of the log in bytes.
278 */
279 int gaim_log_common_sizer(GaimLog *log);
210 /*@}*/ 280 /*@}*/
211 281
212 /******************************************/ 282 /******************************************/
213 /** @name Logger Functions */ 283 /** @name Logger Functions */
214 /******************************************/ 284 /******************************************/