Changeset 1144 in MondoRescue
- Timestamp:
- Feb 12, 2007, 10:54:22 AM (18 years ago)
- Location:
- branches/stable/mondo/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-tools-EXT.h
r1102 r1144 6 6 extern void clean_up_KDE_desktop_if_necessary(void); 7 7 extern long get_time(void); 8 extern void (*log_debug_msg) (int debug_level, const char *szFile,9 const char *szFunction, int nLine,10 const char *fmt, ...);11 extern void standard_log_debug_msg(int debug_level, const char *szFile,12 const char *szFunction, int nLine,13 const char *fmt, ...);14 8 extern int read_cfg_var(char *config_file, char *label, char *value); 15 9 extern int write_cfg_var(char *config_file, char *label, char *value); … … 20 14 extern void initialize_raidrec(struct raid_device_record *raidrec); 21 15 #endif 22 extern void log_trace(char *o);23 16 extern int some_basic_system_sanity_checks(void); 24 17 -
branches/stable/mondo/src/common/libmondo-tools.c
r1140 r1144 314 314 #endif 315 315 } 316 317 318 /**319 * Log a trace message to the trace file.320 * @bug This function seems orphaned. Please remove.321 */322 void log_trace(char *o)323 {324 /*@ pointers **************************************************** */325 FILE *fout;326 327 /*@ buffers ***************************************************** */328 char output[MAX_STR_LEN];329 330 /*@ int ****************************************************** */331 int i;332 333 /*@ end vars *************************************************** */334 335 if (o[0] == '\0') {336 return;337 }338 strcpy(output, o);339 i = (int) strlen(output);340 if (i <= 0) {341 return;342 }343 if (output[i - 1] < 32) {344 output[i - 1] = '\0';345 }346 if (g_text_mode347 /* && !strstr(last_line_of_file(MONDO_LOGFILE),output) */ ) {348 printf("%s\n", output);349 }350 351 fout = fopen(MONDO_TRACEFILE, "a");352 if (fout) {353 fprintf(fout, "%s\n", output);354 paranoid_fclose(fout);355 } else {356 log_OS_error("Cannot write to tracefile");357 }358 }359 360 361 362 316 363 317 … … 1334 1288 1335 1289 /** 1336 * The standard log_debug_msg() (mr_msg() also due to a macro). Writes some describing1337 * information to the logfile.1338 */1339 void standard_log_debug_msg(int debug_level, const char *szFile,1340 const char *szFunction, int nLine,1341 const char *fmt, ...)1342 {1343 va_list args;1344 int i;1345 static int depth = 0;1346 char *tmp;1347 FILE *fout;1348 1349 if (depth > 5) {1350 depth--;1351 return;1352 }1353 depth++;1354 1355 malloc_string(tmp);1356 1357 if (debug_level <= g_loglevel) {1358 va_start(args, fmt);1359 if (!(fout = fopen(MONDO_LOGFILE, "a"))) {1360 return;1361 } // fatal_error("Failed to openout to logfile - sheesh..."); }1362 1363 // add tabs to distinguish log levels1364 if (debug_level > 0) {1365 for (i = 1; i < debug_level; i++)1366 fprintf(fout, "\t");1367 if (getpid() == g_main_pid)1368 fprintf(fout, "[Main] %s->%s#%d: ", szFile, szFunction,1369 nLine);1370 else if (getpid() == g_buffer_pid && g_buffer_pid > 0)1371 fprintf(fout, "[Buff] %s->%s#%d: ", szFile, szFunction,1372 nLine);1373 else1374 fprintf(fout, "[TH=%d] %s->%s#%d: ", getpid(), szFile,1375 szFunction, nLine);1376 }1377 vfprintf(fout, fmt, args);1378 1379 // do not slow down the progran if standard debug level1380 // must be enabled: if no flush, the log won't be up-to-date if there1381 // is a segfault1382 //if (g_dwDebugLevel != 1)1383 1384 va_end(args);1385 fprintf(fout, "\n");1386 paranoid_fclose(fout);1387 }1388 depth--;1389 mr_free(tmp);1390 }1391 1392 /**1393 * Function pointer to the @c log_debug_msg function to use. Points to standard_log_debug_msg() by default.1394 */1395 void (*log_debug_msg) (int, const char *, const char *, int, const char *,1396 ...) = standard_log_debug_msg;1397 1398 1399 /**1400 1290 * If @p y, malloc @p x, else free @p x. 1401 1291 * @bug This function seems orphaned. Please remove. … … 1426 1316 mr_free(g_magicdev_command); 1427 1317 } 1428 1429 /*1430 char**list_of_arrays[] = {1431 &g_boot_mountpt,1432 &g_mondo_home,1433 &g_tmpfs_mountpt,1434 &g_erase_tmpdir_and_scratchdir,1435 &g_serial_string,1436 &g_magicdev_command,1437 NULL};1438 1439 char**ppcurr;1440 int i;1441 1442 for(i=0;list_of_arrays[i];i++)1443 {1444 mr_msg(5, "Allocating %d", i);1445 ppcurr = list_of_arrays[i];1446 if (mal)1447 { *ppcurr = malloc(MAX_STR_LEN); }1448 else1449 {1450 if (*ppcurr)1451 {1452 free(*ppcurr);1453 }1454 }1455 }1456 mr_msg(5, "Returning");1457 */1458 1318 } 1459 1319 -
branches/stable/mondo/src/common/libmondo-tools.h
r1103 r1144 9 9 10 10 long get_time(void); 11 extern void (*log_debug_msg) (int debug_level, const char *szFile,12 const char *szFunction, int nLine,13 const char *fmt, ...);14 void standard_log_debug_msg(int debug_level, const char *szFile,15 const char *szFunction, int nLine,16 const char *fmt, ...);17 11 int read_cfg_var(char *config_file, char *label, char *value); 18 12 int write_cfg_var(char *config_file, char *label, char *value); … … 23 17 void initialize_raidrec(struct raid_device_record *raidrec); 24 18 #endif 25 void log_trace(char *o);26 19 int some_basic_system_sanity_checks(void); 27 20 -
branches/stable/mondo/src/include/my-stuff.h
r1131 r1144 26 26 #include <stdio.h> 27 27 #include "mr_mem.h" 28 #include "mr_msg.h" 28 29 29 30 #if !defined(bool) && !defined(__cplusplus) … … 100 101 */ 101 102 #define MDSTAT_FILE "/proc/mdstat" 102 103 /**104 * @bug Apparently unused.105 */106 #define MONDO_TRACEFILE "/var/log/mondo-tracefile.log"107 103 108 104 #undef assert … … 245 241 * Log the file, line, Mondo error message, and OS error message (errno). 246 242 */ 247 #define log_OS_error(x) { log_msg(0, "%s, line %ld: %s (%s)", __FILE__, __LINE__, x, strerror(errno));}243 #define log_OS_error(x) {mr_msg(1, "%s, line %ld: %s (%s)", __FILE__, __LINE__, x, strerror(errno));} 248 244 249 245 /** … … 255 251 * close() @p x and log a message if it fails. 256 252 */ 257 #define paranoid_close(x) {if(close(x)) { log_msg(5, "close err");} x=-999; }253 #define paranoid_close(x) {if(close(x)) {mr_msg(5, "close err");} x=-999; } 258 254 259 255 /** 260 256 * fclose() @p x and log a message if it fails. 261 257 */ 262 #define paranoid_fclose(x) {if(fclose(x)) { log_msg(5, "fclose err");} x=NULL; }258 #define paranoid_fclose(x) {if(fclose(x)) {mr_msg(5, "fclose err");} x=NULL; } 263 259 264 260 /** 265 261 * pclose() @p x and log a message if it fails. 266 262 */ 267 #define paranoid_pclose(x) {if(pclose(x)) { log_msg(5, "pclose err");} x=NULL; }263 #define paranoid_pclose(x) {if(pclose(x)) {mr_msg(5, "pclose err");} x=NULL; } 268 264 269 265 /** 270 266 * Run the command @p x and log it if it fails. 271 267 */ 272 #define paranoid_system(x) {if(system(x)) log_msg(4, x); }268 #define paranoid_system(x) {if(system(x)) mr_msg(4, x); } 273 269 274 270 /** … … 354 350 355 351 /** 356 * Compatibility define to change log_it() calls to log_debug_msg() calls. 357 */ 358 #define log_it(format, args...) log_debug_msg(2, __FILE__, __FUNCTION__, __LINE__, format, ## args) 359 360 /** 361 * Macro to log a message along with file, line, and function information. 362 */ 363 #define log_msg(level, format, args...) log_debug_msg(level, __FILE__, __FUNCTION__, __LINE__, format, ## args) 352 * Shorter log command 353 */ 354 #define log_it(format, args...) mr_msg(2, format, ## args) 364 355 365 356 #define DEFAULT_DVD_DISK_SIZE 4380 ///< The default size (in MB) of a DVD disk, unless the user says otherwise.
Note:
See TracChangeset
for help on using the changeset viewer.