GNUnet  0.10.x
Data Structures | Macros | Functions | Variables
common_logging.c File Reference

error handling API More...

#include "platform.h"
#include "gnunet_crypto_lib.h"
#include "gnunet_disk_lib.h"
#include "gnunet_strings_lib.h"
#include <regex.h>
Include dependency graph for common_logging.c:

Go to the source code of this file.

Data Structures

struct  CustomLogger
 Linked list of active loggers. More...
 
struct  LogDef
 Represents a single logging definition. More...
 

Macros

#define BULK_DELAY_THRESHOLD   (12 * 60 * 60 * 1000LL * 1000LL)
 After how many milliseconds do we always print that "message X was repeated N times"? Use 12h. More...
 
#define BULK_REPEAT_THRESHOLD   1000
 After how many repetitions do we always print that "message X was repeated N times"? (even if we have not yet reached the delay threshold) More...
 
#define BULK_TRACK_SIZE   256
 How many characters do we use for matching of bulk messages? More...
 
#define COMP_TRACK_SIZE   32
 How many characters do we use for matching of bulk components? More...
 
#define DATE_STR_SIZE   64
 How many characters can a date/time string be at most? More...
 
#define ROTATION_KEEP   3
 How many log files to keep? More...
 
#define PATH_MAX   4096
 Assumed maximum path length (for the log file name). More...
 
#define LEN
 

Functions

static GNUNET_THREAD_LOCAL char last_bulk [256] __attribute__ ((nonstring))
 The last "bulk" error message that we have been logging. More...
 
static enum GNUNET_ErrorType get_type (const char *log)
 Convert a textual description of a loglevel to the respective GNUNET_GE_KIND. More...
 
void GNUNET_abort_ ()
 Abort the process, generate a core dump if possible. More...
 
static void resize_logdefs ()
 Utility function - reallocates logdefs array to be twice as large. More...
 
static void log_rotate (const char *new_name)
 Rotate logs, deleting the oldest log. More...
 
static int setup_log_file (const struct tm *tm)
 Setup the log file. More...
 
static int add_definition (const char *component, const char *file, const char *function, int from_line, int to_line, int level, int force)
 Utility function - adds a parsed definition to logdefs array. More...
 
int GNUNET_get_log_call_status (int caller_level, const char *comp, const char *file, const char *function, int line)
 Decides whether a particular logging call should or should not be allowed to be made. More...
 
static int parse_definitions (const char *constname, int force)
 Utility function - parses a definition. More...
 
static void parse_all_definitions ()
 Utility function - parses GNUNET_LOG and GNUNET_FORCE_LOG. More...
 
int GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile)
 Setup logging. More...
 
void GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls)
 Add a custom logger. More...
 
void GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls)
 Remove a custom logger. More...
 
static void output_message (enum GNUNET_ErrorType kind, const char *comp, const char *datestr, const char *msg)
 Actually output the log message. More...
 
static void flush_bulk (const char *datestr)
 Flush an existing bulk report to the output. More...
 
void GNUNET_log_skip (int n, int check_reset)
 Ignore the next n calls to the log function. More...
 
int GNUNET_get_log_skip ()
 Get the number of log calls that are going to be skipped. More...
 
static void mylog (enum GNUNET_ErrorType kind, const char *comp, const char *message, va_list va)
 Output a log message using the default mechanism. More...
 
void GNUNET_log_nocheck (enum GNUNET_ErrorType kind, const char *message,...)
 Main log function. More...
 
void GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp, const char *message,...)
 Log function that specifies an alternative component. More...
 
const char * GNUNET_error_type_to_string (enum GNUNET_ErrorType kind)
 Convert error type to string. More...
 
const char * GNUNET_h2s (const struct GNUNET_HashCode *hc)
 Convert a hash to a string (for printing debug messages). More...
 
const char * GNUNET_h2s2 (const struct GNUNET_HashCode *hc)
 Convert a hash to a string (for printing debug messages). More...
 
const char * GNUNET_p2s (const struct GNUNET_CRYPTO_EddsaPublicKey *p)
 Convert a public key value to a string (for printing debug messages). More...
 
const char * GNUNET_p2s2 (const struct GNUNET_CRYPTO_EddsaPublicKey *p)
 Convert a public key value to a string (for printing debug messages). More...
 
const char * GNUNET_e2s (const struct GNUNET_CRYPTO_EcdhePublicKey *p)
 Convert a public key value to a string (for printing debug messages). More...
 
const char * GNUNET_e2s2 (const struct GNUNET_CRYPTO_EcdhePublicKey *p)
 Convert a public key value to a string (for printing debug messages). More...
 
const char * GNUNET_sh2s (const struct GNUNET_ShortHashCode *shc)
 Convert a short hash value to a string (for printing debug messages). More...
 
const char * GNUNET_uuid2s (const struct GNUNET_Uuid *uuid)
 Convert a UUID to a string (for printing debug messages). More...
 
const char * GNUNET_h2s_full (const struct GNUNET_HashCode *hc)
 Convert a hash to a string (for printing debug messages). More...
 
const char * GNUNET_i2s (const struct GNUNET_PeerIdentity *pid)
 Convert a peer identity to a string (for printing debug messages). More...
 
const char * GNUNET_i2s2 (const struct GNUNET_PeerIdentity *pid)
 Convert a peer identity to a string (for printing debug messages). More...
 
const char * GNUNET_i2s_full (const struct GNUNET_PeerIdentity *pid)
 Convert a peer identity to a string (for printing debug messages). More...
 
const char * GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen)
 Convert a "struct sockaddr*" (IPv4 or IPv6 address) to a string (for printing debug messages). More...
 
void GNUNET_log_config_missing (enum GNUNET_ErrorType kind, const char *section, const char *option)
 Log error message about missing configuration option. More...
 
void GNUNET_log_config_invalid (enum GNUNET_ErrorType kind, const char *section, const char *option, const char *required)
 Log error message about invalid configuration option value. More...
 
void GNUNET_async_scope_enter (const struct GNUNET_AsyncScopeId *aid, struct GNUNET_AsyncScopeSave *old_scope)
 Set the async scope for the current thread. More...
 
void GNUNET_async_scope_restore (struct GNUNET_AsyncScopeSave *old_scope)
 Clear the current thread's async scope. More...
 
void GNUNET_async_scope_fresh (struct GNUNET_AsyncScopeId *aid_ret)
 Generate a fresh async scope identifier. More...
 
