Back to index

tor  0.2.3.19-rc
Classes | Defines | Typedefs | Functions | Variables
torlog.h File Reference

Headers for log.c. More...

#include "compat.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  log_severity_list_t
 Configures which severities are logged for each logging domain for a given log target. More...

Defines

#define LOG_DEBUG   7
 Debug-level severity: for hyper-verbose messages of no interest to anybody but developers.
#define LOG_INFO   6
 Info-level severity: for messages that appear frequently during normal operation.
#define LOG_NOTICE   5
 Notice-level severity: for messages that appear infrequently during normal operation; that the user will probably care about; and that are not errors.
#define LOG_WARN   4
 Warn-level severity: for messages that only appear when something has gone wrong.
#define LOG_ERR   3
 Error-level severity: for messages that only appear when something has gone very wrong, and the Tor process can no longer proceed.
#define LD_GENERAL   (1u<<0)
 Catch-all for miscellaneous events and fatal errors.
#define LD_CRYPTO   (1u<<1)
 The cryptography subsystem.
#define LD_NET   (1u<<2)
 Networking.
#define LD_CONFIG   (1u<<3)
 Parsing and acting on our configuration.
#define LD_FS   (1u<<4)
 Reading and writing from the filesystem.
#define LD_PROTOCOL   (1u<<5)
 Other servers' (non)compliance with the Tor protocol.
#define LD_MM   (1u<<6)
 Memory management.
#define LD_HTTP   (1u<<7)
 HTTP implementation.
#define LD_APP   (1u<<8)
 Application (socks) requests.
#define LD_CONTROL   (1u<<9)
 Communication via the controller protocol.
#define LD_CIRC   (1u<<10)
 Building, using, and managing circuits.
#define LD_REND   (1u<<11)
 Hidden services.
#define LD_BUG   (1u<<12)
 Internal errors in this Tor process.
#define LD_DIR   (1u<<13)
 Learning and using information about Tor servers.
#define LD_DIRSERV   (1u<<14)
 Learning and using information about Tor servers.
#define LD_OR   (1u<<15)
 Onion routing protocol.
#define LD_EDGE   (1u<<16)
 Generic edge-connection functionality.
#define LD_EXIT   LD_EDGE
#define LD_ACCT   (1u<<17)
 Bandwidth accounting.
#define LD_HIST   (1u<<18)
 Router history.
#define LD_HANDSHAKE   (1u<<19)
 OR handshaking.
#define LD_HEARTBEAT   (1u<<20)
 Heartbeat messages.
#define N_LOGGING_DOMAINS   21
 Number of logging domains in the code.
#define LD_NOCB   (1u<<31)
 This log message is not safe to send to a callback-based logger immediately.
#define log   tor_log /* hack it so we don't conflict with log() as much */
#define log_fn   (_log_fn_function_name=__func__),_log_fn
#define log_debug   (_log_fn_function_name=__func__),_log_debug
#define log_info   (_log_fn_function_name=__func__),_log_info
#define log_notice   (_log_fn_function_name=__func__),_log_notice
#define log_warn   (_log_fn_function_name=__func__),_log_warn
#define log_err   (_log_fn_function_name=__func__),_log_err
#define _TOR_LOG_H

Typedefs

typedef uint32_t log_domain_mask_t
 Mask of zero or more log domains, OR'd together.
typedef struct log_severity_list_t log_severity_list_t
 Configures which severities are logged for each logging domain for a given log target.
typedef void(* log_callback )(int severity, uint32_t domain, const char *msg)
 Callback type used for add_callback_log.

Functions

void init_logging (void)
 Initialize the global logging facility.
int parse_log_level (const char *level)
 If level is a valid log severity, return the corresponding numeric value.
const char * log_level_to_string (int level)
 Return the string equivalent of a given log level.
int parse_log_severity_config (const char **cfg, log_severity_list_t *severity_out)
 Parse a log severity pattern in *cfg_ptr.
