- char datebuffer[32];
- char processinfo[64];
-
- char *ptr = message_details_buffer;
- int templen;
- int len = message_details_buffer_length;
-
- char log_buffer[MAXLOGSIZE];
- const char *logtype_string;
-
- char loglevel_string[12]; /* max int size is 2 billion, or 10 digits */
-
- struct what_to_print_array what_to_print;
-
- workout_what_to_print(&what_to_print, log_struct);
-
-#ifdef DEBUG_OUTPUT_TO_SCREEN
- printf("Making MessageDetails\n");
-#endif
-
- *ptr = 0;
- /*
- datebuffer[0] = 0;
- ptr = datebuffer;
- */
-
- if (what_to_print.print_datetime)
- {
- time_t thetime;
- time(&thetime);
-
- /* some people might prefer localtime() to gmtime() */
- strftime(ptr, len, "%b %d %H:%M:%S", gmtime(&thetime));
-#ifdef DEBUG_OUTPUT_TO_SCREEN
- printf("date is %s\n", ptr);
-#endif
-
- templen = strlen(ptr);
- len -= templen;
- if (what_to_print.print_processname || what_to_print.print_pid)
- strncat(ptr, " ", len);
- else
- strncat(ptr, ":", len);
-
- templen++;
- len --;
- ptr += templen;
- }
-
- /*
- processinfo[0] = 0;
- ptr = processinfo;
- */
-
- if (what_to_print.print_processname)
- {
- strncpy(ptr, global_log_data.processname, len);
-
- templen = strlen(ptr);
- len -= templen;
- ptr += templen;
- }
-
- if (what_to_print.print_pid)
- {
- pid_t pid = getpid();
-
- sprintf(ptr, "[%d]", pid);
-
- templen = strlen(ptr);
- len -= templen;
- ptr += templen;
- }
-
- if (what_to_print.print_srcfile || what_to_print.print_srcline)
- {
- char sprintf_buffer[8];
- char *buff_ptr;
-
- sprintf_buffer[0] = '[';
- if (what_to_print.print_srcfile)
- {
- strcpy(&sprintf_buffer[1], "%s");
- buff_ptr = &sprintf_buffer[3];
- }
- if (what_to_print.print_srcfile && what_to_print.print_srcline)
- {
- strcpy(&sprintf_buffer[3], ":");
- buff_ptr = &sprintf_buffer[4];
- }
- if (what_to_print.print_srcline)
- {
- strcpy(buff_ptr, "%d");
- buff_ptr = &buff_ptr[2];
- }
- strcpy(buff_ptr, "]");
-
- /*
- ok sprintf string is ready, now is the 1st parameter src or linenumber