void GNUNET_async_scope_get (struct GNUNET_AsyncScopeSave *scope_ret)
 Get the current async scope. More...
 
void __attribute__ ((constructor))
 Initializer. More...
 
void __attribute__ ((destructor))
 Destructor. More...
 

Variables

static __thread struct GNUNET_AsyncScopeSave current_async_scope
 Asynchronous scope of the current thread, or NULL if we have not entered an async scope yet. More...
 
static GNUNET_THREAD_LOCAL enum GNUNET_ErrorType last_bulk_kind
 Type of the last bulk message. More...
 
static GNUNET_THREAD_LOCAL struct GNUNET_TIME_Absolute last_bulk_time
 Time of the last bulk error message (0 for none) More...
 
static GNUNET_THREAD_LOCAL unsigned int last_bulk_repeat
 Number of times that bulk message has been repeated since. More...
 
static GNUNET_THREAD_LOCAL char last_bulk_comp [32+1]
 Component when the last bulk was logged. More...
 
static char * component
 Running component. More...
 
static char * component_nopid
 Running component (without pid). More...
 
static char * log_file_name
 Format string describing the name of the log file. More...
 
static enum GNUNET_ErrorType min_level
 Minimum log level. More...
 
static struct CustomLoggerloggers
 Linked list of our custom loggres. More...
 
static GNUNET_THREAD_LOCAL int skip_log = 0
 Number of log calls to ignore. More...
 
static FILE * GNUNET_stderr
 File descriptor to use for "stderr", or NULL for none. More...
 
static struct LogDeflogdefs
 Dynamic array of logging definitions. More...
 
static int logdefs_size
 Allocated size of logdefs array (in units) More...
 
static int logdefs_len
 The number of units used in logdefs array. More...
 
static int gnunet_log_parsed
 GNUNET_YES if GNUNET_LOG environment variable is already parsed. More...
 
static int gnunet_force_log_parsed
 GNUNET_YES if GNUNET_FORCE_LOG environment variable is already parsed. More...
 
static int gnunet_force_log_present
 GNUNET_YES if at least one definition with forced == 1 is available. More...
 

Detailed Description

error handling API

Author
Christian Grothoff

Definition in file common_logging.c.

Macro Definition Documentation

◆ BULK_DELAY_THRESHOLD

#define BULK_DELAY_THRESHOLD   (12 * 60 * 60 * 1000LL * 1000LL)

After how many milliseconds do we always print that "message X was repeated N times"? Use 12h.

Definition at line 37 of file common_logging.c.

Referenced by mylog().

◆ BULK_REPEAT_THRESHOLD

#define BULK_REPEAT_THRESHOLD   1000

After how many repetitions do we always print that "message X was repeated N times"? (even if we have not yet reached the delay threshold)

Definition at line 44 of file common_logging.c.

Referenced by mylog().

◆ BULK_TRACK_SIZE

#define BULK_TRACK_SIZE   256

How many characters do we use for matching of bulk messages?

Definition at line 50 of file common_logging.c.

Referenced by flush_bulk().

◆ COMP_TRACK_SIZE

#define COMP_TRACK_SIZE   32

How many characters do we use for matching of bulk components?

Definition at line 56 of file common_logging.c.

◆ DATE_STR_SIZE

#define DATE_STR_SIZE   64

How many characters can a date/time string be at most?

Definition at line 62 of file common_logging.c.

Referenced by flush_bulk(), and mylog().

◆ ROTATION_KEEP

#define ROTATION_KEEP   3

How many log files to keep?

Definition at line 67 of file common_logging.c.

Referenced by log_rotate().

◆ PATH_MAX

#define PATH_MAX   4096

Assumed maximum path length (for the log file name).

Definition at line 73 of file common_logging.c.

Referenced by setup_log_file().

◆ LEN

#define LEN
Value:
GNUNET_MAX ((INET6_ADDRSTRLEN + 8), \
(1 + sizeof (struct sockaddr_un) - sizeof (sa_family_t)))
#define GNUNET_MAX(a, b)
Definition: gnunet_common.h:85

Referenced by GNUNET_a2s().

Function Documentation

◆ __attribute__() [1/3]

static GNUNET_THREAD_LOCAL char last_bulk [ 256 ] __attribute__ ( (nonstring)  )
static

The last "bulk" error message that we have been logging.

Note that this message maybe truncated to the first BULK_TRACK_SIZE characters, in which case it is NOT 0-terminated!

◆ get_type()

static enum GNUNET_ErrorType get_type ( const char *  log)
static

Convert a textual description of a loglevel to the respective GNUNET_GE_KIND.

Parameters
logloglevel to parse
Returns
GNUNET_GE_INVALID if log does not parse

Definition at line 263 of file common_logging.c.

References _, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_ERROR, GNUNET_ERROR_TYPE_INFO, GNUNET_ERROR_TYPE_INVALID, GNUNET_ERROR_TYPE_MESSAGE, GNUNET_ERROR_TYPE_NONE, GNUNET_ERROR_TYPE_UNSPECIFIED, and GNUNET_ERROR_TYPE_WARNING.

Referenced by GNUNET_log_setup(), and parse_definitions().

264 {
265  if (NULL == log)
267  if (0 == strcasecmp (log, _ ("DEBUG")))
269  if (0 == strcasecmp (log, _ ("INFO")))
270  return GNUNET_ERROR_TYPE_INFO;
271  if (0 == strcasecmp (log, _ ("MESSAGE")))
273  if (0 == strcasecmp (log, _ ("WARNING")))
275  if (0 == strcasecmp (log, _ ("ERROR")))
277  if (0 == strcasecmp (log, _ ("NONE")))
278  return GNUNET_ERROR_TYPE_NONE;
280 }
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
Here is the caller graph for this function:

◆ resize_logdefs()

static void resize_logdefs ( )
static

Utility function - reallocates logdefs array to be twice as large.

Definition at line 301 of file common_logging.c.

References GNUNET_realloc.

Referenced by add_definition().

302 {
303  logdefs_size = (logdefs_size + 1) * 2;
304  logdefs = GNUNET_realloc (logdefs, logdefs_size * sizeof (struct LogDef));
305 }
static int logdefs_size
Allocated size of logdefs array (in units)
static struct LogDef * logdefs
Dynamic array of logging definitions.
#define GNUNET_realloc(ptr, size)
Wrapper around realloc.
Represents a single logging definition.
Here is the caller graph for this function:

