mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-11 05:33:47 +01:00
Make a pair of add_*_log() functions mockable.
This commit is contained in:
parent
ac3136a6fb
commit
f4fc633937
@ -276,8 +276,8 @@ static int log_time_granularity = 1;
|
|||||||
|
|
||||||
/** Define log time granularity for all logs to be <b>granularity_msec</b>
|
/** Define log time granularity for all logs to be <b>granularity_msec</b>
|
||||||
* milliseconds. */
|
* milliseconds. */
|
||||||
void
|
MOCK_IMPL(void,
|
||||||
set_log_time_granularity(int granularity_msec)
|
set_log_time_granularity,(int granularity_msec))
|
||||||
{
|
{
|
||||||
log_time_granularity = granularity_msec;
|
log_time_granularity = granularity_msec;
|
||||||
tor_log_sigsafe_err_set_granularity(granularity_msec);
|
tor_log_sigsafe_err_set_granularity(granularity_msec);
|
||||||
@ -937,9 +937,9 @@ set_log_severity_config(int loglevelMin, int loglevelMax,
|
|||||||
|
|
||||||
/** Add a log handler named <b>name</b> to send all messages in <b>severity</b>
|
/** Add a log handler named <b>name</b> to send all messages in <b>severity</b>
|
||||||
* to <b>fd</b>. Copies <b>severity</b>. Helper: does no locking. */
|
* to <b>fd</b>. Copies <b>severity</b>. Helper: does no locking. */
|
||||||
static void
|
MOCK_IMPL(STATIC void,
|
||||||
add_stream_log_impl(const log_severity_list_t *severity,
|
add_stream_log_impl,(const log_severity_list_t *severity,
|
||||||
const char *name, int fd)
|
const char *name, int fd))
|
||||||
{
|
{
|
||||||
logfile_t *lf;
|
logfile_t *lf;
|
||||||
lf = tor_malloc_zero(sizeof(logfile_t));
|
lf = tor_malloc_zero(sizeof(logfile_t));
|
||||||
@ -1199,10 +1199,10 @@ mark_logs_temp(void)
|
|||||||
* opening the logfile failed, -1 is returned and errno is set appropriately
|
* opening the logfile failed, -1 is returned and errno is set appropriately
|
||||||
* (by open(2)). Takes ownership of fd.
|
* (by open(2)). Takes ownership of fd.
|
||||||
*/
|
*/
|
||||||
int
|
MOCK_IMPL(int,
|
||||||
add_file_log(const log_severity_list_t *severity,
|
add_file_log,(const log_severity_list_t *severity,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
int fd)
|
int fd))
|
||||||
{
|
{
|
||||||
logfile_t *lf;
|
logfile_t *lf;
|
||||||
|
|
||||||
|
@ -163,11 +163,11 @@ int parse_log_severity_config(const char **cfg,
|
|||||||
log_severity_list_t *severity_out);
|
log_severity_list_t *severity_out);
|
||||||
void set_log_severity_config(int minSeverity, int maxSeverity,
|
void set_log_severity_config(int minSeverity, int maxSeverity,
|
||||||
log_severity_list_t *severity_out);
|
log_severity_list_t *severity_out);
|
||||||
void add_stream_log(const log_severity_list_t *severity, const char *name,
|
void add_stream_log(const log_severity_list_t *severity,
|
||||||
int fd);
|
const char *name, int fd);
|
||||||
int add_file_log(const log_severity_list_t *severity,
|
MOCK_DECL(int, add_file_log,(const log_severity_list_t *severity,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
int fd);
|
int fd));
|
||||||
|
|
||||||
#ifdef HAVE_SYSLOG_H
|
#ifdef HAVE_SYSLOG_H
|
||||||
int add_syslog_log(const log_severity_list_t *severity,
|
int add_syslog_log(const log_severity_list_t *severity,
|
||||||
@ -194,7 +194,7 @@ void change_callback_log_severity(int loglevelMin, int loglevelMax,
|
|||||||
void flush_pending_log_callbacks(void);
|
void flush_pending_log_callbacks(void);
|
||||||
void flush_log_messages_from_startup(void);
|
void flush_log_messages_from_startup(void);
|
||||||
void log_set_application_name(const char *name);
|
void log_set_application_name(const char *name);
|
||||||
void set_log_time_granularity(int granularity_msec);
|
MOCK_DECL(void, set_log_time_granularity,(int granularity_msec));
|
||||||
void truncate_logs(void);
|
void truncate_logs(void);
|
||||||
|
|
||||||
void tor_log(int severity, log_domain_mask_t domain, const char *format, ...)
|
void tor_log(int severity, log_domain_mask_t domain, const char *format, ...)
|
||||||
@ -306,6 +306,8 @@ extern const log_domain_mask_t LD_GENERAL_;
|
|||||||
MOCK_DECL(STATIC void, logv, (int severity, log_domain_mask_t domain,
|
MOCK_DECL(STATIC void, logv, (int severity, log_domain_mask_t domain,
|
||||||
const char *funcname, const char *suffix, const char *format,
|
const char *funcname, const char *suffix, const char *format,
|
||||||
va_list ap) CHECK_PRINTF(5,0));
|
va_list ap) CHECK_PRINTF(5,0));
|
||||||
|
MOCK_DECL(STATIC void, add_stream_log_impl,(
|
||||||
|
const log_severity_list_t *severity, const char *name, int fd));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(LOG_PRIVATE) || defined(TOR_UNIT_TESTS)
|
#if defined(LOG_PRIVATE) || defined(TOR_UNIT_TESTS)
|
||||||
|
Loading…
Reference in New Issue
Block a user