33 #include <lal/XLALError.h>
34 #include <lal/LALMalloc.h>
35 #include <lal/LALDebugLevel.h>
41 #define getpid _getpid
43 #ifdef HAVE_SYS_TIME_H
46 #ifdef HAVE_SYS_TYPES_H
47 #include <sys/types.h>
54 #ifdef HAVE_SYS_RESOURCE_H
55 #include <sys/resource.h>
60 #ifndef HAVE_LOCALTIME_R
61 #define localtime_r(timep, result) memcpy((result), localtime(timep), sizeof(struct tm))
64 #include <lal/LogPrintf.h>
123 va_start(va, format);
126 vfprintf (
LogFile(), format, va );
145 va_start(va, format);
148 vfprintf(
LogFile(), format, va);
161 static char buf[100];
163 time_t
x = (time_t)t;
167 int hundreds_of_microseconds=(int)(10000*(t-(
int)t));
169 if (hundreds_of_microseconds == 10000) {
171 hundreds_of_microseconds=0;
175 strftime(buf,
sizeof(buf),
"%Y-%m-%d %H:%M:%S", &tm);
176 sprintf(finer,
".%04d", hundreds_of_microseconds);
200 #ifdef HAVE_SYS_RESOURCE_H
207 peakHeapMB /= 1024.0;
214 if (
usage.ru_maxrss > 0 ) {
235 #define EPOCHFILETIME_SEC (11644473600.)
236 #define TEN_MILLION 10000000.
241 GetSystemTimeAsFileTime(&sysTime);
242 time.LowPart = sysTime.dwLowDateTime;
243 time.HighPart = sysTime.dwHighDateTime;
244 t = (double)time.QuadPart;
246 t -= EPOCHFILETIME_SEC;
251 if ( gettimeofday ( &tv, NULL ) != 0 ) {
252 XLALPrintError (
"%s: call to gettimeofday() failed with errno = %d\n", __func__, errno );
256 return tv.tv_sec + (tv.tv_usec/1.e6);
272 #if defined(HAVE_CLOCK_GETTIME) && HAVE_DECL_CLOCK_PROCESS_CPUTIME_ID
275 if ( clock_gettime ( CLOCK_PROCESS_CPUTIME_ID, &ut ) != 0 ) {
278 return ut.tv_sec + ut.tv_nsec * 1.e-9;
300 static char buf[100];
305 sprintf (buf,
"CRITICAL" );
308 sprintf (buf,
"normal");
311 sprintf (buf,
"debug");
314 sprintf (buf,
"detail");
317 sprintf (buf,
"unknown(%d)", level );
351 for ( i=0; i < rows; i ++ )
353 for (j=0; j < cols; j ++ )
355 fprintf (
fp, fmt, gsl_matrix_get ( gij, i, j ) );
380 if ( !vect || !
fp || !fmt )
386 for ( i=0; i < rows; i ++ )
388 fprintf (
fp, fmt, gsl_vector_get ( vect, i ) );
406 if ( !vect || !
fp || !fmt )
412 for ( i=0; i < rows; i ++ )
414 fprintf (
fp, fmt, gsl_vector_int_get ( vect, i ) );
438 if ( (ret =
LALMalloc( strlen ( str ) + 1) ) == NULL )
443 while ( (tmp = strchr ( tmp,
'\n' ) ) )
467 for (
UINT4 i = 0; i < numSamples; i++ )
493 for (
UINT4 i = 0; i < numSamples; i++ )
520 for (
UINT4 i = 0; i < numSamples; i++ )
static FILE * LogFile(void)
Decide where to print log messages.
void LogPrintfVerbatim(LogLevel_t level, const char *format,...)
Verbatim output of the given log-message if LogLevel() >= level.
static const char * LogTimeToString(double t)
static const char * LogFormatLevel(LogLevel_t level)
#define localtime_r(timep, result)
void LogPrintf(LogLevel_t level, const char *format,...)
Output the given log-message, prefixed by a timestamp and level, if LogLevel() >= level.
int XLALPrintError(const char *fmt,...)
char * XLALGPSToStr(char *, const LIGOTimeGPS *t)
Return a string containing the ASCII base 10 representation of a LIGOTimeGPS.
double REAL8
Double precision real floating-point number (8 bytes).
uint32_t UINT4
Four-byte unsigned integer.
@ LALINFO
enable info messages
@ LALWARNING
enable warning messages
@ LALMEMPADBIT
enable memory padding
size_t lalMallocTotalPeak
peak amount of memory allocated so far
void LogSetFile(FILE *fp)
Set file to print log messages to.
int XLALdumpREAL8TimeSeries(const char *fname, const REAL8TimeSeries *series)
dump given REAL8 time-series into a text-file
REAL8 XLALGetCPUTime(void)
High-resolution CPU timer (returns result in seconds), aimed for code-timing purposes.
int XLALdumpREAL4TimeSeries(const char *fname, const REAL4TimeSeries *series)
dump given REAL4 time-series into a text-file
REAL8 XLALGetPeakHeapUsageMB(void)
Returns the peak amount of memory (in MB) allocated on the heap so far using either lalMallocTotalPea...
const char * LogGetTimestamp(void)
LogLevel_t
Argument-type for LogPrintf(): determines log-level of this message.
int XLALdumpCOMPLEX8TimeSeries(const char *fname, const COMPLEX8TimeSeries *series)
dump given COMPLEX8 time-series into a text-file
int XLALfprintfGSLmatrix(FILE *fp, const char *fmt, const gsl_matrix *gij)
Output gsl_matrix in octave-format, using the given format for the matrix-entries return -1 on error,...
int XLALfprintfGSLvector_int(FILE *fp, const char *fmt, const gsl_vector_int *vect)
int XLALfprintfGSLvector(FILE *fp, const char *fmt, const gsl_vector *vect)
Output gsl_matrix in octave-format, using the given format for the matrix-entries return -1 on error,...
REAL8 XLALGetTimeOfDay(void)
Return time of day (seconds since 1970) as a double.
LogLevel_t LogLevel(void)
Get log level by examining lalDebugLevel.
char * XLALClearLinebreaks(const char *str)
Returns input string with line-breaks ' ' removed (replaced by space) The original string is unmodifi...
@ LOG_CRITICAL
log-level for critical errors
@ LOG_NONE
internal: don't use
@ LOG_DEBUG
debug log-level
@ LOG_NORMAL
'normal' log-level
@ LOG_DETAIL
detailed log-level
#define XLAL_ERROR_REAL8(...)
Macro to invoke a failure from a XLAL routine returning a REAL8.
#define XLAL_CHECK(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns an integ...
#define XLAL_CHECK_REAL8(assertion,...)
Macro to test an assertion and invoke a failure if it is not true in a function that returns a REAL8.
@ XLAL_SUCCESS
Success return value (not an error number)
@ XLAL_EINVAL
Invalid argument.
LIGOTimeGPS * XLALGPSAdd(LIGOTimeGPS *epoch, REAL8 dt)
Adds a double to a GPS time.
Time series of COMPLEX8 data, see DATATYPE-TimeSeries types for more details.
REAL8 deltaT
The time step between samples of the time series in seconds.
LIGOTimeGPS epoch
The start time of the time series.
COMPLEX8Sequence * data
The sequence of sampled data.
UINT4 length
Number of elements in array.
COMPLEX8 * data
Pointer to the data array.
Epoch relative to GPS epoch, see LIGOTimeGPS type for more details.
Time series of REAL4 data, see DATATYPE-TimeSeries types for more details.
REAL4Sequence * data
The sequence of sampled data.
REAL8 deltaT
The time step between samples of the time series in seconds.
LIGOTimeGPS epoch
The start time of the time series.
REAL4 * data
Pointer to the data array.
UINT4 length
Number of elements in array.
Time series of REAL8 data, see DATATYPE-TimeSeries types for more details.
REAL8Sequence * data
The sequence of sampled data.
REAL8 deltaT
The time step between samples of the time series in seconds.
LIGOTimeGPS epoch
The start time of the time series.
REAL8 * data
Pointer to the data array.
UINT4 length
Number of elements in array.