◆ log_rotate()

static void log_rotate ( const char *  new_name)
static

Rotate logs, deleting the oldest log.

Parameters
new_namenew name to add to the rotation

Definition at line 315 of file common_logging.c.

References GNUNET_free, GNUNET_strdup, ROTATION_KEEP, and UNLINK.

Referenced by setup_log_file().

316 {
317  static char *rotation[ROTATION_KEEP];
318  static unsigned int rotation_off;
319  char *discard;
320 
321  if ('\0' == *new_name)
322  return; /* not a real log file name */
323  discard = rotation[rotation_off % ROTATION_KEEP];
324  if (NULL != discard)
325  {
326  /* Note: can't log errors during logging (recursion!), so this
327  operation MUST silently fail... */
328  (void) UNLINK (discard);
329  GNUNET_free (discard);
330  }
331  rotation[rotation_off % ROTATION_KEEP] = GNUNET_strdup (new_name);
332  rotation_off++;
333 }
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define UNLINK(f)
Definition: plibc.h:666
#define ROTATION_KEEP
How many log files to keep?
#define GNUNET_free(ptr)
Wrapper around free.
Here is the caller graph for this function:

◆ setup_log_file()

static int setup_log_file ( const struct tm *  tm)
static

Setup the log file.

Parameters
tmtimestamp for which we should setup logging
Returns
GNUNET_OK on success, GNUNET_SYSERR on error

Definition at line 343 of file common_logging.c.

