GNUnet  0.16.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 enum GNUNET_ErrorType get_type (const char *log)
 Convert a textual description of a loglevel to the respective enumeration type. More...
 
void GNUNET_abort_ ()
 Abort the process, generate a core dump if possible. More...
 
static void resize_logdefs (void)
 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...
 
const char * GNUNET_b2s (const void *buf, size_t buf_size)
 Convert a buffer to an 8-character string representative of the contents. 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 GNUNET_THREAD_LOCAL 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 char last_bulk[256] __nonstring
 The last "bulk" error message that we have been logging. 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.

◆ 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.

◆ 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.

◆ 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.

◆ ROTATION_KEEP

#define ROTATION_KEEP   3

How many log files to keep?

Definition at line 67 of file common_logging.c.

◆ PATH_MAX

#define PATH_MAX   4096

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

Definition at line 73 of file common_logging.c.

◆ LEN

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

Function Documentation

◆ get_type()

static enum GNUNET_ErrorType get_type ( const char *  log)
static

Convert a textual description of a loglevel to the respective enumeration type.

Parameters
logloglevel to parse
Returns
GNUNET_ERROR_TYPE_INVALID if log does not parse

Definition at line 243 of file common_logging.c.

256 {
257  if (NULL == log)
259  if (0 == strcasecmp (log, "DEBUG"))
261  if (0 == strcasecmp (log, "INFO"))
262  return GNUNET_ERROR_TYPE_INFO;
263  if (0 == strcasecmp (log, "MESSAGE"))
265  if (0 == strcasecmp (log, "WARNING"))
267  if (0 == strcasecmp (log, "ERROR"))
269  if (0 == strcasecmp (log, "NONE"))
270  return GNUNET_ERROR_TYPE_NONE;
272 }
@ GNUNET_ERROR_TYPE_UNSPECIFIED
@ GNUNET_ERROR_TYPE_WARNING
@ GNUNET_ERROR_TYPE_ERROR
@ GNUNET_ERROR_TYPE_NONE
@ GNUNET_ERROR_TYPE_INVALID
@ GNUNET_ERROR_TYPE_MESSAGE
@ GNUNET_ERROR_TYPE_DEBUG
@ GNUNET_ERROR_TYPE_INFO

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().

Here is the caller graph for this function:

◆ resize_logdefs()

static void resize_logdefs ( void  )
static

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

Definition at line 290 of file common_logging.c.

291 {
292  logdefs_size = (logdefs_size + 1) * 2;
293  logdefs = GNUNET_realloc (logdefs, logdefs_size * sizeof(struct LogDef));
294 }
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.

References GNUNET_realloc, logdefs, and logdefs_size.

Referenced by add_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 303 of file common_logging.c.

304 {
305  static char *rotation[ROTATION_KEEP];
306  static unsigned int rotation_off;
307  char *discard;
308 
309  if ('\0' == *new_name)
310  return; /* not a real log file name */
311  discard = rotation[rotation_off % ROTATION_KEEP];
312  if (NULL != discard)
313  {
314  /* Note: can't log errors during logging (recursion!), so this
315  operation MUST silently fail... */
316  (void) unlink (discard);
317  GNUNET_free (discard);
318  }
319  rotation[rotation_off % ROTATION_KEEP] = GNUNET_strdup (new_name);
320  rotation_off++;
321 }
#define ROTATION_KEEP
How many log files to keep?
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_free(ptr)
Wrapper around free.

References GNUNET_free, GNUNET_strdup, and ROTATION_KEEP.

Referenced by setup_log_file().

Here is the caller graph for this function:

◆ GNUNET_b2s()

const char* GNUNET_b2s ( const void *  buf,
size_t  buf_size 
)

Convert a buffer to an 8-character string representative of the contents.

This is used for logging binary data when debugging.

Parameters
bufbuffer to log
buf_sizenumber of bytes in buf
Returns
text representation of buf, valid until next call to this function

Definition at line 325 of file common_logging.c.

