/[LeafOK_CVS]/lbbs/src/log.c
ViewVC logotype

Diff of /lbbs/src/log.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.37 by sysadm, Thu Dec 18 14:47:00 2025 UTC Revision 1.38 by sysadm, Fri Dec 19 06:16:27 2025 UTC
# Line 123  int log_printf(enum log_level_t log_leve Line 123  int log_printf(enum log_level_t log_leve
123                  // Encoding error                  // Encoding error
124                  return -1;                  return -1;
125          }          }
126          else if (offset + ret >= sizeof(buf))          else if (offset + ret + 1 >= sizeof(buf))
127          {          {
128                  buf[sizeof(buf) - 2] = '\n'; // Add newline for truncated messages                  buf[sizeof(buf) - 2] = '\n'; // Add newline for truncated messages
129                  buf[sizeof(buf) - 1] = '\0'; // Ensure null termination                  buf[sizeof(buf) - 1] = '\0'; // Ensure null termination
# Line 135  int log_printf(enum log_level_t log_leve Line 135  int log_printf(enum log_level_t log_leve
135          }          }
136          else          else
137          {          {
138                    buf[offset + ret] = '\n';         // Add newline
139                    buf[offset + ret + 1] = '\0'; // Ensure null termination
140                  if (fputs(buf, fp_log) == EOF)                  if (fputs(buf, fp_log) == EOF)
141                  {                  {
142                          return -3; // Write error                          return -3; // Write error
143                  }                  }
144                  ret = offset + ret;                  ret = offset + ret + 1; // Return number of characters written (including newline)
145          }          }
146    
147          if (fflush(fp_log) == EOF)          if (fflush(fp_log) == EOF)
# Line 172  int log_restart(void) Line 174  int log_restart(void)
174                  fp_common = fopen(path_common_log, "a");                  fp_common = fopen(path_common_log, "a");
175                  if (fp_common == NULL)                  if (fp_common == NULL)
176                  {                  {
177                          log_error("fopen(%s) error: %s\n", path_common_log, strerror(errno));                          log_error("fopen(%s) error: %s", path_common_log, strerror(errno));
178                          return -1;                          return -1;
179                  }                  }
180          }          }
# Line 182  int log_restart(void) Line 184  int log_restart(void)
184                  fp_error = fopen(path_error_log, "a");                  fp_error = fopen(path_error_log, "a");
185                  if (fp_error == NULL)                  if (fp_error == NULL)
186                  {                  {
187                          log_error("fopen(%s) error: %s\n", path_error_log, strerror(errno));                          log_error("fopen(%s) error: %s", path_error_log, strerror(errno));
188                          if (fp_common)                          if (fp_common)
189                          {                          {
190                                  fclose(fp_common);                                  fclose(fp_common);


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1