References fn, GNUNET_DISK_directory_create_for_file(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_strerror_file, GNUNET_OK, GNUNET_strdup, GNUNET_SYSERR, log_rotate(), OPEN, PATH_MAX, and STRERROR.

Referenced by GNUNET_log_setup(), and mylog().

344 {
345  static char last_fn[PATH_MAX + 1];
346  char fn[PATH_MAX + 1];
347  int altlog_fd;
348  int dup_return;
349  FILE *altlog;
350  char *leftsquare;
351 
352  if (NULL == log_file_name)
353  return GNUNET_SYSERR;
354  if (0 == strftime (fn, sizeof (fn), log_file_name, tm))
355  return GNUNET_SYSERR;
356  leftsquare = strrchr (fn, '[');
357  if ((NULL != leftsquare) && (']' == leftsquare[1]))
358  {
359  char *logfile_copy = GNUNET_strdup (fn);
360 
361  logfile_copy[leftsquare - fn] = '\0';
362  logfile_copy[leftsquare - fn + 1] = '\0';
363  snprintf (fn,
364  PATH_MAX,
365  "%s%d%s",
366  logfile_copy,
367  getpid (),
368  &logfile_copy[leftsquare - fn + 2]);
369  GNUNET_free (logfile_copy);
370  }
371  if (0 == strcmp (fn, last_fn))
372  return GNUNET_OK; /* no change */
373  log_rotate (last_fn);
374  strcpy (last_fn, fn);
376  {
377  fprintf (stderr,
378  "Failed to create directory for `%s': %s\n",
379  fn,
380  STRERROR (errno));
381  return GNUNET_SYSERR;
382  }
383 #if WINDOWS
384  altlog_fd =
385  OPEN (fn, O_APPEND | O_BINARY | O_WRONLY | O_CREAT, _S_IREAD | _S_IWRITE);
386 #else
387  altlog_fd = OPEN (fn,
388  O_APPEND | O_WRONLY | O_CREAT,
389  S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
390 #endif
391  if (-1 != altlog_fd)
392  {
393  if (NULL != GNUNET_stderr)
394  fclose (GNUNET_stderr);
395  dup_return = dup2 (altlog_fd, 2);
396  (void) close (altlog_fd);
397  if (-1 != dup_return)
398  {
399  altlog = fdopen (2, "ab");
400  if (NULL == altlog)
401  {
402  (void) close (2);
403  altlog_fd = -1;
404  }
405  }
406  else
407  {
408  altlog_fd = -1;
409  }
410  }
411  if (-1 == altlog_fd)
412  {
414  return GNUNET_SYSERR;
415  }
416  GNUNET_stderr = altlog;
417  return GNUNET_OK;
418 }
#define OPEN
Definition: plibc.h:651
#define STRERROR(i)
Definition: plibc.h:676
static char * log_file_name
Format string describing the name of the log file.
static FILE * GNUNET_stderr
File descriptor to use for "stderr", or NULL for none.
int GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:833
#define GNUNET_OK
Named constants for return values.
Definition: gnunet_common.h:78
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define PATH_MAX
Assumed maximum path length (for the log file name).
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level &#39;level&#39; that indicates a failure of the command &#39;cmd&#39; with the mess...
static char * fn
Filename of the unique file.
#define GNUNET_SYSERR
Definition: gnunet_common.h:79
static void log_rotate(const char *new_name)
Rotate logs, deleting the oldest log.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_definition()

static int add_definition ( const char *  component,
const char *  file,
const char *  function,
int  from_line,
int  to_line,
int  level,
int  force 
)
static

Utility function - adds a parsed definition to logdefs array.

Parameters
componentsee struct LogDef, can't be NULL
filesee struct LogDef, can't be NULL
functionsee struct LogDef, can't be NULL
from_linesee struct LogDef
to_linesee struct LogDef
levelsee struct LogDef, must be >= 0
forcesee struct LogDef
Returns
0 on success, regex-specific error otherwise

Definition at line 435 of file common_logging.c.

References LogDef::component_regex, LogDef::file_regex, LogDef::force, LogDef::from_line, LogDef::function_regex, LogDef::level, resize_logdefs(), and LogDef::to_line.

Referenced by parse_definitions().

442 {
443  struct LogDef n;
444  int r;
445 
446  if (logdefs_size == logdefs_len)
447  resize_logdefs ();
448  memset (&n, 0, sizeof (n));
449  if (0 == strlen (component))
450  component = (char *) ".*";
451  r = regcomp (&n.component_regex, (const char *) component, REG_NOSUB);
452  if (0 != r)
453  {
454  return r;
455  }
456  if (0 == strlen (file))
457  file = (char *) ".*";
458  r = regcomp (&n.file_regex, (const char *) file, REG_NOSUB);
459  if (0 != r)
460  {
461  regfree (&n.component_regex);
462  return r;
463  }
464  if ((NULL == function) || (0 == strlen (function)))
465  function = (char *) ".*";
466  r = regcomp (&n.function_regex, (const char *) function, REG_NOSUB);
467  if (0 != r)
468  {
469  regfree (&n.component_regex);
470  regfree (&n.file_regex);
471  return r;
472  }
473  n.from_line = from_line;
474  n.to_line = to_line;
475  n.level = level;
476  n.force = force;
477  logdefs[logdefs_len++] = n;
478  return 0;
479 }
static int logdefs_len
The number of units used in logdefs array.
static int logdefs_size
Allocated size of logdefs array (in units)
static struct LogDef * logdefs
Dynamic array of logging definitions.
int force
1 if this definition comes from GNUNET_FORCE_LOG, which means that it overrides any configuration opt...
int to_line
Highest line at which this definition matches.
int from_line
Lowest line at which this definition matches.
static char * component
Running component.
static void resize_logdefs()
Utility function - reallocates logdefs array to be twice as large.
Represents a single logging definition.
int level
Maximal log level allowed for calls that match this definition.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_get_log_call_status()

int GNUNET_get_log_call_status ( int  caller_level,
const char *  comp,
const char *  file,
const char *  function,
int  line 
)

Decides whether a particular logging call should or should not be allowed to be made.

Used internally by GNUNET_log*()

Parameters
caller_levelloglevel the caller wants to use
compcomponent name the caller uses (NULL means that global component name is used)
filefile name containing the logging call, usually FILE
functionfunction which tries to make a logging call, usually FUNCTION
lineline at which the call is made, usually LINE
Returns
0 to disallow the call, 1 to allow it

Definition at line 496 of file common_logging.c.

References component_nopid, LogDef::component_regex, LogDef::file_regex, LogDef::force, LogDef::from_line, LogDef::function_regex, GNUNET_ERROR_TYPE_MESSAGE, GNUNET_NO, LogDef::level, logdefs_len, min_level, and LogDef::to_line.

Referenced by GCC_debug(), GCCH_debug(), GCT_debug(), and get_nick_record().

501 {
502  struct LogDef *ld;
503  int i;
504  int force_only;
505 
506  if (NULL == comp)
507  /* Use default component */
508  comp = component_nopid;
509 
510  /* We have no definitions to override globally configured log level,
511  * so just use it right away.
512  */
513  if ((min_level >= 0) && (GNUNET_NO == gnunet_force_log_present))
514  return caller_level <= min_level;
515 
516  /* Only look for forced definitions? */
517  force_only = min_level >= 0;
518  for (i = 0; i < logdefs_len; i++)
519  {
520  ld = &logdefs[i];
521  if (((! force_only) || ld->force) &&
522  (line >= ld->from_line && line <= ld->to_line) &&
523  (0 == regexec (&ld->component_regex, comp, 0, NULL, 0)) &&
524  (0 == regexec (&ld->file_regex, file, 0, NULL, 0)) &&
525  (0 == regexec (&ld->function_regex, function, 0, NULL, 0)))
526  {
527  /* We're finished */
528  return caller_level <= ld->level;
529  }
530  }
531  /* No matches - use global level, if defined */
532  if (min_level >= 0)
533  return caller_level <= min_level;
534  /* All programs/services previously defaulted to WARNING.
535  * Now *we* default to WARNING, and THEY default to NULL.
536  * Or rather we default to MESSAGE, since things aren't always bad.
537  */
538  return caller_level <= GNUNET_ERROR_TYPE_MESSAGE;
539 }
static int logdefs_len
The number of units used in logdefs array.
static struct LogDef * logdefs
Dynamic array of logging definitions.
#define GNUNET_NO
Definition: gnunet_common.h:81
int force
1 if this definition comes from GNUNET_FORCE_LOG, which means that it overrides any configuration opt...
int to_line
Highest line at which this definition matches.
int from_line
Lowest line at which this definition matches.
static char * line
Desired phone line (string to be converted to a hash).
static int gnunet_force_log_present
GNUNET_YES if at least one definition with forced == 1 is available.
regex_t function_regex
Function name regex.
regex_t component_regex
Component name regex.
Represents a single logging definition.
regex_t file_regex
File name regex.
static enum GNUNET_ErrorType min_level
Minimum log level.
int level
Maximal log level allowed for calls that match this definition.
static char * component_nopid
Running component (without pid).
Here is the caller graph for this function:

◆ parse_definitions()

static int parse_definitions ( const char *  constname,
int  force 
)
static

Utility function - parses a definition.

Definition format: component;file;function;from_line-to_line;level[/component...] All entries are mandatory, but may be empty. Empty entries for component, file and function are treated as "matches anything". Empty line entry is treated as "from 0 to INT_MAX" Line entry with only one line is treated as "this line only" Entry for level MUST NOT be empty. Entries for component, file and function that consist of a single character "*" are treated (at the moment) the same way empty entries are treated (wildcard matching is not implemented (yet?)). file entry is matched to the end of FILE. That is, it might be a base name, or a base name with leading directory names (some compilers define FILE to absolute file path).

Parameters
constnamename of the environment variable from which to get the string to be parsed
force1 if definitions found in constname are to be forced
Returns
number of added definitions

Definition at line 566 of file common_logging.c.

References _, add_definition(), LogDef::from_line, get_type(), getenv(), GNUNET_ERROR_TYPE_INVALID, GNUNET_ERROR_TYPE_UNSPECIFIED, GNUNET_free, GNUNET_strdup, INT_MAX, LogDef::level, p, start, state, t, and LogDef::to_line.

Referenced by parse_all_definitions().

567 {
568  char *def;
569  const char *tmp;
570  char *comp = NULL;
571  char *file = NULL;
572  char *function = NULL;
573  char *p;
574  char *start;
575  char *t;
576  short state;
577  int level;
578  int from_line, to_line;
579  int counter = 0;
580  int keep_looking = 1;
581 
582  tmp = getenv (constname);
583  if (NULL == tmp)
584  return 0;
585  def = GNUNET_strdup (tmp);
586  from_line = 0;
587  to_line = INT_MAX;
588  for (p = def, state = 0, start = def; keep_looking; p++)
589  {
590  switch (p[0])
591  {
592  case ';': /* found a field separator */
593  p[0] = '\0';
594  switch (state)
595  {
596  case 0: /* within a component name */
597  comp = start;
598  break;
599  case 1: /* within a file name */
600  file = start;
601  break;
602  case 2: /* within a function name */
603  /* after a file name there must be a function name */
604  function = start;
605  break;
606  case 3: /* within a from-to line range */
607  if (strlen (start) > 0)
608  {
609  errno = 0;
610  from_line = strtol (start, &t, 10);
611  if ((0 != errno) || (from_line < 0))
612  {
613  GNUNET_free (def);
614  return counter;
615  }
616  if ((t < p) && ('-' == t[0]))
617  {
618  errno = 0;
619  start = t + 1;
620  to_line = strtol (start, &t, 10);
621  if ((0 != errno) || (to_line < 0) || (t != p))
622  {
623  GNUNET_free (def);
624  return counter;
625  }
626  }
627  else /* one number means "match this line only" */
628  to_line = from_line;
629  }
630  else /* default to 0-max */
631  {
632  from_line = 0;
633  to_line = INT_MAX;
634  }
635  break;
636  default:
637  fprintf (
638  stderr,
639  _ ("ERROR: Unable to parse log definition: Syntax error at `%s'.\n"),
640  p);
641  break;
642  }
643  start = p + 1;
644  state++;
645  break;
646  case '\0': /* found EOL */
647  keep_looking = 0;
648  /* fall through to '/' */
649  case '/': /* found a definition separator */
650  switch (state)
651  {
652  case 4: /* within a log level */
653  p[0] = '\0';
654  state = 0;
655  level = get_type ((const char *) start);
656  if ((GNUNET_ERROR_TYPE_INVALID == level) ||
657  (GNUNET_ERROR_TYPE_UNSPECIFIED == level) ||
658  (0 != add_definition (comp,
659  file,
660  function,
661  from_line,
662  to_line,
663  level,
664  force)))
665  {
666  GNUNET_free (def);
667  return counter;
668  }
669  counter++;
670  start = p + 1;
671  break;
672  default:
673  fprintf (
674  stderr,
675  _ ("ERROR: Unable to parse log definition: Syntax error at `%s'.\n"),
676  p);
677  break;
678  }
679  default:
680  break;
681  }
682  }
683  GNUNET_free (def);
684  return counter;
685 }
static int start
Set if we are to start default services (including ARM).
Definition: gnunet-arm.c:39
int force
1 if this definition comes from GNUNET_FORCE_LOG, which means that it overrides any configuration opt...
static struct GNUNET_SCHEDULER_Task * t
Main task.
int to_line
Highest line at which this definition matches.
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
int from_line
Lowest line at which this definition matches.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
#define INT_MAX
enum State state
current state of profiling
static struct GNUNET_OS_Process * p
Helper process we started.
Definition: gnunet-qr.c:59
static int add_definition(const char *component, const char *file, const char *function, int from_line, int to_line, int level, int force)
Utility function - adds a parsed definition to logdefs array.
char * getenv()
static enum GNUNET_ErrorType get_type(const char *log)
Convert a textual description of a loglevel to the respective GNUNET_GE_KIND.
int level
Maximal log level allowed for calls that match this definition.
#define GNUNET_free(ptr)
Wrapper around free.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ parse_all_definitions()

static void parse_all_definitions ( )
static

Utility function - parses GNUNET_LOG and GNUNET_FORCE_LOG.

Definition at line 692 of file common_logging.c.

References GNUNET_NO, GNUNET_YES, and parse_definitions().

Referenced by GNUNET_log_setup().

693 {
696  parse_definitions ("GNUNET_FORCE_LOG", 1) > 0 ? GNUNET_YES : GNUNET_NO;
698 
700  parse_definitions ("GNUNET_LOG", 0);
702 }
static int parse_definitions(const char *constname, int force)
Utility function - parses a definition.
#define GNUNET_NO
Definition: gnunet_common.h:81
static int gnunet_force_log_present
GNUNET_YES if at least one definition with forced == 1 is available.
static int gnunet_log_parsed
GNUNET_YES if GNUNET_LOG environment variable is already parsed.
#define GNUNET_YES
Definition: gnunet_common.h:80
static int gnunet_force_log_parsed
GNUNET_YES if GNUNET_FORCE_LOG environment variable is already parsed.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ output_message()

static void output_message ( enum GNUNET_ErrorType  kind,
const char *  comp,
const char *  datestr,
const char *  msg 
)
static

Actually output the log message.

Parameters
kindhow severe was the issue
compcomponent responsible
datestrcurrent date/time
msgthe actual message

Definition at line 821 of file common_logging.c.

References current_async_scope, end, FPRINTF, GNUNET_assert, GNUNET_ERROR_TYPE_MESSAGE, GNUNET_error_type_to_string(), GNUNET_STRINGS_data_to_string(), GNUNET_THREAD_LOCAL, GNUNET_YES, GNUNET_AsyncScopeSave::have_scope, CustomLogger::logger, CustomLogger::logger_cls, loggers, CustomLogger::next, and GNUNET_AsyncScopeSave::scope_id.

Referenced by flush_bulk(), and mylog().

825 {
826  struct CustomLogger *pos;
827 
828 #if WINDOWS
829  EnterCriticalSection (&output_message_cs);
830 #endif
831  /* only use the standard logger if no custom loggers are present */
832  if ((NULL != GNUNET_stderr) && (NULL == loggers))
833  {
834  if (kind == GNUNET_ERROR_TYPE_MESSAGE)
835  {
836  /* The idea here is to produce "normal" output messages
837  * for end users while still having the power of the
838  * logging engine for developer needs. So ideally this
839  * is what it should look like when CLI tools are used
840  * interactively, yet the same message shouldn't look
841  * this way if the output is going to logfiles or robots
842  * instead.
843  */
844  FPRINTF (GNUNET_stderr, "* %s", msg);
845  }
847  {
848  static GNUNET_THREAD_LOCAL char id_buf[27];
849  char *end;
850 
851  /* We're logging, so skip_log must be currently 0. */
852  skip_log = 100;
854  sizeof (struct GNUNET_AsyncScopeId),
855  id_buf,
856  sizeof (id_buf) - 1);
857  GNUNET_assert (NULL != end);
858  *end = '\0';
859  skip_log = 0;
861  "%s %s(%s) %s %s",
862  datestr,
863  comp,
864  id_buf,
866  msg);
867  }
868  else
869  {
871  "%s %s %s %s",
872  datestr,
873  comp,
875  msg);
876  }
877  fflush (GNUNET_stderr);
878  }
879  pos = loggers;
880  while (NULL != pos)
881  {
882  pos->logger (pos->logger_cls, kind, comp, datestr, msg);
883  pos = pos->next;
884  }
885 #if WINDOWS
886  LeaveCriticalSection (&output_message_cs);
887 #endif
888 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
struct CustomLogger * next
This is a linked list.
#define GNUNET_THREAD_LOCAL
Definition: platform.h:295
#define FPRINTF
Definition: plibc.h:683
const char * GNUNET_error_type_to_string(enum GNUNET_ErrorType kind)
Convert error type to string.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
static FILE * GNUNET_stderr
File descriptor to use for "stderr", or NULL for none.
void * logger_cls
Closure for logger.
Identifier for an asynchronous execution context.
Linked list of active loggers.
static struct CustomLogger * loggers
Linked list of our custom loggres.
int have_scope
GNUNET_YES unless this saved scope is the unnamed root scope.
struct GNUNET_AsyncScopeId scope_id
Saved scope.
#define GNUNET_YES
Definition: gnunet_common.h:80
static GNUNET_THREAD_LOCAL int skip_log
Number of log calls to ignore.
static __thread struct GNUNET_AsyncScopeSave current_async_scope
Asynchronous scope of the current thread, or NULL if we have not entered an async scope yet...
char * GNUNET_STRINGS_data_to_string(const void *data, size_t size, char *out, size_t out_size)
Convert binary data to ASCII encoding using CrockfordBase32.
Definition: strings.c:924
GNUNET_Logger logger
Log function.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ flush_bulk()