327 {
328  static GNUNET_THREAD_LOCAL char ret[9];
329  struct GNUNET_HashCode hc;
330  char *tmp;
331 
333  buf_size,
334  &hc);
336  sizeof (hc));
337  memcpy (ret,
338  tmp,
339  8);
340  GNUNET_free (tmp);
341  ret[8] = '\0';
342  return ret;
343 }
static int ret
Return value of the commandline.
Definition: gnunet-abd.c:81
static char buf[2048]
void GNUNET_CRYPTO_hash(const void *block, size_t size, struct GNUNET_HashCode *ret)
Compute hash of a given block.
Definition: crypto_hash.c:41
char * GNUNET_STRINGS_data_to_string_alloc(const void *buf, size_t size)
Return the base32crockford encoding of the given buffer.
Definition: strings.c:764
#define GNUNET_THREAD_LOCAL
Definition: platform.h:246
A 512-bit hashcode.

References buf, GNUNET_CRYPTO_hash(), GNUNET_free, GNUNET_STRINGS_data_to_string_alloc(), GNUNET_THREAD_LOCAL, and ret.

Here is the call 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 353 of file common_logging.c.

354 {
355  static char last_fn[PATH_MAX + 1];
356  char fn[PATH_MAX + 1];
357  int altlog_fd;
358  int dup_return;
359  FILE *altlog;
360  char *leftsquare;
361 
362  if (NULL == log_file_name)
363  return GNUNET_SYSERR;
364  if (0 == strftime (fn, sizeof(fn), log_file_name, tm))
365  return GNUNET_SYSERR;
366  leftsquare = strrchr (fn, '[');
367  if ((NULL != leftsquare) && (']' == leftsquare[1]))
368  {
369  char *logfile_copy = GNUNET_strdup (fn);
370 
371  logfile_copy[leftsquare - fn] = '\0';
372  logfile_copy[leftsquare - fn + 1] = '\0';
373  snprintf (fn,
374  PATH_MAX,
375  "%s%d%s",
376  logfile_copy,
377  getpid (),
378  &logfile_copy[leftsquare - fn + 2]);
379  GNUNET_free (logfile_copy);
380  }
381  if (0 == strcmp (fn, last_fn))
382  return GNUNET_OK; /* no change */
383  log_rotate (last_fn);
384  strcpy (last_fn, fn);
386  {
387  fprintf (stderr,
388  "Failed to create directory for `%s': %s\n",
389  fn,
390  strerror (errno));
391  return GNUNET_SYSERR;
392  }
393  altlog_fd = open (fn,
394  O_APPEND | O_WRONLY | O_CREAT,
395  S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
396 
397  if (-1 != altlog_fd)
398  {
399  if (NULL != GNUNET_stderr)
400  fclose (GNUNET_stderr);
401  dup_return = dup2 (altlog_fd, 2);
402  (void) close (altlog_fd);
403  if (-1 != dup_return)
404  {
405  altlog = fdopen (2, "ab");
406  if (NULL == altlog)
407  {
408  (void) close (2);
409  altlog_fd = -1;
410  }
411  }
412  else
413  {
414  altlog_fd = -1;
415  }
416  }
417  if (-1 == altlog_fd)
418  {
420  return GNUNET_SYSERR;
421  }
422  GNUNET_stderr = altlog;
423  return GNUNET_OK;
424 }
static void log_rotate(const char *new_name)
Rotate logs, deleting the oldest log.
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.
#define PATH_MAX
Assumed maximum path length (for the log file name).
@ GNUNET_OK
Definition: gnunet_common.h:95
@ GNUNET_SYSERR
Definition: gnunet_common.h:93
enum GNUNET_GenericReturnValue GNUNET_DISK_directory_create_for_file(const char *filename)
Create the directory structure for storing a file.
Definition: disk.c:582
#define GNUNET_log_strerror_file(level, cmd, filename)
Log an error message at log-level 'level' that indicates a failure of the command 'cmd' with the mess...

References GNUNET_DISK_directory_create_for_file(), GNUNET_ERROR_TYPE_ERROR, GNUNET_free, GNUNET_log_strerror_file, GNUNET_OK, GNUNET_stderr, GNUNET_strdup, GNUNET_SYSERR, log_file_name, log_rotate(), and PATH_MAX.

Referenced by GNUNET_log_setup(), and mylog().

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 440 of file common_logging.c.

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

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

Referenced by parse_definitions().

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 501 of file common_logging.c.

506 {
507  struct LogDef *ld;
508  int i;
509  int force_only;
510 
511  if (NULL == comp)
512  /* Use default component */
513  comp = component_nopid;
514 
515  /* We have no definitions to override globally configured log level,
516  * so just use it right away.
517  */
518  if ((min_level >= 0) && (GNUNET_NO == gnunet_force_log_present))
519  return caller_level <= min_level;
520 
521  /* Only look for forced definitions? */
522  force_only = min_level >= 0;
523  for (i = 0; i < logdefs_len; i++)
524  {
525  ld = &logdefs[i];
526  if (((! force_only) || ld->force) &&
527  ((line >= ld->from_line) && (line <= ld->to_line) ) &&
528  (0 == regexec (&ld->component_regex, comp, 0, NULL, 0)) &&
529  (0 == regexec (&ld->file_regex, file, 0, NULL, 0)) &&
530  (0 == regexec (&ld->function_regex, function, 0, NULL, 0)))
531  {
532  /* We're finished */
533  return caller_level <= ld->level;
534  }
535  }
536  /* No matches - use global level, if defined */
537  if (min_level >= 0)
538  return caller_level <= min_level;
539  /* All programs/services previously defaulted to WARNING.
540  * Now *we* default to WARNING, and THEY default to NULL.
541  * Or rather we default to MESSAGE, since things aren't always bad.
542  */
543  return caller_level <= GNUNET_ERROR_TYPE_MESSAGE;
544 }
static int gnunet_force_log_present
GNUNET_YES if at least one definition with forced == 1 is available.
static char * component_nopid
Running component (without pid).
static enum GNUNET_ErrorType min_level
Minimum log level.
static char * line
Desired phone line (string to be converted to a hash).
@ GNUNET_NO
Definition: gnunet_common.h:94
regex_t file_regex
File name regex.
regex_t function_regex
Function name regex.
regex_t component_regex
Component name regex.

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

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

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 571 of file common_logging.c.

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

References _, add_definition(), LogDef::force, 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().

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 705 of file common_logging.c.

706 {
709  parse_definitions ("GNUNET_FORCE_LOG", 1) > 0 ? GNUNET_YES : GNUNET_NO;
711 
713  parse_definitions ("GNUNET_LOG", 0);
715 }
static int parse_definitions(const char *constname, int force)
Utility function - parses a definition.
static int gnunet_force_log_parsed
GNUNET_YES if GNUNET_FORCE_LOG environment variable is already parsed.
static int gnunet_log_parsed
GNUNET_YES if GNUNET_LOG environment variable is already parsed.
@ GNUNET_YES
Definition: gnunet_common.h:97

References gnunet_force_log_parsed, gnunet_force_log_present, gnunet_log_parsed, GNUNET_NO, GNUNET_YES, and parse_definitions().

Referenced by GNUNET_log_setup().

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 831 of file common_logging.c.

835 {
836  struct CustomLogger *pos;
837 
838  /* only use the standard logger if no custom loggers are present */
839  if ((NULL != GNUNET_stderr) && (NULL == loggers))
840  {
841  if (kind == GNUNET_ERROR_TYPE_MESSAGE)
842  {
843  /* The idea here is to produce "normal" output messages
844  * for end users while still having the power of the
845  * logging engine for developer needs. So ideally this
846  * is what it should look like when CLI tools are used
847  * interactively, yet the same message shouldn't look
848  * this way if the output is going to logfiles or robots
849  * instead.
850  */fprintf (GNUNET_stderr, "* %s", msg);
851  }
853  {
854  static GNUNET_THREAD_LOCAL char id_buf[27];
855  char *end;
856 
857  /* We're logging, so skip_log must be currently 0. */
858  skip_log = 100;
860  sizeof(struct GNUNET_AsyncScopeId),
861  id_buf,
862  sizeof(id_buf) - 1);
863  GNUNET_assert (NULL != end);
864  *end = '\0';
865  skip_log = 0;
866  fprintf (GNUNET_stderr,
867  "%s %s(%s) %s %s",
868  datestr,
869  comp,
870  id_buf,
872  msg);
873  }
874  else
875  {
876  fprintf (GNUNET_stderr,
877  "%s %s %s %s",
878  datestr,
879  comp,
881  msg);
882  }
883  fflush (GNUNET_stderr);
884  }
885  pos = loggers;
886  while (NULL != pos)
887  {
888  pos->logger (pos->logger_cls, kind, comp, datestr, msg);
889  pos = pos->next;
890  }
891 }
struct GNUNET_MessageHeader * msg
Definition: 005.c:2
static GNUNET_THREAD_LOCAL int skip_log
Number of log calls to ignore.
static struct CustomLogger * loggers
Linked list of our custom loggres.
static GNUNET_THREAD_LOCAL struct GNUNET_AsyncScopeSave current_async_scope
Asynchronous scope of the current thread, or NULL if we have not entered an async scope yet.
static int end
Set if we are to shutdown all services (including ARM).
Definition: gnunet-arm.c:34
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.
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:709
Linked list of active loggers.
void * logger_cls
Closure for logger.
struct CustomLogger * next
This is a linked list.
GNUNET_Logger logger
Log function.
Identifier for an asynchronous execution context.
int have_scope
GNUNET_YES unless this saved scope is the unnamed root scope.
struct GNUNET_AsyncScopeId scope_id
Saved scope.

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

