trick/trick_source/sim_services/Message/message_publish_standalone.cpp
Alex Lin 19025d77ad Standardize directory names
Reorganized.  Created a new top level include directory that will hold all of Trick's header files. Moved all of the Trick headers to this directory.  Created a libexec directory that holds all of the executables that users don't need to execute directly.  Changed all of the executables remaining in bin to start with "trick-".  In the sim_services directories changed all source files to find the Trick headers in their new location.  Since all of the include files are gone in sim_services, removed the src directories as well, moving all of the source files up a level.  Moved the makefiles, docs, man, and other architecture independent files into a top level share directory.  Renamed lib_${TRICK_HOST_CPU} to lib64 or lib depending on the platform we're currently on.

refs #63
2015-06-09 08:44:42 -05:00

32 lines
925 B
C++

#include <unistd.h>
#include <stdio.h>
#include <stdarg.h>
#include <time.h>
// message_publish when you don't have a message publisher class
#define MAX_MSG_HEADER_SIZE 256
#define MAX_MSG_SIZE 20480
extern "C" int message_publish_standalone(int level, const char * format_msg, ...) {
char msg_buf[MAX_MSG_SIZE];
char date_buf[MAX_MSG_HEADER_SIZE];
char hostname[64];
time_t date ;
va_list args;
va_start(args, format_msg);
(void) vsnprintf(msg_buf, MAX_MSG_SIZE, format_msg, args);
va_end(args);
date = time(NULL) ;
strftime(date_buf, (size_t) 20, "%Y/%m/%d,%H:%M:%S", localtime(&date));
(void) gethostname(hostname, (size_t) 48);
fprintf(stdout, "|L %d|%s| |%s|T %d|%.2f| %s" , level,
// so that we don't call any exec routines, use process id 0 and sim time 0.0
date_buf, hostname , 0, 0.0, msg_buf) ;
fflush(stdout) ;
return (0);
}