static void flush_bulk ( const char *  datestr)
static

Flush an existing bulk report to the output.

Parameters
datestrour current timestamp

Definition at line 897 of file common_logging.c.

References _, GNUNET_TIME_Absolute::abs_value_us, BULK_TRACK_SIZE, DATE_STR_SIZE, GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_YES, last_bulk_time, msg, and output_message().

Referenced by mylog().

898 {
899  char msg[DATE_STR_SIZE + BULK_TRACK_SIZE + 256];
900  int rev;
901  char *last;
902  const char *ft;
903 
904  if ((0 == last_bulk_time.abs_value_us) || (0 == last_bulk_repeat))
905  return;
906  rev = 0;
907  last = memchr (last_bulk, '\0', BULK_TRACK_SIZE);
908  if (last == NULL)
909  last = &last_bulk[BULK_TRACK_SIZE - 1];
910  else if (last != last_bulk)
911  last--;
912  if (last[0] == '\n')
913  {
914  rev = 1;
915  last[0] = '\0';
916  }
917  ft =
920  GNUNET_YES);
921  snprintf (msg,
922  sizeof (msg),
923  _ ("Message `%.*s' repeated %u times in the last %s\n"),
925  last_bulk,
927  ft);
928  if (rev == 1)
929  last[0] = '\n';
932  last_bulk_repeat = 0;
933 }
#define DATE_STR_SIZE
How many characters can a date/time string be at most?
static GNUNET_THREAD_LOCAL struct GNUNET_TIME_Absolute last_bulk_time
Time of the last bulk error message (0 for none)
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
#define BULK_TRACK_SIZE
How many characters do we use for matching of bulk messages?
uint64_t abs_value_us
The actual value.
#define _(String)
GNU gettext support macro.
Definition: platform.h:208
static GNUNET_THREAD_LOCAL char last_bulk_comp[32+1]
Component when the last bulk was logged.
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:727
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
static void output_message(enum GNUNET_ErrorType kind, const char *comp, const char *datestr, const char *msg)
Actually output the log message.
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
static GNUNET_THREAD_LOCAL unsigned int last_bulk_repeat
Number of times that bulk message has been repeated since.
#define GNUNET_YES
Definition: gnunet_common.h:80
static GNUNET_THREAD_LOCAL enum GNUNET_ErrorType last_bulk_kind
Type of the last bulk message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mylog()

