Project

General

Profile

Revision 132

Added by Jason knichel over 16 years ago

changed the Log class a little and made it conform to coding style slightly better

View differences:

Log.cpp
5 5
 * 
6 6
 * @author Jason Knichel
7 7
 *
8
 * @TODO: change this file to follow the coding style
8 9
 */
9 10

  
10 11
#include <time.h>
......
33 34
  }
34 35

  
35 36
  printf("About to log start message.\n");
36
  logMessage(LOG_TYPE_START_LOG, "Starting server");
37
  log_string(LOG_TYPE_START_LOG, "Starting server");
37 38
}
38 39

  
39 40
/**
......
49 50
 *
50 51
 * @return A struct tm that represents the current time
51 52
 */
52
struct tm Log::getCurrentTime() {
53
struct tm Log::get_current_time() {
53 54
  struct tm currTime;
54 55
  memset(&currTime, 0, sizeof(struct tm));
55 56
  
......
67 68
 *
68 69
 * @return 0 on success, negative error code on error
69 70
 */
70
int Log::logMessage(int type, char * message) {
71
int Log::log_string(int type, char * message) {
71 72
  if (!logFile) {
72 73
    fprintf(stderr, "Tried to log a message but the file pointer was null.\n");
73 74
    return -1;
......
107 108
    return -1;
108 109
  }
109 110

  
110
  struct tm currTime = getCurrentTime();
111
  struct tm currTime = get_current_time();
111 112
  
112 113
  char buffer[LOG_MAX_TIME_LENGTH];
113 114
  asctime_r(&currTime, buffer);
......
118 119

  
119 120
  return 0;
120 121
}
122

  
123
int Log::log_error(char * message) {
124
  return log_string(LOG_TYPE_ERROR, message);
125
}
126

  
127
int Log::log_message(char *  message) {
128
  return log_string(LOG_TYPE_MESSAGE, message);
129
}

Also available in: Unified diff