1/*
2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License as
4 * published by the Free Software Foundation; either version 2 of
5 * the License, or (at your option) any later version.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
15 * MA 02111-1307 USA
16 */
17#ifndef VSF_LOGGING_H
18#define VSF_LOGGING_H
19
20/* Forward delcarations */
21struct mystr;
22struct vsf_session;
23
24enum EVSFLogEntryType
25{
26  kVSFLogEntryNull = 1,
27  kVSFLogEntryDownload,
28  kVSFLogEntryUpload,
29  kVSFLogEntryMkdir,
30  kVSFLogEntryLogin,
31  kVSFLogEntryFTPInput,
32  kVSFLogEntryFTPOutput,
33  kVSFLogEntryConnection,
34  kVSFLogEntryDelete,
35  kVSFLogEntryRename,
36  kVSFLogEntryRmdir,
37  kVSFLogEntryChmod
38};
39
40/* vsf_log_init()
41 * PURPOSE
42 * Initialize the logging services, by opening a writable file descriptor to
43 * the log file (should logging be enabled).
44 * PARAMETERS
45 * p_sess       - the current session object
46 */
47void vsf_log_init(struct vsf_session* p_sess);
48
49/* vsf_log_start_entry()
50 * PURPOSE
51 * Denote the start of a logged operation. Importantly, timing information
52 * (if applicable) will be taken starting from this call.
53 * PARAMETERS
54 * p_sess       - the current session object
55 * what         - the type of operation which just started
56 */
57void vsf_log_start_entry(struct vsf_session* p_sess,
58                         enum EVSFLogEntryType what);
59
60/* vsf_log_entry_pending()
61 * PURPOSE
62 * Determine whether a log entry has been started and not yet closed.
63 * RETURNS
64 * 0 if no log entry is pending; 1 if one is.
65 */
66int vsf_log_entry_pending(struct vsf_session* p_sess);
67
68/* vsf_log_do_log()
69 * PURPOSE
70 * Denote the end of a logged operation, specifying whether the operation
71 * was successful or not.
72 * PARAMETERS
73 * p_sess       - the current session object
74 * succeeded    - 0 for a failed operation, 1 for a successful operation
75 */
76void vsf_log_do_log(struct vsf_session* p_sess, int succeeded);
77
78/* vsf_log_line()
79 * PURPOSE
80 * Logs a single line of information, without disturbing any pending log
81 * operations (e.g. a download log spans a period of time).
82 * This call must be used for any logging calls nested within a call to
83 * the vsf_log_start_entry() function.
84 * PARAMETERS
85 * p_sess       - the current session object
86 * what         - the type of operation to log
87 * p_str        - the string to log
88 */
89void vsf_log_line(struct vsf_session* p_sess, enum EVSFLogEntryType what,
90                  struct mystr* p_str);
91
92#endif /* VSF_LOGGING_H */
93
94