static void mylog ( enum GNUNET_ErrorType  kind,
const char *  comp,
const char *  message,
va_list  va 
)
static

Output a log message using the default mechanism.

Parameters
kindhow severe was the issue
compcomponent responsible
messagethe actual message
vaarguments to the format string "message"

Definition at line 982 of file common_logging.c.

References GNUNET_TIME_Absolute::abs_value_us, buf, BULK_DELAY_THRESHOLD, BULK_REPEAT_THRESHOLD, DATE_STR_SIZE, flush_bulk(), GNUNET_assert, GNUNET_ERROR_TYPE_BULK, GNUNET_strlcpy(), GNUNET_TIME_absolute_get(), GNUNET_TIME_absolute_get_duration(), GNUNET_TIME_get_offset(), last_bulk_time, output_message(), pc, GNUNET_TIME_Relative::rel_value_us, setup_log_file(), size, and VSNPRINTF.

Referenced by GNUNET_log_from_nocheck(), and GNUNET_log_nocheck().

986 {
987  char date[DATE_STR_SIZE];
988  char date2[DATE_STR_SIZE];
989  struct tm *tmptr;
990  size_t size;
991  va_list vacp;
992 
993  va_copy (vacp, va);
994  size = VSNPRINTF (NULL, 0, message, vacp) + 1;
995  GNUNET_assert (0 != size);
996  va_end (vacp);
997  memset (date, 0, DATE_STR_SIZE);
998  {
999  char buf[size];
1000  long long offset;
1001 #ifdef WINDOWS
1002  LARGE_INTEGER pc;
1003  time_t timetmp;
1004 
1005  offset = GNUNET_TIME_get_offset ();
1006  time (&timetmp);
1007  timetmp += offset / 1000;
1008  tmptr = localtime (&timetmp);
1009  pc.QuadPart = 0;
1010  QueryPerformanceCounter (&pc);
1011  if (NULL == tmptr)
1012  {
1013  strcpy (date, "localtime error");
1014  }
1015  else
1016  {
1017  if (0 ==
1018  strftime (date2, DATE_STR_SIZE, "%b %d %H:%M:%S-%%020llu", tmptr))
1019  abort ();
1020  if (0 > snprintf (date,
1021  sizeof (date),
1022  date2,
1023  (long long) (pc.QuadPart /
1024  (performance_frequency.QuadPart / 1000))))
1025  abort ();
1026  }
1027 #else
1028  struct timeval timeofday;
1029 
1030  gettimeofday (&timeofday, NULL);
1031  offset = GNUNET_TIME_get_offset ();
1032  if (offset > 0)
1033  {
1034  timeofday.tv_sec += offset / 1000LL;
1035  timeofday.tv_usec += (offset % 1000LL) * 1000LL;
1036  if (timeofday.tv_usec > 1000000LL)
1037  {
1038  timeofday.tv_usec -= 1000000LL;
1039  timeofday.tv_sec++;
1040  }
1041  }
1042  else
1043  {
1044  timeofday.tv_sec += offset / 1000LL;
1045  if (timeofday.tv_usec > -(offset % 1000LL) * 1000LL)
1046  {
1047  timeofday.tv_usec += (offset % 1000LL) * 1000LL;
1048  }
1049  else
1050  {
1051  timeofday.tv_usec += 1000000LL + (offset % 1000LL) * 1000LL;
1052  timeofday.tv_sec--;
1053  }
1054  }
1055  tmptr = localtime (&timeofday.tv_sec);
1056  if (NULL == tmptr)
1057  {
1058  strcpy (date, "localtime error");
1059  }
1060  else
1061  {
1062  if (0 == strftime (date2, DATE_STR_SIZE, "%b %d %H:%M:%S-%%06u", tmptr))
1063  abort ();
1064  if (0 > snprintf (date, sizeof (date), date2, timeofday.tv_usec))
1065  abort ();
1066  }
1067 #endif
1068  VSNPRINTF (buf, size, message, va);
1069 #if ! (defined(GNUNET_CULL_LOGGING) || TALER_WALLET_ONLY)
1070  if (NULL != tmptr)
1071  (void) setup_log_file (tmptr);
1072 #endif
1073  if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) &&
1074  (0 != last_bulk_time.abs_value_us) &&
1075  (0 == strncmp (buf, last_bulk, sizeof (last_bulk))))
1076  {
1077  last_bulk_repeat++;
1081  flush_bulk (date);
1082  return;
1083  }
1084  flush_bulk (date);
1085  GNUNET_strlcpy (last_bulk, buf, sizeof (last_bulk));
1086  last_bulk_repeat = 0;
1087  last_bulk_kind = kind;
1089  GNUNET_strlcpy (last_bulk_comp, comp, sizeof (last_bulk_comp));
1090  output_message (kind, comp, date, buf);
1091  }
1092 }
#define DATE_STR_SIZE
How many characters can a date/time string be at most?
static GNUNET_THREAD_LOCAL struct GNUNET_TIME_Absolute last_bulk_time
Time of the last bulk error message (0 for none)
uint64_t rel_value_us
The actual value.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define BULK_DELAY_THRESHOLD
After how many milliseconds do we always print that "message X was repeated N times"? Use 12h.
uint64_t abs_value_us
The actual value.
static GNUNET_THREAD_LOCAL char last_bulk_comp[32+1]
Component when the last bulk was logged.
static char buf[2048]
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:118
static unsigned int size
Size of the "table".
Definition: peer.c:67
long long GNUNET_TIME_get_offset(void)
Get the timestamp offset for this instance.
Definition: time.c:65
#define VSNPRINTF(str, size, fmt, a)
Definition: plibc.h:687
static void output_message(enum GNUNET_ErrorType kind, const char *comp, const char *datestr, const char *msg)
Actually output the log message.
static struct GNUNET_FS_PublishContext * pc
Handle to FS-publishing operation.
#define BULK_REPEAT_THRESHOLD
After how many repetitions do we always print that "message X was repeated N times"? (even if we have not yet reached the delay threshold)
struct GNUNET_TIME_Relative GNUNET_TIME_absolute_get_duration(struct GNUNET_TIME_Absolute whence)
Get the duration of an operation as the difference of the current time and the given start time "henc...
Definition: time.c:373
static GNUNET_THREAD_LOCAL unsigned int last_bulk_repeat
Number of times that bulk message has been repeated since.
static int setup_log_file(const struct tm *tm)
Setup the log file.
static void flush_bulk(const char *datestr)
Flush an existing bulk report to the output.
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
static GNUNET_THREAD_LOCAL enum GNUNET_ErrorType last_bulk_kind
Type of the last bulk message.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_log_nocheck()