void set_log_severity_config (int minSeverity, int maxSeverity, log_severity_list_t *severity_out)
 Adjust a log severity configuration in severity_out to contain every domain between loglevelMin and loglevelMax, inclusive.
void add_stream_log (const log_severity_list_t *severity, const char *name, int fd)
 Add a log handler named name to send all messages in severity to fd.
int add_file_log (const log_severity_list_t *severity, const char *filename)
 Add a log handler to send messages to filename.
int add_callback_log (const log_severity_list_t *severity, log_callback cb)
 Add a log handler to send messages in severity to the function cb.
void logs_set_domain_logging (int enabled)
 Set whether we report logging domains as a part of our log messages.
int get_min_log_level (void)
 Return the least severe log level that any current log is interested in.
void switch_logs_debug (void)
 Switch all logs to output at most verbose level.
void logs_free_all (void)
 Close all open log files, and free other static memory.
void add_temp_log (int min_severity)
 Add a log handler to receive messages during startup (before the real logs are initialized).
void close_temp_logs (void)
 Close any log handlers added by add_temp_log() or marked by mark_logs_temp().
void rollback_log_changes (void)
 Make all currently temporary logs (set to be closed by close_temp_logs) live again, and close all non-temporary logs.
void mark_logs_temp (void)
 Configure all log handles to be closed by close_temp_logs().
void change_callback_log_severity (int loglevelMin, int loglevelMax, log_callback cb)
 Adjust the configured severity of any logs whose callback function is cb.
void flush_pending_log_callbacks (void)
 If there are any log messages that were generated with LD_NOCB waiting to be sent to callback-based loggers, send them now.
void log_set_application_name (const char *name)
 Set the "application name" for the logs to name: we'll use this name in the message we write when starting up, and at the start of each new log.
void set_log_time_granularity (int granularity_msec)
 Define log time granularity for all logs to be granularity_msec milliseconds.
