netatalk 4.5.0
Free and Open Source Apple Filing Protocol (AFP) Server
Loading...
Searching...
No Matches
logger.c File Reference
`#include <ctype.h>`
`#include <errno.h>`
`#include <fcntl.h>`
`#include <limits.h>`
`#include <signal.h>`
`#include <stdarg.h>`
`#include <stdbool.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <sys/stat.h>`
`#include <sys/time.h>`
`#include <sys/types.h>`
`#include <sys/uio.h>`
`#include <syslog.h>`
`#include <time.h>`
`#include <unistd.h>`
`#include <atalk/logger.h>`
`#include <atalk/unix.h>`
`#include <atalk/util.h>`

## Macros
#define | COUNT_ARRAY(array)
#define | MAXLOGSIZE 512
#define | LOGLEVEL_STRING_IDENTIFIERS
#define | LOGTYPE_STRING_IDENTIFIERS
#define | DEFAULT_LOG_CONFIG {0, 0, -1, log_none, 0, true}

## Functions
static int | generate_message (char **message_details_buffer, char *user_message, int display_options, enum loglevels loglevel, enum logtypes logtypelogtype, bool log_us_timestamp)
static int | get_syslog_equivalent (enum loglevels loglevel)
static void | make_syslog_entry (enum loglevels loglevel, enum logtypes logtypelogtype, char *message)
static void | log_init (void)
static void | log_setup (const char *filename, enum loglevels loglevel, enum logtypes logtypelogtype, const bool log_us_timestamp)
void | syslog_setup (int loglevel, enum logtypes logtypelogtype, int display_options, int facility)
static void | setuplog_internal (const char *loglevel, const char *logtypelogtype, const char *filename, const bool log_us_timestamp)
| If filename == NULL its for syslog logging, otherwise its for file-logging.
void | set_processname (const char *processname)
void | make_log_entry (enum loglevels loglevel, enum logtypes logtypelogtype, const char *file, const bool log_us_timestamp, int line, char *message,...)
void | setuplog (const char *logstr, const char *logfile, const bool log_us_timestamp)

## Variables
log_config_t | log_config = { 0 }
UAM_MODULE_EXPORT logtype_conf_t | type_configs [logtype_end_of_list_marker]
static const char * | log_src_filename
static int | log_src_linenumber
static const char * | arr_logtype_strings [] = LOGTYPE_STRING_IDENTIFIERS
static const unsigned int | num_logtype_strings
static const char | arr_loglevel_chars [] = {'-', 'S', 'E', 'W', 'N', 'I', 'D'}
static const unsigned int | num_loglevel_chars = COUNT_ARRAY(arr_loglevel_chars)
static const char * | arr_loglevel_strings [] = LOGLEVEL_STRING_IDENTIFIERS
static const unsigned int | num_loglevel_strings

## Macro Definition Documentation

## ◆ COUNT_ARRAY

#define COUNT_ARRAY | ( |  | array | ) |

Value:
(sizeof((array))/sizeof((array)[0]))

## ◆ DEFAULT_LOG_CONFIG

#define DEFAULT_LOG_CONFIG {0, 0, -1, log_none, 0, true}

Default log config: log nothing to files.

0: set ?
0: syslog ?
-1: logfiles fd
log_none: no logging by default
0: Display options
false timestamp_us
log_none
@ log_none
Definition logger.h:18

## ◆ LOGLEVEL_STRING_IDENTIFIERS

#define LOGLEVEL_STRING_IDENTIFIERS

Value:
{ \
"-", \
"severe", \
"error", \
"warn", \
"note", \
"info", \
"debug", \
"debug6", \
"debug7", \
"debug8", \
"debug9", \
"maxdebug"}

## ◆ LOGTYPE_STRING_IDENTIFIERS

#define LOGTYPE_STRING_IDENTIFIERS

Value:
{ \
"Default", \
"Logger", \
"CNID", \
"AFPDaemon", \
"DSI", \
"ATalkDaemon", \
"PAPDaemon", \
"UAMS", \
"FCE", \
"ad", \
"Spotlight", \
"end_of_list_marker"}

these are the string identifiers corresponding to each logtype

## ◆ MAXLOGSIZE

#define MAXLOGSIZE 512

## Function Documentation

## ◆ generate_message()