void GNUNET_log_nocheck ( enum GNUNET_ErrorType  kind,
const char *  message,
  ... 
)

Main log function.

Parameters
kindhow serious is the error?
messagewhat is the message (format string)
...arguments for format string

Definition at line 1103 of file common_logging.c.

References mylog().

1104 {
1105  va_list va;
1106 
1107  va_start (va, message);
1108  mylog (kind, component, message, va);
1109  va_end (va);
1110 }
static char * component
Running component.
static void mylog(enum GNUNET_ErrorType kind, const char *comp, const char *message, va_list va)
Output a log message using the default mechanism.
Here is the call graph for this function:

◆ GNUNET_async_scope_enter()

void GNUNET_async_scope_enter ( const struct GNUNET_AsyncScopeId aid,
struct GNUNET_AsyncScopeSave old_scope 
)

Set the async scope for the current thread.

Parameters
aidthe async scope identifier
old_scope[out]location to save the old scope

Definition at line 1545 of file common_logging.c.

References current_async_scope, GNUNET_YES, GNUNET_AsyncScopeSave::have_scope, and GNUNET_AsyncScopeSave::scope_id.

Referenced by GNUNET_SCHEDULER_begin_async_scope(), and GNUNET_SCHEDULER_do_work().

1547 {
1548  *old_scope = current_async_scope;
1551 }
int have_scope
GNUNET_YES unless this saved scope is the unnamed root scope.
struct GNUNET_AsyncScopeId scope_id
Saved scope.
#define GNUNET_YES
Definition: gnunet_common.h:80
static __thread struct GNUNET_AsyncScopeSave current_async_scope
Asynchronous scope of the current thread, or NULL if we have not entered an async scope yet...
Here is the caller graph for this function:

◆ GNUNET_async_scope_restore()

void GNUNET_async_scope_restore ( struct GNUNET_AsyncScopeSave old_scope)

Clear the current thread's async scope.

Parameters
old_scopescope to restore

Definition at line 1560 of file common_logging.c.

References current_async_scope.

Referenced by GNUNET_SCHEDULER_do_work().

