logging.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef VSF_LOGGING_H
  2. #define VSF_LOGGING_H
  3. /* Forward delcarations */
  4. struct mystr;
  5. struct vsf_session;
  6. enum EVSFLogEntryType
  7. {
  8. kVSFLogEntryNull = 1,
  9. kVSFLogEntryDownload,
  10. kVSFLogEntryUpload,
  11. kVSFLogEntryMkdir,
  12. kVSFLogEntryLogin,
  13. kVSFLogEntryFTPInput,
  14. kVSFLogEntryFTPOutput,
  15. kVSFLogEntryConnection,
  16. kVSFLogEntryDelete,
  17. kVSFLogEntryRename,
  18. kVSFLogEntryRmdir,
  19. kVSFLogEntryChmod,
  20. kVSFLogEntryDebug,
  21. };
  22. /* vsf_log_init()
  23. * PURPOSE
  24. * Initialize the logging services, by opening a writable file descriptor to
  25. * the log file (should logging be enabled).
  26. * PARAMETERS
  27. * p_sess - the current session object
  28. */
  29. void vsf_log_init(struct vsf_session* p_sess);
  30. /* vsf_log_start_entry()
  31. * PURPOSE
  32. * Denote the start of a logged operation. Importantly, timing information
  33. * (if applicable) will be taken starting from this call.
  34. * PARAMETERS
  35. * p_sess - the current session object
  36. * what - the type of operation which just started
  37. */
  38. void vsf_log_start_entry(struct vsf_session* p_sess,
  39. enum EVSFLogEntryType what);
  40. /* vsf_log_entry_pending()
  41. * PURPOSE
  42. * Determine whether a log entry has been started and not yet closed.
  43. * RETURNS
  44. * 0 if no log entry is pending; 1 if one is.
  45. */
  46. int vsf_log_entry_pending(struct vsf_session* p_sess);
  47. /* vsf_log_clear_entry()
  48. * PURPOSE
  49. * Clears any pending log entry.
  50. */
  51. void vsf_log_clear_entry(struct vsf_session* p_sess);
  52. /* vsf_log_do_log()
  53. * PURPOSE
  54. * Denote the end of a logged operation, specifying whether the operation
  55. * was successful or not.
  56. * PARAMETERS
  57. * p_sess - the current session object
  58. * succeeded - 0 for a failed operation, 1 for a successful operation
  59. */
  60. void vsf_log_do_log(struct vsf_session* p_sess, int succeeded);
  61. /* vsf_log_line()
  62. * PURPOSE
  63. * Logs a single line of information, without disturbing any pending log
  64. * operations (e.g. a download log spans a period of time).
  65. * This call must be used for any logging calls nested within a call to
  66. * the vsf_log_start_entry() function.
  67. * PARAMETERS
  68. * p_sess - the current session object
  69. * what - the type of operation to log
  70. * p_str - the string to log
  71. */
  72. void vsf_log_line(struct vsf_session* p_sess, enum EVSFLogEntryType what,
  73. struct mystr* p_str);
  74. #endif /* VSF_LOGGING_H */