void tor_log (int severity, log_domain_mask_t domain, const char *format,...) CHECK_PRINTF(3
void _log_fn (int severity, log_domain_mask_t domain, const char *format,...)
void _log_debug (log_domain_mask_t domain, const char *format,...)
void _log_info (log_domain_mask_t domain, const char *format,...)
void _log_notice (log_domain_mask_t domain, const char *format,...)
void _log_warn (log_domain_mask_t domain, const char *format,...)
void _log_err (log_domain_mask_t domain, const char *format,...)

Variables

const char * _log_fn_function_name
 Output a message to the log, prefixed with a function name fn.

Detailed Description

Headers for log.c.

Definition in file torlog.h.


Class Documentation

struct log_severity_list_t

Configures which severities are logged for each logging domain for a given log target.

Definition at line 109 of file torlog.h.

Class Members
log_domain_mask_t masks For each log severity, a bitmask of which domains a given logger is logging.

Define Documentation

#define _TOR_LOG_H

Definition at line 214 of file torlog.h.

#define LD_ACCT   (1u<<17)

Bandwidth accounting.

Definition at line 90 of file torlog.h.

#define LD_APP   (1u<<8)

Application (socks) requests.

Definition at line 71 of file torlog.h.

#define LD_BUG   (1u<<12)

Internal errors in this Tor process.

Definition at line 79 of file torlog.h.

#define LD_CIRC   (1u<<10)

Building, using, and managing circuits.

Definition at line 75 of file torlog.h.

#define LD_CONFIG   (1u<<3)

Parsing and acting on our configuration.

Definition at line 61 of file torlog.h.

#define LD_CONTROL   (1u<<9)

Communication via the controller protocol.

Definition at line 73 of file torlog.h.

#define LD_CRYPTO   (1u<<1)

The cryptography subsystem.

Definition at line 57 of file torlog.h.

#define LD_DIR   (1u<<13)

Learning and using information about Tor servers.

Definition at line 81 of file torlog.h.

#define LD_DIRSERV   (1u<<14)

Learning and using information about Tor servers.

Definition at line 83 of file torlog.h.

#define LD_EDGE   (1u<<16)

Generic edge-connection functionality.

Definition at line 87 of file torlog.h.

#define LD_EXIT   LD_EDGE

Definition at line 88 of file torlog.h.

#define LD_FS   (1u<<4)

Reading and writing from the filesystem.

Definition at line 63 of file torlog.h.

#define LD_GENERAL   (1u<<0)

Catch-all for miscellaneous events and fatal errors.

Definition at line 55 of file torlog.h.

#define LD_HANDSHAKE   (1u<<19)

OR handshaking.

Definition at line 94 of file torlog.h.

#define LD_HEARTBEAT   (1u<<20)

Heartbeat messages.

Definition at line 96 of file torlog.h.

#define LD_HIST   (1u<<18)

Router history.

Definition at line 92 of file torlog.h.

#define LD_HTTP   (1u<<7)

HTTP implementation.

Definition at line 69 of file torlog.h.

#define LD_MM   (1u<<6)

Memory management.

Definition at line 67 of file torlog.h.

#define LD_NET   (1u<<2)

Networking.

Definition at line 59 of file torlog.h.

#define LD_NOCB   (1u<<31)

This log message is not safe to send to a callback-based logger immediately.

Used as a flag, not a log domain.

Definition at line 102 of file torlog.h.

#define LD_OR   (1u<<15)

Onion routing protocol.

Definition at line 85 of file torlog.h.

#define LD_PROTOCOL   (1u<<5)

Other servers' (non)compliance with the Tor protocol.

Definition at line 65 of file torlog.h.

#define LD_REND   (1u<<11)

Hidden services.

Definition at line 77 of file torlog.h.

#define log   tor_log /* hack it so we don't conflict with log() as much */

Definition at line 154 of file torlog.h.

#define LOG_DEBUG   7

Debug-level severity: for hyper-verbose messages of no interest to anybody but developers.

Definition at line 35 of file torlog.h.

Definition at line 205 of file torlog.h.

#define LOG_ERR   3

Error-level severity: for messages that only appear when something has gone very wrong, and the Tor process can no longer proceed.

Definition at line 49 of file torlog.h.

Definition at line 209 of file torlog.h.

Definition at line 204 of file torlog.h.

#define LOG_INFO   6

Info-level severity: for messages that appear frequently during normal operation.

Definition at line 38 of file torlog.h.

Definition at line 206 of file torlog.h.

#define LOG_NOTICE   5

Notice-level severity: for messages that appear infrequently during normal operation; that the user will probably care about; and that are not errors.

Definition at line 43 of file torlog.h.

Definition at line 207 of file torlog.h.

#define LOG_WARN   4

Warn-level severity: for messages that only appear when something has gone wrong.

Definition at line 46 of file torlog.h.

Definition at line 208 of file torlog.h.

#define N_LOGGING_DOMAINS   21

Number of logging domains in the code.

Definition at line 98 of file torlog.h.


Typedef Documentation

typedef void(* log_callback)(int severity, uint32_t domain, const char *msg)

Callback type used for add_callback_log.

Definition at line 122 of file torlog.h.

typedef uint32_t log_domain_mask_t

Mask of zero or more log domains, OR'd together.

Definition at line 105 of file torlog.h.

Configures which severities are logged for each logging domain for a given log target.


Function Documentation

void _log_debug ( log_domain_mask_t  domain,
const char *  format,
  ... 
)

Definition at line 468 of file log.c.

{
  va_list ap;
  /* For GCC we do this check in the macro. */
  if (PREDICT_LIKELY(LOG_DEBUG > _log_global_min_severity))
    return;
  va_start(ap,format);
  logv(LOG_DEBUG, domain, _log_fn_function_name, format, ap);
  va_end(ap);
  _log_fn_function_name = NULL;
}

Here is the call graph for this function:

void _log_err ( log_domain_mask_t  domain,
const char *  format,
  ... 
)

Definition at line 513 of file log.c.

{
  va_list ap;
  if (LOG_ERR > _log_global_min_severity)
    return;
  va_start(ap,format);
  logv(LOG_ERR, domain, _log_fn_function_name, format, ap);
  va_end(ap);
  _log_fn_function_name = NULL;
}

Here is the call graph for this function:

void _log_fn ( int  severity,
log_domain_mask_t  domain,
const char *  format,
  ... 
)

Definition at line 457 of file log.c.

{
  va_list ap;
  if (severity > _log_global_min_severity)
    return;
  va_start(ap,format);
  logv(severity, domain, _log_fn_function_name, format, ap);
  va_end(ap);
  _log_fn_function_name = NULL;
}

Here is the call graph for this function:

void _log_info ( log_domain_mask_t  domain,
const char *  format,
  ... 
)

Definition at line 480 of file log.c.

{
  va_list ap;
  if (LOG_INFO > _log_global_min_severity)
    return;
  va_start(ap,format);
  logv(LOG_INFO, domain, _log_fn_function_name, format, ap);
  va_end(ap);
  _log_fn_function_name = NULL;
}

Here is the call graph for this function:

void _log_notice ( log_domain_mask_t  domain,
const char *  format,
  ... 
)

Definition at line 491 of file log.c.

{
  va_list ap;
  if (LOG_NOTICE > _log_global_min_severity)
    return;
  va_start(ap,format);
  logv(LOG_NOTICE, domain, _log_fn_function_name, format, ap);
  va_end(ap);
  _log_fn_function_name = NULL;
}

Here is the call graph for this function:

void _log_warn ( log_domain_mask_t  domain,
const char *  format,
  ... 
)

Definition at line 502 of file log.c.

{
  va_list ap;
  if (LOG_WARN > _log_global_min_severity)
    return;
  va_start(ap,format);
  logv(LOG_WARN, domain, _log_fn_function_name, format, ap);
  va_end(ap);
  _log_fn_function_name = NULL;
}

Here is the call graph for this function:

int add_callback_log ( const log_severity_list_t severity,
log_callback  cb 
)

Add a log handler to send messages in severity to the function cb.

Definition at line 697 of file log.c.

{
  logfile_t *lf;
  lf = tor_malloc_zero(sizeof(logfile_t));
  lf->fd = -1;
  lf->severities = tor_memdup(severity, sizeof(log_severity_list_t));
  lf->filename = tor_strdup("<callback>");
  lf->callback = cb;
  lf->next = logfiles;

  LOCK_LOGS();
  logfiles = lf;
  _log_global_min_severity = get_min_log_level();
  UNLOCK_LOGS();
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int add_file_log ( const log_severity_list_t severity,
const char *  filename 
)

Add a log handler to send messages to filename.

If opening the logfile fails, -1 is returned and errno is set appropriately (by open(2)).

Definition at line 828 of file log.c.

{
  int fd;
  logfile_t *lf;

  fd = tor_open_cloexec(filename, O_WRONLY|O_CREAT|O_APPEND, 0644);
  if (fd<0)
    return -1;
  if (tor_fd_seekend(fd)<0)
    return -1;

  LOCK_LOGS();
  add_stream_log_impl(severity, filename, fd);
  logfiles->needs_close = 1;
  lf = logfiles;
  _log_global_min_severity = get_min_log_level();

  if (log_tor_version(lf, 0) < 0) {
    delete_log(lf);
  }
  UNLOCK_LOGS();

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void add_stream_log ( const log_severity_list_t severity,
const char *  name,
int  fd 
)

Add a log handler named name to send all messages in severity to fd.

Steals a reference to severity; the caller must not use it after calling this function.

Definition at line 648 of file log.c.

{
  LOCK_LOGS();
  add_stream_log_impl(severity, name, fd);
  UNLOCK_LOGS();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void add_temp_log ( int  min_severity)

Add a log handler to receive messages during startup (before the real logs are initialized).

Definition at line 681 of file log.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void change_callback_log_severity ( int  loglevelMin,
int  loglevelMax,
log_callback  cb 
)

Adjust the configured severity of any logs whose callback function is cb.

Definition at line 717 of file log.c.

{
  logfile_t *lf;
  log_severity_list_t severities;
  set_log_severity_config(loglevelMin, loglevelMax, &severities);
  LOCK_LOGS();
  for (lf = logfiles; lf; lf = lf->next) {
    if (lf->callback == cb) {
      memcpy(lf->severities, &severities, sizeof(severities));
    }
  }
  _log_global_min_severity = get_min_log_level();
  UNLOCK_LOGS();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void close_temp_logs ( void  )

Close any log handlers added by add_temp_log() or marked by mark_logs_temp().

Definition at line 778 of file log.c.

{
  logfile_t *lf, **p;

  LOCK_LOGS();
  for (p = &logfiles; *p; ) {
    if ((*p)->is_temporary) {
      lf = *p;
      /* we use *p here to handle the edge case of the head of the list */
      *p = (*p)->next;
      close_log(lf);
      log_free(lf);
    } else {
      p = &((*p)->next);
    }
  }

  _log_global_min_severity = get_min_log_level();
  UNLOCK_LOGS();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void flush_pending_log_callbacks ( void  )

If there are any log messages that were generated with LD_NOCB waiting to be sent to callback-based loggers, send them now.

Definition at line 736 of file log.c.

{
  logfile_t *lf;
  smartlist_t *messages, *messages_tmp;

  LOCK_LOGS();
  if (0 == smartlist_len(pending_cb_messages)) {
    UNLOCK_LOGS();
    return;
  }

  messages = pending_cb_messages;
  pending_cb_messages = smartlist_new();
  do {
    SMARTLIST_FOREACH_BEGIN(messages, pending_cb_message_t *, msg) {
      const int severity = msg->severity;
      const int domain = msg->domain;
      for (lf = logfiles; lf; lf = lf->next) {
        if (! lf->callback || lf->seems_dead ||
            ! (lf->severities->masks[SEVERITY_MASK_IDX(severity)] & domain)) {
          continue;
        }
        lf->callback(severity, domain, msg->msg);
      }
      tor_free(msg->msg);
      tor_free(msg);
    } SMARTLIST_FOREACH_END(msg);
    smartlist_clear(messages);

    messages_tmp = pending_cb_messages;
    pending_cb_messages = messages;
    messages = messages_tmp;
  } while (smartlist_len(messages));

  smartlist_free(messages);

  UNLOCK_LOGS();
}

Here is the call graph for this function:

Here is the caller graph for this function:

int get_min_log_level ( void  )

Return the least severe log level that any current log is interested in.

Definition at line 1086 of file log.c.

{
  logfile_t *lf;
  int i;
  int min = LOG_ERR;
  for (lf = logfiles; lf; lf = lf->next) {
    for (i = LOG_DEBUG; i > min; --i)
      if (lf->severities->masks[SEVERITY_MASK_IDX(i)])
        min = i;
  }
  return min;
}

Here is the caller graph for this function:

void init_logging ( void  )

Initialize the global logging facility.

Definition at line 657 of file log.c.

Here is the call graph for this function:

Here is the caller graph for this function:

const char* log_level_to_string ( int  level)

Return the string equivalent of a given log level.

Definition at line 900 of file log.c.

{
  return sev_to_string(level);
}

Here is the call graph for this function:

void log_set_application_name ( const char *  name)

Set the "application name" for the logs to name: we'll use this name in the message we write when starting up, and at the start of each new log.

Tor uses this string to write the version number to the log file.

Definition at line 159 of file log.c.

{
  tor_free(appname);
  appname = name ? tor_strdup(name) : NULL;
}

Here is the caller graph for this function:

void logs_free_all ( void  )

Close all open log files, and free other static memory.

Definition at line 539 of file log.c.

{
  logfile_t *victim, *next;
  smartlist_t *messages;
  LOCK_LOGS();
  next = logfiles;
  logfiles = NULL;
  messages = pending_cb_messages;
  pending_cb_messages = NULL;
  UNLOCK_LOGS();
  while (next) {
    victim = next;
    next = next->next;
    close_log(victim);
    log_free(victim);
  }
  tor_free(appname);

  SMARTLIST_FOREACH(messages, pending_cb_message_t *, msg, {
      tor_free(msg->msg);
      tor_free(msg);
    });
  smartlist_free(messages);

  /* We _could_ destroy the log mutex here, but that would screw up any logs
   * that happened between here and the end of execution. */
}

Here is the call graph for this function:

Here is the caller graph for this function:

void logs_set_domain_logging ( int  enabled)

Set whether we report logging domains as a part of our log messages.

Definition at line 670 of file log.c.

Here is the caller graph for this function:

void mark_logs_temp ( void  )

Configure all log handles to be closed by close_temp_logs().

Definition at line 814 of file log.c.

{
  logfile_t *lf;
  LOCK_LOGS();
  for (lf = logfiles; lf; lf = lf->next)
    lf->is_temporary = 1;
  UNLOCK_LOGS();
}

Here is the caller graph for this function:

int parse_log_level ( const char *  level)

If level is a valid log severity, return the corresponding numeric value.

Otherwise, return -1.

Definition at line 883 of file log.c.

{
  if (!strcasecmp(level, "err"))
    return LOG_ERR;
  if (!strcasecmp(level, "warn"))
    return LOG_WARN;
  if (!strcasecmp(level, "notice"))
    return LOG_NOTICE;
  if (!strcasecmp(level, "info"))
    return LOG_INFO;
  if (!strcasecmp(level, "debug"))
    return LOG_DEBUG;
  return -1;
}

Here is the caller graph for this function:

int parse_log_severity_config ( const char **  cfg_ptr,
log_severity_list_t severity_out 
)

Parse a log severity pattern in *cfg_ptr.

Advance cfg_ptr after the end of the severityPattern. Set the value of severity_out to the parsed pattern. Return 0 on success, -1 on failure.

The syntax for a SeverityPattern is:

   SeverityPattern = *(DomainSeverity SP)* DomainSeverity
   DomainSeverity = (DomainList SP)? SeverityRange
   SeverityRange = MinSeverity ("-" MaxSeverity )?
   DomainList = "[" (SP? DomainSpec SP? ",") SP? DomainSpec "]"
   DomainSpec = "*" | Domain | "~" Domain
 

A missing MaxSeverity defaults to ERR. Severities and domains are case-insensitive. "~" indicates negation for a domain; negation happens last inside a DomainList. Only one SeverityRange without a DomainList is allowed per line.

Definition at line 979 of file log.c.

{
  const char *cfg = *cfg_ptr;
  int got_anything = 0;
  int got_an_unqualified_range = 0;
  memset(severity_out, 0, sizeof(*severity_out));

  cfg = eat_whitespace(cfg);
  while (*cfg) {
    const char *dash, *space;
    char *sev_lo, *sev_hi;
    int low, high, i;
    log_domain_mask_t domains = ~0u;

    if (*cfg == '[') {
      int err = 0;
      char *domains_str;
      smartlist_t *domains_list;
      log_domain_mask_t neg_domains = 0;
      const char *closebracket = strchr(cfg, ']');
      if (!closebracket)
        return -1;
      domains = 0;
      domains_str = tor_strndup(cfg+1, closebracket-cfg-1);
      domains_list = smartlist_new();
      smartlist_split_string(domains_list, domains_str, ",", SPLIT_SKIP_SPACE,
                             -1);
      tor_free(domains_str);
      SMARTLIST_FOREACH(domains_list, const char *, domain,
          {
            if (!strcmp(domain, "*")) {
              domains = ~0u;
            } else {
              int d;
              int negate=0;
              if (*domain == '~') {
                negate = 1;
                ++domain;
              }
              d = parse_log_domain(domain);
              if (!d) {
                log_warn(LD_CONFIG, "No such logging domain as %s", domain);
                err = 1;
              } else {
                if (negate)
                  neg_domains |= d;
                else
                  domains |= d;
              }
            }
          });
      SMARTLIST_FOREACH(domains_list, char *, d, tor_free(d));
      smartlist_free(domains_list);
      if (err)
        return -1;
      if (domains == 0 && neg_domains)
        domains = ~neg_domains;
      else
        domains &= ~neg_domains;
      cfg = eat_whitespace(closebracket+1);
    } else {
      ++got_an_unqualified_range;
    }
    if (!strcasecmpstart(cfg, "file") ||
        !strcasecmpstart(cfg, "stderr") ||
        !strcasecmpstart(cfg, "stdout") ||
        !strcasecmpstart(cfg, "syslog")) {
      goto done;
    }
    if (got_an_unqualified_range > 1)
      return -1;

    space = strchr(cfg, ' ');
    dash = strchr(cfg, '-');
    if (!space)
      space = strchr(cfg, '\0');
    if (dash && dash < space) {
      sev_lo = tor_strndup(cfg, dash-cfg);
      sev_hi = tor_strndup(dash+1, space-(dash+1));
    } else {
      sev_lo = tor_strndup(cfg, space-cfg);
      sev_hi = tor_strdup("ERR");
    }
    low = parse_log_level(sev_lo);
    high = parse_log_level(sev_hi);
    tor_free(sev_lo);
    tor_free(sev_hi);
    if (low == -1)
      return -1;
    if (high == -1)
      return -1;

    got_anything = 1;
    for (i=low; i >= high; --i)
      severity_out->masks[SEVERITY_MASK_IDX(i)] |= domains;

    cfg = eat_whitespace(space);
  }

 done:
  *cfg_ptr = cfg;
  return got_anything ? 0 : -1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void rollback_log_changes ( void  )

Make all currently temporary logs (set to be closed by close_temp_logs) live again, and close all non-temporary logs.

Definition at line 802 of file log.c.

{
  logfile_t *lf;
  LOCK_LOGS();
  for (lf = logfiles; lf; lf = lf->next)
    lf->is_temporary = ! lf->is_temporary;
  UNLOCK_LOGS();
  close_temp_logs();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void set_log_severity_config ( int  minSeverity,
int  maxSeverity,
log_severity_list_t severity_out 
)

Adjust a log severity configuration in severity_out to contain every domain between loglevelMin and loglevelMax, inclusive.

Definition at line 614 of file log.c.

{
  int i;
  tor_assert(loglevelMin >= loglevelMax);
  tor_assert(loglevelMin >= LOG_ERR && loglevelMin <= LOG_DEBUG);
  tor_assert(loglevelMax >= LOG_ERR && loglevelMax <= LOG_DEBUG);
  memset(severity_out, 0, sizeof(log_severity_list_t));
  for (i = loglevelMin; i >= loglevelMax; --i) {
    severity_out->masks[SEVERITY_MASK_IDX(i)] = ~0u;
  }
}

Here is the caller graph for this function:

void set_log_time_granularity ( int  granularity_msec)

Define log time granularity for all logs to be granularity_msec milliseconds.

Definition at line 171 of file log.c.

{
  log_time_granularity = granularity_msec;
}

Here is the caller graph for this function:

void switch_logs_debug ( void  )

Switch all logs to output at most verbose level.

Definition at line 1101 of file log.c.

{
  logfile_t *lf;
  int i;
  LOCK_LOGS();
  for (lf = logfiles; lf; lf=lf->next) {
    for (i = LOG_DEBUG; i >= LOG_ERR; --i)
      lf->severities->masks[SEVERITY_MASK_IDX(i)] = ~0u;
  }
  _log_global_min_severity = get_min_log_level();
  UNLOCK_LOGS();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void tor_log ( int  severity,
log_domain_mask_t  domain,
const char *  format,
  ... 
)

Variable Documentation

const char* _log_fn_function_name

Output a message to the log, prefixed with a function name fn.

Variant implementation of log_fn, log_debug, log_info,... for C compilers

without variadic macros. In this case, the calling function sets _log_fn_function_name to the name of the function, then invokes the appropriate _log_fn, _log_debug, etc.

Definition at line 455 of file log.c.