Referenced by flush_bulk(), and mylog().

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 900 of file common_logging.c.

901 {
902  char msg[DATE_STR_SIZE + BULK_TRACK_SIZE + 256];
903  int rev;
904  char *last;
905  const char *ft;
906 
907  if ((0 == last_bulk_time.abs_value_us) || (0 == last_bulk_repeat))
908  return;
909  rev = 0;
910  last = memchr (last_bulk, '\0', BULK_TRACK_SIZE);
911  if (last == NULL)
912  last = &last_bulk[BULK_TRACK_SIZE - 1];
913  else if (last != last_bulk)
914  last--;
915  if (last[0] == '\n')
916  {
917  rev = 1;
918  last[0] = '\0';
919  }
920  ft =
923  GNUNET_YES);
924  snprintf (msg,
925  sizeof(msg),
926  _ ("Message `%.*s' repeated %u times in the last %s\n"),
928  last_bulk,
930  ft);
931  if (rev == 1)
932  last[0] = '\n';
935  last_bulk_repeat = 0;
936 }
static GNUNET_THREAD_LOCAL struct GNUNET_TIME_Absolute last_bulk_time
Time of the last bulk error message (0 for none)
static GNUNET_THREAD_LOCAL char last_bulk_comp[32+1]
Component when the last bulk was logged.
static GNUNET_THREAD_LOCAL enum GNUNET_ErrorType last_bulk_kind
Type of the last bulk message.
static void output_message(enum GNUNET_ErrorType kind, const char *comp, const char *datestr, const char *msg)
Actually output the log message.
static GNUNET_THREAD_LOCAL unsigned int last_bulk_repeat
Number of times that bulk message has been repeated since.
#define DATE_STR_SIZE
How many characters can a date/time string be at most?
#define BULK_TRACK_SIZE
How many characters do we use for matching of bulk messages?
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:435
struct GNUNET_TIME_Absolute GNUNET_TIME_absolute_get(void)
Get the current time.
Definition: time.c:110
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:570
uint64_t abs_value_us
The actual value.

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_comp, last_bulk_kind, last_bulk_repeat, last_bulk_time, msg, and output_message().

