00001 #ifndef VSF_LOGGING_H 00002 #define VSF_LOGGING_H 00003 00004 /* Forward delcarations */ 00005 struct mystr; 00006 struct vsf_session; 00007 00008 enum EVSFLogEntryType 00009 { 00010 kVSFLogEntryNull = 1, 00011 kVSFLogEntryDownload, 00012 kVSFLogEntryUpload, 00013 kVSFLogEntryMkdir, 00014 kVSFLogEntryLogin, 00015 kVSFLogEntryFTPInput, 00016 kVSFLogEntryFTPOutput, 00017 kVSFLogEntryConnection, 00018 kVSFLogEntryDelete, 00019 kVSFLogEntryRename, 00020 kVSFLogEntryRmdir, 00021 kVSFLogEntryChmod 00022 }; 00023 00024 /* vsf_log_init() 00025 * PURPOSE 00026 * Initialize the logging services, by opening a writable file descriptor to 00027 * the log file (should logging be enabled). 00028 * PARAMETERS 00029 * p_sess - the current session object 00030 */ 00031 void vsf_log_init(struct vsf_session* p_sess); 00032 00033 /* vsf_log_start_entry() 00034 * PURPOSE 00035 * Denote the start of a logged operation. Importantly, timing information 00036 * (if applicable) will be taken starting from this call. 00037 * PARAMETERS 00038 * p_sess - the current session object 00039 * what - the type of operation which just started 00040 */ 00041 void vsf_log_start_entry(struct vsf_session* p_sess, 00042 enum EVSFLogEntryType what); 00043 00044 /* vsf_log_entry_pending() 00045 * PURPOSE 00046 * Determine whether a log entry has been started and not yet closed. 00047 * RETURNS 00048 * 0 if no log entry is pending; 1 if one is. 00049 */ 00050 int vsf_log_entry_pending(struct vsf_session* p_sess); 00051 00052 /* vsf_log_do_log() 00053 * PURPOSE 00054 * Denote the end of a logged operation, specifying whether the operation 00055 * was successful or not. 00056 * PARAMETERS 00057 * p_sess - the current session object 00058 * succeeded - 0 for a failed operation, 1 for a successful operation 00059 */ 00060 void vsf_log_do_log(struct vsf_session* p_sess, int succeeded); 00061 00062 /* vsf_log_line() 00063 * PURPOSE 00064 * Logs a single line of information, without disturbing any pending log 00065 * operations (e.g. a download log spans a period of time). 00066 * This call must be used for any logging calls nested within a call to 00067 * the vsf_log_start_entry() function. 00068 * PARAMETERS 00069 * p_sess - the current session object 00070 * what - the type of operation to log 00071 * p_str - the string to log 00072 */ 00073 void vsf_log_line(struct vsf_session* p_sess, enum EVSFLogEntryType what, 00074 struct mystr* p_str); 00075 00076 /* vsf_log_failed_line() 00077 * PURPOSE 00078 * Same as vsf_log_line(), except that it logs the line as failed operation. 00079 * PARAMETERS 00080 * p_sess - the current session object 00081 * what - the type of operation to log 00082 * p_str - the string to log 00083 */ 00084 void vsf_log_failed_line(struct vsf_session* p_sess, enum EVSFLogEntryType what, 00085 struct mystr* p_str); 00086 00087 #endif /* VSF_LOGGING_H */ 00088