int generate_message | ( | char ** | message_details_buffer,
|  | char * | user_message,
|  | int | display_options,
|  | enum loglevels | loglevel,
|  | enum logtypes | logtype,
|  | bool | log_us_timestamp )
| static

## ◆ get_syslog_equivalent()

int get_syslog_equivalent | ( | enum loglevels | loglevel | ) |
| static

## ◆ log_init()

void log_init | ( | void |  | ) |
| static

## ◆ log_setup()

void log_setup | ( | const char * | filename,
|  | enum loglevels | loglevel,
|  | enum logtypes | logtype,
|  | const bool | log_us_timestamp )
| static

## ◆ make_log_entry()

void make_log_entry | ( | enum loglevels | loglevel,
|  | enum logtypes | logtype,
|  | const char * | file,
|  | const bool | log_us_timestamp,
|  | int | line,
|  | char * | message,
|  |  | ... )

Bug
  make_log_entry has 1 main flaw: The message in its entirety, must fit into the tempbuffer. So it must be shorter than MAXLOGSIZE

LOG macro func no.1: log the message to file

## ◆ make_syslog_entry()

void make_syslog_entry | ( | enum loglevels | loglevel,
|  | enum logtypes | logtype,
|  | char * | message )
| static

Called by the LOG macro for syslog messages

## ◆ set_processname()

void set_processname | ( | const char * | processname | ) |

This function sets up the processname

## ◆ setuplog()

void setuplog | ( | const char * | logstr,
|  | const char * | logfile,
|  | const bool | log_us_timestamp )

## ◆ setuplog_internal()

void setuplog_internal | ( | const char * | loglevel,
|  | const char * | logtype,
|  | const char * | filename,
|  | const bool | log_us_timestamp )
| static

If filename == NULL its for syslog logging, otherwise its for file-logging.

"unsetuplog" calls with loglevel == NULL. loglevel == NULL means:

if logtype == default
disable logging
else
set to default logging
logtype
logtype
Definition cmd_dbd.h:9
to
PATH_T to
Definition nad_cp.c:87

## ◆ syslog_setup()

void syslog_setup | ( | int | loglevel,
|  | enum logtypes | logtype,
|  | int | display_options,
|  | int | facility )

Setup syslog logging

Setup the level and type of log that will be logged to syslog.

## Variable Documentation

## ◆ arr_loglevel_chars

const char arr_loglevel_chars[] = {'-', 'S', 'E', 'W', 'N', 'I', 'D'}
| static

## ◆ arr_loglevel_strings

const char* arr_loglevel_strings[] = LOGLEVEL_STRING_IDENTIFIERS
| static

## ◆ arr_logtype_strings

const char* arr_logtype_strings[] = LOGTYPE_STRING_IDENTIFIERS
| static

## ◆ log_config

log_config_t log_config = { 0 }

Main log config container

## ◆ log_src_filename

const char* log_src_filename
| static

## ◆ log_src_linenumber

int log_src_linenumber
| static

## ◆ num_loglevel_chars

const unsigned int num_loglevel_chars = COUNT_ARRAY(arr_loglevel_chars)
| static

## ◆ num_loglevel_strings

const unsigned int num_loglevel_strings
| static

Initial value:
=
COUNT_ARRAY(arr_loglevel_strings)
COUNT_ARRAY
#define COUNT_ARRAY(array)
Definition logger.c:38
arr_loglevel_strings
static const char * arr_loglevel_strings[]
Definition logger.c:118

## ◆ num_logtype_strings

const unsigned int num_logtype_strings
| static

Initial value:
=
COUNT_ARRAY(arr_logtype_strings)
arr_logtype_strings
static const char * arr_logtype_strings[]
Definition logger.c:110

## ◆ type_configs

UAM_MODULE_EXPORT logtype_conf_t type_configs[logtype_end_of_list_marker]

Initial value:
= {
DEFAULT_LOG_CONFIG,
DEFAULT_LOG_CONFIG,
DEFAULT_LOG_CONFIG,
DEFAULT_LOG_CONFIG,
DEFAULT_LOG_CONFIG,
DEFAULT_LOG_CONFIG,
DEFAULT_LOG_CONFIG,
DEFAULT_LOG_CONFIG,
DEFAULT_LOG_CONFIG,
DEFAULT_LOG_CONFIG,
DEFAULT_LOG_CONFIG
}
DEFAULT_LOG_CONFIG
#define DEFAULT_LOG_CONFIG
Definition logger.c:88