Referenced by mylog().

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 985 of file common_logging.c.

989 {
990  char date[DATE_STR_SIZE];
991  char date2[DATE_STR_SIZE];
992  struct tm *tmptr;
993  size_t size;
994  va_list vacp;
995 
996  va_copy (vacp, va);
997  size = vsnprintf (NULL, 0, message, vacp) + 1;
998  GNUNET_assert (0 != size);
999  va_end (vacp);
1000  memset (date, 0, DATE_STR_SIZE);
1001  {
1002  char buf[size];
1003  long long offset;
1004 
1005  struct timeval timeofday;
1006 
1007  gettimeofday (&timeofday, NULL);
1008  offset = GNUNET_TIME_get_offset ();
1009  if (offset > 0)
1010  {
1011  timeofday.tv_sec += offset / 1000LL;
1012  timeofday.tv_usec += (offset % 1000LL) * 1000LL;
1013  if (timeofday.tv_usec > 1000000LL)
1014  {
1015  timeofday.tv_usec -= 1000000LL;
1016  timeofday.tv_sec++;
1017  }
1018  }
1019  else
1020  {
1021  timeofday.tv_sec += offset / 1000LL;
1022  if (timeofday.tv_usec > -(offset % 1000LL) * 1000LL)
1023  {
1024  timeofday.tv_usec += (offset % 1000LL) * 1000LL;
1025  }
1026  else
1027  {
1028  timeofday.tv_usec += 1000000LL + (offset % 1000LL) * 1000LL;
1029  timeofday.tv_sec--;
1030  }
1031  }
1032  tmptr = localtime (&timeofday.tv_sec);
1033  if (NULL == tmptr)
1034  {
1035  strcpy (date, "localtime error");
1036  }
1037  else
1038  {
1039  /* RFC 3339 timestamp, with snprintf placeholder for microseconds */
1040  if (0 == strftime (date2, DATE_STR_SIZE, "%Y-%m-%dT%H:%M:%S.%%06u%z",
1041  tmptr))
1042  abort ();
1043  /* Fill in microseconds */
1044  if (0 > snprintf (date, sizeof(date), date2, timeofday.tv_usec))
1045  abort ();
1046  }
1047 
1048  vsnprintf (buf, size, message, va);
1049 #if ! defined(GNUNET_CULL_LOGGING)
1050  if (NULL != tmptr)
1051  (void) setup_log_file (tmptr);
1052 #endif
1053  if ((0 != (kind & GNUNET_ERROR_TYPE_BULK)) &&
1054  (0 != last_bulk_time.abs_value_us) &&
1055  (0 == strncmp (buf, last_bulk, sizeof(last_bulk))))
1056  {
1057  last_bulk_repeat++;
1061  flush_bulk (date);
1062  return;
1063  }
1064  flush_bulk (date);
1065  GNUNET_strlcpy (last_bulk, buf, sizeof(last_bulk));
1066  last_bulk_repeat = 0;
1067  last_bulk_kind = kind;
1069  GNUNET_strlcpy (last_bulk_comp, comp, sizeof(last_bulk_comp));
1070  output_message (kind, comp, date, buf);
1071  }
1072 }
#define BULK_DELAY_THRESHOLD
After how many milliseconds do we always print that "message X was repeated N times"?...
#define BULK_REPEAT_THRESHOLD
After how many repetitions do we always print that "message X was repeated N times"?...
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.
@ GNUNET_ERROR_TYPE_BULK
size_t GNUNET_strlcpy(char *dst, const char *src, size_t n)
Like strlcpy but portable.
Definition: strings.c:139
long long GNUNET_TIME_get_offset(void)
Get the timestamp offset for this instance.
Definition: time.c:55
static unsigned int size
Size of the "table".
Definition: peer.c:67
uint64_t rel_value_us
The actual value.

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_comp, last_bulk_kind, last_bulk_repeat, last_bulk_time, output_message(), GNUNET_TIME_Relative::rel_value_us, setup_log_file(), and size.