1561 {
1562  current_async_scope = *old_scope;
1563 }
static __thread struct GNUNET_AsyncScopeSave current_async_scope
Asynchronous scope of the current thread, or NULL if we have not entered an async scope yet...
Here is the caller graph for this function:

◆ GNUNET_async_scope_fresh()

void GNUNET_async_scope_fresh ( struct GNUNET_AsyncScopeId aid_ret)

Generate a fresh async scope identifier.

Parameters
[out]aid_retpointer to where the result is stored

Definition at line 1572 of file common_logging.c.

References GNUNET_CRYPTO_QUALITY_WEAK, and GNUNET_CRYPTO_random_block().

1573 {
1575  aid_ret,
1576  sizeof (struct GNUNET_AsyncScopeId));
1577 }
Identifier for an asynchronous execution context.
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).
Here is the call graph for this function:

◆ GNUNET_async_scope_get()

void GNUNET_async_scope_get ( struct GNUNET_AsyncScopeSave scope_ret)

Get the current async scope.

Parameters
[out]scope_retpointer to where the result is stored

Definition at line 1586 of file common_logging.c.

References current_async_scope.

Referenced by add_without_sets(), GNUNET_CURL_job_add2(), GNUNET_SCHEDULER_add_at_with_priority(), GNUNET_SCHEDULER_add_select(), GNUNET_SCHEDULER_add_shutdown(), and GNUNET_SCHEDULER_do_work().

1587 {
1588  *scope_ret = current_async_scope;
1589 }
static __thread struct GNUNET_AsyncScopeSave current_async_scope
Asynchronous scope of the current thread, or NULL if we have not entered an async scope yet...
Here is the caller graph for this function:

◆ __attribute__() [2/3]

void __attribute__ ( (constructor)  )

Initializer.

Definition at line 1595 of file common_logging.c.

References GNInitWinEnv(), and GNUNET_abort_().

1596 {
1597  GNUNET_stderr = stderr;
1598 #ifdef MINGW
1599  GNInitWinEnv (NULL);
1600 #endif
1601 #if WINDOWS
1602  if (! InitializeCriticalSectionAndSpinCount (&output_message_cs, 0x00000400))
1603  GNUNET_abort_ ();
1604 #endif
1605 }
static FILE * GNUNET_stderr
File descriptor to use for "stderr", or NULL for none.
void GNUNET_abort_()
Abort the process, generate a core dump if possible.
int GNInitWinEnv()
Here is the call graph for this function:

◆ __attribute__() [3/3]

void __attribute__ ( (destructor)  )

Destructor.

Definition at line 1611 of file common_logging.c.

References GNShutdownWinEnv().

1612 {
1613 #if WINDOWS
1614  DeleteCriticalSection (&output_message_cs);
1615 #endif
1616 #ifdef MINGW
1617  GNShutdownWinEnv ();
1618 #endif
1619 }
void GNShutdownWinEnv()
Here is the call graph for this function:

Variable Documentation

◆ current_async_scope

__thread struct GNUNET_AsyncScopeSave current_async_scope
static

Asynchronous scope of the current thread, or NULL if we have not entered an async scope yet.

Definition at line 103 of file common_logging.c.

Referenced by GNUNET_async_scope_enter(), GNUNET_async_scope_get(), GNUNET_async_scope_restore(), and output_message().

◆ last_bulk_kind

GNUNET_THREAD_LOCAL enum GNUNET_ErrorType last_bulk_kind
static

Type of the last bulk message.

Definition at line 116 of file common_logging.c.

◆ last_bulk_time

GNUNET_THREAD_LOCAL struct GNUNET_TIME_Absolute last_bulk_time
static

Time of the last bulk error message (0 for none)

Definition at line 121 of file common_logging.c.

Referenced by flush_bulk(), and mylog().

◆ last_bulk_repeat

GNUNET_THREAD_LOCAL unsigned int last_bulk_repeat
static

Number of times that bulk message has been repeated since.

Definition at line 126 of file common_logging.c.

◆ last_bulk_comp

GNUNET_THREAD_LOCAL char last_bulk_comp[32+1]
static

Component when the last bulk was logged.

Will be 0-terminated.

Definition at line 131 of file common_logging.c.

◆ component

char* component
static

Running component.

Definition at line 136 of file common_logging.c.

◆ component_nopid

char* component_nopid
static

Running component (without pid).

Definition at line 141 of file common_logging.c.

Referenced by GNUNET_get_log_call_status(), and GNUNET_log_from_nocheck().

◆ log_file_name

char* log_file_name
static

Format string describing the name of the log file.

Definition at line 146 of file common_logging.c.

◆ min_level

enum GNUNET_ErrorType min_level
static

Minimum log level.

Definition at line 151 of file common_logging.c.

Referenced by GNUNET_get_log_call_status().

◆ loggers

struct CustomLogger* loggers
static

Linked list of our custom loggres.

Definition at line 156 of file common_logging.c.

Referenced by GNUNET_logger_add(), GNUNET_logger_remove(), and output_message().

◆ skip_log

GNUNET_THREAD_LOCAL int skip_log = 0
static

Number of log calls to ignore.

Definition at line 161 of file common_logging.c.

Referenced by GNUNET_get_log_skip(), and GNUNET_log_skip().

◆ GNUNET_stderr

FILE* GNUNET_stderr
static

File descriptor to use for "stderr", or NULL for none.

Definition at line 166 of file common_logging.c.

◆ logdefs

struct LogDef* logdefs
static

Dynamic array of logging definitions.

Definition at line 219 of file common_logging.c.

◆ logdefs_size

int logdefs_size
static

Allocated size of logdefs array (in units)

Definition at line 224 of file common_logging.c.

◆ logdefs_len

int logdefs_len
static

The number of units used in logdefs array.

Definition at line 229 of file common_logging.c.

Referenced by GNUNET_get_log_call_status().

◆ gnunet_log_parsed

int gnunet_log_parsed
static

GNUNET_YES if GNUNET_LOG environment variable is already parsed.

Definition at line 234 of file common_logging.c.

◆ gnunet_force_log_parsed

int gnunet_force_log_parsed
static

GNUNET_YES if GNUNET_FORCE_LOG environment variable is already parsed.

Definition at line 239 of file common_logging.c.

◆ gnunet_force_log_present

int gnunet_force_log_present
static

GNUNET_YES if at least one definition with forced == 1 is available.

Definition at line 244 of file common_logging.c.