/usr/include/astrometry/log.h is in astrometry.net 0.46-0ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | #ifndef _LOG_H
#define _LOG_H
#include <stdio.h>
#include <stdarg.h>
#include "an-bool.h"
enum log_level {
LOG_NONE,
LOG_ERROR,
LOG_MSG,
LOG_VERB,
LOG_ALL
};
typedef void (*logfunc_t)(void* baton, enum log_level, const char* file, int line, const char* func, const char* format, va_list va);
//typedef void (*logfunc2_t)(void* baton, enum log_level, const char* file, int line, const char* string);
struct log_t {
enum log_level level;
FILE* f;
anbool timestamp;
double t0;
// User-specified logging functions
logfunc_t logfunc;
void* baton;
};
typedef struct log_t log_t;
/**
Send log messages to the user-specified logging function (as well as
to the FILE*, if it is set; use log_to(NULL) to only send messages to
the user-specified function.
*/
void log_use_function(logfunc_t func, void* baton);
/**
Make all logging commands thread-specific rather than global.
*/
void log_set_thread_specific(void);
void log_set_timestamp(anbool b);
/**
* Initialize global logging object. Must be called before any of the other
* log_* functions.
*/
void log_init(enum log_level level);
void log_set_level(enum log_level level);
/**
Sends global logging to the given FILE*.
*/
void log_to(FILE* fid);
void log_to_fd(int fd);
/**
* Create a new logger.
*
* Parameters:
*
* level - LOG_NONE don't show anything
* LOG_ERROR only log errors
* LOG_MSG log errors and important messages
* LOG_VERB log verbose messages
* LOG_ALL log debug messages
*
* Returns:
*
* A new logger object
*
*/
log_t* log_create(const enum log_level level);
/**
* Close and free a logger object.
*/
void log_free(log_t* logger);
#define LOG_TEMPLATE(name) \
void log_##name(const char* file, int line, const char* func, const char* format, ...) \
__attribute__ ((format (printf, 4, 5)));
LOG_TEMPLATE(logmsg);
LOG_TEMPLATE(logerr);
LOG_TEMPLATE(logverb);
LOG_TEMPLATE(logdebug);
void log_loglevel(enum log_level level, const char* file, int line, const char* func, const char* format, ...)
__attribute__ ((format (printf, 5, 6)));
/**
* Log a message:
*/
#define logerr( x, ...) log_logerr( __FILE__, __LINE__, __func__, x, ##__VA_ARGS__)
#define logmsg( x, ...) log_logmsg( __FILE__, __LINE__, __func__, x, ##__VA_ARGS__)
#define logverb( x, ...) log_logverb( __FILE__, __LINE__, __func__, x, ##__VA_ARGS__)
#define debug( x, ...) log_logdebug(__FILE__, __LINE__, __func__, x, ##__VA_ARGS__)
#define logdebug(x, ...) log_logdebug(__FILE__, __LINE__, __func__, x, ##__VA_ARGS__)
// log at a particular level.
#define loglevel(loglvl, format, ...) log_loglevel(loglvl, __FILE__, __LINE__, __func__, format, ##__VA_ARGS__)
int log_get_level(void);
FILE* log_get_fid(void);
extern log_t _logger_global;
#endif // _LOG_H
|