Referenced by GNUNET_log_from_nocheck(), and GNUNET_log_nocheck().

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 1083 of file common_logging.c.

1084 {
1085  va_list va;
1086 
1087  va_start (va, message);
1088  mylog (kind, component, message, va);
1089  va_end (va);
1090 }
static void mylog(enum GNUNET_ErrorType kind, const char *comp, const char *message, va_list va)
Output a log message using the default mechanism.

References component, and mylog().

Here is the call graph for this function:

◆ GNUNET_log_from_nocheck()

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

Log function that specifies an alternative component.

This function should be used by plugins.

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

Definition at line 1103 of file common_logging.c.

1107 {
1108  va_list va;
1109  char comp_w_pid[128];
1110 
1111  if (comp == NULL)
1112  comp = component_nopid;
1113 
1114  va_start (va, message);
1115  GNUNET_snprintf (comp_w_pid, sizeof(comp_w_pid), "%s-%d", comp, getpid ());
1116  mylog (kind, comp_w_pid, message, va);
1117  va_end (va);
1118 }
int GNUNET_snprintf(char *buf, size_t size, const char *format,...) __attribute__((format(printf
Like snprintf, just aborts if the buffer is of insufficient size.

References component_nopid, GNUNET_snprintf(), and mylog().

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 1524 of file common_logging.c.

1526 {
1527  *old_scope = current_async_scope;
1530 }

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().

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 1539 of file common_logging.c.

1540 {
1541  current_async_scope = *old_scope;
1542 }

References current_async_scope.

Referenced by GNUNET_SCHEDULER_do_work().

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 1551 of file common_logging.c.

1552 {
1554  aid_ret,
1555  sizeof(struct GNUNET_AsyncScopeId));
1556 }
void GNUNET_CRYPTO_random_block(enum GNUNET_CRYPTO_Quality mode, void *buffer, size_t length)
Fill block with a random values.
@ GNUNET_CRYPTO_QUALITY_WEAK
No good quality of the operation is needed (i.e., random numbers can be pseudo-random).

References GNUNET_CRYPTO_QUALITY_WEAK, and GNUNET_CRYPTO_random_block().

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 1565 of file common_logging.c.

1566 {
1567  *scope_ret = current_async_scope;
1568 }

References current_async_scope.

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

Here is the caller graph for this function:

◆ __attribute__() [1/2]

void __attribute__ ( (constructor)  )

Initializer.

Definition at line 1574 of file common_logging.c.

1576 {
1577  GNUNET_stderr = stderr;
1578 }

References GNUNET_stderr.

◆ __attribute__() [2/2]

void __attribute__ ( (destructor)  )

Destructor.

Definition at line 1584 of file common_logging.c.

1586 {
1587 
1588 }

Variable Documentation

◆ current_async_scope

GNUNET_THREAD_LOCAL 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().

◆ __nonstring

GNUNET_THREAD_LOCAL char last_bulk [ 256 ] __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!

Definition at line 110 of file common_logging.c.

◆ last_bulk_kind

GNUNET_THREAD_LOCAL enum GNUNET_ErrorType last_bulk_kind
static

Type of the last bulk message.

Definition at line 115 of file common_logging.c.

Referenced by flush_bulk(), and mylog().

◆ 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 120 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 125 of file common_logging.c.

Referenced by flush_bulk(), and mylog().

◆ 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 130 of file common_logging.c.

Referenced by flush_bulk(), and mylog().

◆ component

char* component
static

Running component.

Definition at line 135 of file common_logging.c.

Referenced by add_definition(), GNUNET_log_nocheck(), and GNUNET_log_setup().

◆ component_nopid

char* component_nopid
static

Running component (without pid).

Definition at line 140 of file common_logging.c.

Referenced by GNUNET_get_log_call_status(), GNUNET_log_from_nocheck(), and GNUNET_log_setup().

◆ log_file_name

char* log_file_name
static

Format string describing the name of the log file.

Definition at line 145 of file common_logging.c.

Referenced by GNUNET_log_setup(), and setup_log_file().

◆ min_level

enum GNUNET_ErrorType min_level
static

Minimum log level.

Definition at line 145 of file common_logging.c.

Referenced by GNUNET_get_log_call_status(), and GNUNET_log_setup().

◆ loggers

struct CustomLogger* loggers
static

Linked list of our custom loggres.

Definition at line 155 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 160 of file common_logging.c.

Referenced by GNUNET_get_log_skip(), GNUNET_log_skip(), and output_message().

◆ GNUNET_stderr

FILE* GNUNET_stderr
static

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

Definition at line 165 of file common_logging.c.

Referenced by __attribute__(), output_message(), and setup_log_file().

◆ logdefs

struct LogDef* logdefs
static

Dynamic array of logging definitions.

Definition at line 218 of file common_logging.c.

Referenced by add_definition(), GNUNET_get_log_call_status(), and resize_logdefs().

◆ logdefs_size

int logdefs_size
static

Allocated size of logdefs array (in units)

Definition at line 223 of file common_logging.c.

Referenced by add_definition(), and resize_logdefs().

◆ logdefs_len

int logdefs_len
static

The number of units used in logdefs array.

Definition at line 228 of file common_logging.c.

Referenced by add_definition(), and 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 233 of file common_logging.c.

Referenced by parse_all_definitions().

◆ gnunet_force_log_parsed

int gnunet_force_log_parsed
static

GNUNET_YES if GNUNET_FORCE_LOG environment variable is already parsed.

Definition at line 238 of file common_logging.c.

Referenced by parse_all_definitions().

◆ 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 243 of file common_logging.c.

Referenced by GNUNET_get_log_call_status(), and parse_all_definitions().