Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
log.c File Reference
#include "gwlib.h"
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <time.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>

Go to the source code of this file.

Macros

#define MAX_LOGFILES   128
 
#define THREADTABLE_SIZE   1024
 
#define thread_slot()   (gwthread_self() % THREADTABLE_SIZE)
 
#define MAX_LOGGABLE_PLACES   (10*1000)
 
#define FORMAT_SIZE   (1024)
 
#define FUNCTION_GUTS(level, place)
 
#define FUNCTION_GUTS_EXCL(level, place)
 

Enumerations

enum  {
  LOG_PID, LOG_DAEMON, LOG_DEBUG, LOG_INFO,
  LOG_WARNING, LOG_ERR, LOG_ALERT
}
 

Functions

static int decode (char *name)
 
static void openlog (const char *ident, int option, int facility)
 
static void syslog (int translog, const char *msg,...)
 
static void closelog (void)
 
static void add_stderr (void)
 
void log_init (void)
 
void log_shutdown (void)
 
void log_set_output_level (enum output_level level)
 
void log_set_log_level (enum output_level level)
 
void log_set_syslog_facility (char *facility)
 
void log_set_syslog (const char *ident, int syslog_level)
 
void log_reopen (void)
 
void log_close_all (void)
 
int log_open (char *filename, int level, enum excl_state excl)
 
static void format (char *buf, int level, const char *place, int e, const char *fmt, int with_timestamp_and_pid)
 
static void PRINTFLIKE (2, 0)
 
static void PRINTFLIKE (1, 0)
 
void gw_backtrace (void **stack_frames, size_t size, int lock)
 
void gw_panic (int err, const char *fmt,...)
 
void error (int err, const char *fmt,...)
 
void warning (int err, const char *fmt,...)
 
void info (int err, const char *fmt,...)
 
static int place_matches (const char *place, const char *pat)
 
static int place_should_be_logged (const char *place)
 
static int place_is_not_logged (const char *place)
 
void debug (const char *place, int err, const char *fmt,...)
 
void log_set_debug_places (const char *places)
 
void log_thread_to (int idx)
 

Variables

struct {
   FILE *   file
 
   int   minimum_output_level
 
   char   filename [FILENAME_MAX+1]
 
   enum excl_state   exclusive
 
logfiles [MAX_LOGFILES]
 
static int num_logfiles = 0
 
static unsigned int thread_to [(long) THREADTABLE_SIZE]
 
static char * loggable_places [MAX_LOGGABLE_PLACES]
 
static int num_places = 0
 
static RWLock rwlock
 
static int sysloglevel
 
static int syslogfacility = LOG_DAEMON
 
static int dosyslog = 0
 

Macro Definition Documentation

#define FORMAT_SIZE   (1024)

Definition at line 393 of file log.c.

Referenced by format().

#define FUNCTION_GUTS (   level,
  place 
)
Value:
do { \
int i; \
int formatted = 0; \
char buf[FORMAT_SIZE]; \
va_list args; \
for (i = 0; i < num_logfiles; ++i) { \
level >= logfiles[i].minimum_output_level && \
logfiles[i].file != NULL) { \
if (!formatted) { \
format(buf, level, place, err, fmt, 1); \
formatted = 1; \
} \
va_start(args, fmt); \
output(logfiles[i].file, buf, args); \
va_end(args); \
} \
} \
gw_rwlock_unlock(&rwlock); \
if (dosyslog) { \
format(buf, level, place, err, fmt, 0); \
va_start(args, fmt); \
kannel_syslog(buf,args,level); \
va_end(args); \
} \
} while (0)
static struct @66 logfiles[MAX_LOGFILES]
static int dosyslog
Definition: log.c:175
int gw_rwlock_rdlock(RWLock *lock)
Definition: gw-rwlock.c:134
int minimum_output_level
Definition: log.c:134
FILE * file
Definition: log.c:133
static RWLock rwlock
Definition: log.c:168
static int num_logfiles
Definition: log.c:138
#define FORMAT_SIZE
Definition: log.c:393
enum excl_state exclusive
Definition: log.c:136

Definition at line 508 of file log.c.

Referenced by debug(), error(), gw_panic(), info(), and warning().

#define FUNCTION_GUTS_EXCL (   level,
  place 
)
Value:
do { \
char buf[FORMAT_SIZE]; \
va_list args; \
if (logfiles[e].exclusive == GW_EXCL && \
level >= logfiles[e].minimum_output_level && \
logfiles[e].file != NULL) { \
format(buf, level, place, err, fmt, 1); \
va_start(args, fmt); \
output(logfiles[e].file, buf, args); \
va_end(args); \
} \
gw_rwlock_unlock(&rwlock); \
} while (0)
static struct @66 logfiles[MAX_LOGFILES]
int gw_rwlock_rdlock(RWLock *lock)
Definition: gw-rwlock.c:134
int minimum_output_level
Definition: log.c:134
Definition: log.h:74
FILE * file
Definition: log.c:133
static RWLock rwlock
Definition: log.c:168
#define FORMAT_SIZE
Definition: log.c:393
enum excl_state exclusive
Definition: log.c:136

Definition at line 538 of file log.c.

Referenced by debug(), error(), info(), and warning().

#define MAX_LOGFILES   128

Definition at line 131 of file log.c.

Referenced by log_open().

#define MAX_LOGGABLE_PLACES   (10*1000)

Definition at line 160 of file log.c.

Referenced by log_set_debug_places().

#define thread_slot ( )    (gwthread_self() % THREADTABLE_SIZE)

Definition at line 153 of file log.c.

Referenced by debug(), error(), info(), log_thread_to(), and warning().

#define THREADTABLE_SIZE   1024

Definition at line 145 of file log.c.

Referenced by log_init().

Enumeration Type Documentation

anonymous enum
Enumerator
LOG_PID 
LOG_DAEMON 
LOG_DEBUG 
LOG_INFO 
LOG_WARNING 
LOG_ERR 
LOG_ALERT 

Definition at line 105 of file log.c.

105  {
107 };
Definition: log.c:106
Definition: log.c:106
Definition: log.c:106
Definition: log.c:106
Definition: log.c:106

Function Documentation

static void add_stderr ( void  )
static

Definition at line 180 of file log.c.

References file, GW_DEBUG, GW_NON_EXCL, logfiles, and num_logfiles.

Referenced by log_init().

181 {
182  int i;
183 
184  for (i = 0; i < num_logfiles; ++i)
185  if (logfiles[i].file == stderr)
186  return;
187  logfiles[num_logfiles].file = stderr;
188  logfiles[num_logfiles].minimum_output_level = GW_DEBUG;
189  logfiles[num_logfiles].exclusive = GW_NON_EXCL;
190  ++num_logfiles;
191 }
static struct @66 logfiles[MAX_LOGFILES]
FILE * file
Definition: log.c:133
static int num_logfiles
Definition: log.c:138
Definition: log.h:69
static void closelog ( void  )
static

Definition at line 122 of file log.c.

Referenced by log_close_all().

123 {
124 }
void debug ( const char *  place,
int  err,
const char *  fmt,
  ... 
)

Definition at line 690 of file log.c.

References FUNCTION_GUTS, FUNCTION_GUTS_EXCL, GW_DEBUG, place_is_not_logged(), place_should_be_logged(), thread_slot, and thread_to.

Referenced by abort_elapsed(), accept_thread(), acknowledge_from_rawmessage(), add_push_flag(), add_sar_transaction(), assembly_sar_event(), at2_check_sms_memory(), at2_detect_modem_type(), at2_detect_speed(), at2_extract_line(), at2_open_device(), at2_open_device1(), at2_pdu_decode_deliver_sm(), at2_pdu_decode_report_sm(), at2_pdu_encode(), at2_pdu_extract(), at2_read_delete_message(), at2_read_modems(), at2_read_sms_memory(), at2_send_messages(), at2_send_one_message(), at2_shutdown_cb(), at2_start_cb(), at2_wait_modem_command(), at2_write(), at2_write_ctrlz(), at2_write_line(), at_dial(), bb_reload_smsc_groups(), bb_shutdown(), begin_sar_result(), boxc_receiver(), boxc_sender(), brunet_receive_sms(), brunet_send_sms(), cant_handle_event(), cfg_dump(), cfg_read(), cgw_sender(), cgw_shutdown_cb(), cgw_start_cb(), charset_convert(), check_application_headers(), cimd2_accept_message(), cimd2_get_packet(), cimd2_receive_msg(), cimd2_request(), cimd2_send_response(), cimd2_shutdown_cb(), cimd2_start_cb(), cimd2_stop_cb(), cimd2_submit_msg(), cimd_close(), cimd_open_connection(), cimd_pending_smsmessage(), cimd_receive_msg(), cimd_submit_msg(), clear_sent(), clickatell_receive_sms(), clickatell_send_sms(), client_create(), client_destroy(), client_read_status(), client_reset(), client_session(), client_thread(), concat_handling_check_and_handle(), concat_handling_cleanup(), concat_handling_clear_old_parts(), concat_handling_init(), config_reload(), confirm_push(), conn_pool_get(), connect_tcpip(), continue_sar_result(), convert_content(), cookie_destroy(), create_dlr_from_msg(), data_sm_to_msg(), decode_bearer_indication(), deconvert_content(), delayed_http_reply(), delivery_time_constraints(), dispatch_datagram(), dlr_add(), dlr_find(), dump_area(), dump_pdu(), dump_tpis(), elapse_timer(), emi2_handle_smscreq(), emi2_receiver(), emi2_sender(), emi_open_session(), emi_submit_msg(), emimsg_send(), empty_msg_lists(), event_semantically_valid(), expect_acknowledge(), expire_cookies(), fake_listener(), generic_destroy(), generic_init(), generic_parse_reply(), generic_receive_sms(), generic_send_sms(), get_cookies(), get_data(), get_fields(), get_header_value(), get_matching_translations(), get_ton_npi_value(), get_x_kannel_from_xml(), grp_dump(), gw_accept(), gw_check_check_leaks(), gwthread_cancel(), gwthread_dumpsigmask(), gwthread_join_every(), gwthread_shutdown(), handle_dlr(), handle_erroneous_field_in(), handle_init_event(), handle_internal_event(), handle_method_event(), handle_ota_event(), handle_pdu(), handle_push_event(), handle_reply(), handle_session_event(), handle_split(), handle_submit_sm(), handle_transaction(), have_cookie(), http_accept_request(), http_cgivar_dump(), http_header_dump(), http_queue_thread(), http_use_proxy(), httpsmsc_receiver(), httpsmsc_send_cb(), httpsmsc_shutdown(), indicate_push_abort(), indicate_push_connection(), init_machine_create(), init_machine_destroy(), init_reroute(), init_smsbox_routes(), init_wapbox(), io_thread(), ip_allowed_by_ppg(), kannel_receive_sms(), kannel_send_sms(), log_set_syslog(), machine_create(), machine_destroy(), main(), main_connection_loop(), main_thread(), make_confirmed_push_request(), make_session_request(), make_unit_push_request(), memorybuffer_has_rawmessage(), meta_data_unpack(), method_machine_destroy(), mime_decompile(), mime_entity_body(), mime_entity_dump(), mime_entity_dump_real(), mime_something_to_entity(), msg_dump(), msg_to_bb(), msg_to_pdu(), my_dump(), n_messages_benchmark(), new_thread(), new_thread_cleanup(), normalize_charset(), numhash_create(), obey_request(), octstr_dump_debug(), octstr_dump_short(), octstr_shutdown(), ois_check_incoming(), ois_check_input(), ois_open_receiver(), ois_open_sender(), ois_read_into_buffer(), oisd_accept_message(), oisd_get_packet(), oisd_receive_msg(), oisd_request(), oisd_send_response(), oisd_shutdown_cb(), oisd_start_cb(), oisd_stop_cb(), oisd_submit_msg(), oneuser_dump(), OTAbitmap_create_stream(), pack_into_push_datagram(), pack_known_header(), packet_encode_message(), pap_request_thread(), parachute_start(), parse_address_value(), parse_attr_value(), parse_attribute(), parse_bad_message_response_value(), parse_cimd_to_iso88591(), parse_client_specifier(), parse_constant(), parse_document(), parse_dump(), parse_element(), parse_ext_qualifiers(), parse_global_phone_number(), parse_http_date(), parse_ipv4(), parse_ipv4_fragment(), parse_ipv6(), parse_iso88591_to_emi(), parse_msg_to_rawmessage(), parse_pap_value(), parse_progress_note_value(), parse_push_message_value(), parse_push_response_value(), parse_quality_of_service_value(), parse_response_result_value(), parse_url(), pdu_to_msg(), poller(), post_content_create(), proxy_thread(), push_client_event_handle(), push_client_machine_create(), push_client_machine_destroy(), push_client_machine_find_or_create(), push_machine_create(), push_machine_destroy(), radius_pdu_dump(), radius_pdu_unpack(), read_pdu(), receive_push_reply(), receive_reply(), receive_smpp_thread(), reconnect(), report_versions(), request_confirmed_push(), request_push(), request_unit_push(), resend_sar_result(), resp_event_handle(), resp_machine_create(), resp_machine_destroy(), resp_machine_find_or_create(), response(), response_push_connection(), return_reply(), route_msg(), run_wapbox(), sema_msg_session_mt(), sema_open(), sema_pending_smsmessage(), sema_reopen(), sema_submit_msg(), send_acknowledge(), send_bad_message_response(), send_message(), send_messages(), send_msg(), send_pdu(), send_post(), send_push_response(), send_request(), send_smpp_thread(), sendsms_thread(), server(), server_thread(), session_machine_create(), session_machine_destroy(), set_any_value(), set_cookies(), shutdown_cb(), sigterm(), smasi_pdu_dump(), smpp_pdu_dump(), smpp_pdu_dump_line(), smpp_pdu_init(), sms_router(), sms_send(), sms_to_client(), smsbox_req_sendota(), smsbox_start(), smsbox_thread(), smsc2_cleanup(), smsc2_rout(), smsc_cimd2_create(), smsc_oisd_create(), smsc_soap_create(), smscconn_send(), soap_add_msg_cb(), soap_client_init_query(), soap_create_map(), soap_fetch_xml_data(), soap_listener(), soap_map_xml_data(), soap_msgdata_attribute(), soap_msgdata_deps(), soap_o2o_msgdata_attribute(), soap_parse_dlr(), soap_parse_mo(), soap_read_date(), soap_read_response(), soap_send_loop(), soap_server(), soap_server_start(), soap_server_stop(), soap_shutdown_cb(), soap_start_cb(), soap_stop_cb(), spawn_thread(), start_cb(), start_push(), start_request(), start_wap(), stop_initiator_timer(), store_file_dump(), store_push_data(), store_uuid(), string_to_versioned_number(), sustained_level_benchmark(), tcpip_connect_nb_to_server_with_port(), tcpip_connect_to_server_with_port(), tell_fatal_error(), thread1(), thread2(), tid_in_window(), transform_message(), truncated_datagram(), udp_die(), udp_receiver(), udp_sender(), udp_shutdown(), udp_start(), udpc_create(), unpack_datagram(), unpack_wdp_datagram_real(), wait_for_ack(), wap_addr_tuple_dump(), wap_dispatch_datagram(), wap_event_assert(), wap_event_dump(), wap_map_url(), wap_msg_recv(), wap_msg_send(), wap_push_ppg_shutdown(), wapbox_start(), wapme_smsproxy_send_sms(), wbmp_create_stream(), wdp_to_wapboxes(), wina_bearer_identifier(), wml_compile(), wrapper_receiver(), wrapper_sender(), wrapper_shutdown(), wrapper_start(), wrapper_stop(), write_request_thread(), wsp_cap_dump(), wsp_cap_dump_list(), wsp_headers_pack(), wsp_headers_unpack(), wsp_pack_integer_string(), wsp_pack_version_value(), wsp_pdu_dump(), wsp_push_client_shutdown(), wsp_session_shutdown(), wtp_event_dump(), wtp_initiator_shutdown(), wtp_pdu_dump(), wtp_resp_shutdown(), wtp_tid_cache_shutdown(), wtp_tid_is_valid(), X28_open_send_link(), xidris_receive_sms(), and xidris_send_sms().

691 {
692  int e;
693 
694  if (place_should_be_logged(place) && place_is_not_logged(place) == 0) {
695  /*
696  * Note: giving `place' to FUNCTION_GUTS makes log lines
697  * too long and hard to follow. We'll rely on an external
698  * list of what places are used instead of reading them
699  * from the log file.
700  */
701  if ((e = thread_to[thread_slot()])) {
703  } else {
704  FUNCTION_GUTS(GW_DEBUG, "");
705  }
706  }
707 }
#define FUNCTION_GUTS_EXCL(level, place)
Definition: log.c:538
static unsigned int thread_to[(long) THREADTABLE_SIZE]
Definition: log.c:146
Definition: log.h:69
static int place_is_not_logged(const char *place)
Definition: log.c:675
#define thread_slot()
Definition: log.c:153
#define FUNCTION_GUTS(level, place)
Definition: log.c:508
static int place_should_be_logged(const char *place)
Definition: log.c:660
static int decode ( char *  name)
static

Definition at line 109 of file log.c.

References LOG_DAEMON.

Referenced by log_set_syslog_facility().

110 {
111  return LOG_DAEMON;
112 }
void error ( int  err,
const char *  fmt,
  ... 
)

Definition at line 612 of file log.c.

References FUNCTION_GUTS, FUNCTION_GUTS_EXCL, GW_ERROR, thread_slot, and thread_to.

Referenced by add_group(), add_service(), alog_open(), alog_reopen(), at2_detect_modem_type(), at2_device_thread(), at2_init_device(), at2_open_device(), at2_open_device1(), at2_pdu_decode_deliver_sm(), at2_pdu_decode_report_sm(), at2_pdu_encode(), at2_read_buffer(), at2_read_delete_message(), at2_read_pending_incoming_messages(), at2_send_one_message(), at2_set_speed(), at2_wait_modem_command(), at2_write(), at2_write_ctrlz(), at2_write_line(), at_dial(), bb_remove_message(), block_user_signals(), boxc_sent_pop(), brunet_init(), brunet_parse_reply(), brunet_receive_sms(), cant_handle_event(), cfg_read(), cgw_listener(), cgw_open_listening_socket(), cgw_open_send_connection(), cgw_receiver(), cgw_sender(), cgw_wait_command(), change_user(), charset_convert(), check_application_headers(), check_config(), check_data_content_type_header(), check_data_x_wap_application_id_header(), check_do_elements(), check_marks(), check_variable_name(), check_variable_syntax(), cimd2_accept_message(), cimd2_get_packet(), cimd2_login(), cimd2_receive_msg(), cimd2_request(), cimd_close(), cimd_open(), cimd_open_connection(), cimd_pending_smsmessage(), cimd_receive_msg(), cimd_reopen(), cimd_submit_msg(), clickatell_parse_reply(), clickatell_receive_sms(), client_read_status(), client_session(), concat_handling_check_and_handle(), conn_destroy(), conn_flush(), conn_wait(), conn_wrap_fd(), convert_addr_from_pdu(), copy_until_nul(), create_onetrans(), create_oneuser(), data_sm_to_msg(), date_parse_http(), decode_bearer_indication(), decode_binary_data(), deduce_body_state(), delayed_http_reply(), deliver_to_bearerbox_real(), dispatch(), dispatch_datagram(), dispatch_into_queue(), dlr_spool_add(), dlr_spool_get(), dlr_spool_remove(), do_queue_cleanup(), drop_from_free_ring(), emi2_handle_smscreq(), emi2_listener(), emi2_open_listening_socket(), emi2_receiver(), emi_fill_ucp60_login(), emi_open(), emi_open_session(), emi_receive_msg(), emi_reopen(), emi_submit_msg(), emimsg_send(), expect_acknowledge(), expire_cookies(), fake_listener(), fake_open_connection(), fdset_create_real(), fdset_destroy(), field_count_op(), field_count_reply(), fill_threadinfo(), find_area(), find_session_machine(), for_each_file(), generic_init(), generic_parse_reply(), generic_receive_sms(), get_connection(), get_cookies(), get_data(), get_fields(), get_header_value(), get_msg_filename(), get_variable(), get_x_kannel_from_xml(), gw_accept(), gwthread_poll(), gwthread_pollfd(), handle_connect_reply(), handle_dlr(), handle_get_reply(), handle_init_event(), handle_mo_dcs(), handle_mt_dcs(), handle_operation(), handle_pdu(), handle_reply(), handle_transaction(), have_cookie(), headers_acceptable(), http_header_get(), httpsmsc_send(), httpsmsc_send_cb(), init_configuration(), init_machine_find_or_create(), init_smsbox(), io_thread(), ip_allowed_by_ppg(), is_executable(), kannel_receive_sms(), log_open(), log_reopen(), main(), main_connection_loop(), main_for_producer_and_consumer(), main_loop(), make_server_socket(), memorybuffer_cut_rawmessage(), meta_data_merge(), meta_data_unpack(), mime_decompile(), msg_to_bb(), msg_to_emimsg(), msg_to_pdu(), msg_unpack_real(), mutex_trylock_real(), mutex_unlock_real(), numhash_add_number(), numhash_create(), obey_request(), obey_request_thread(), octstr_append_from_socket(), octstr_dump_real(), octstr_print(), octstr_read_file(), octstr_read_pipe(), octstr_write_data(), octstr_write_to_socket(), ois_check_deliver_sm_invoke(), ois_check_incoming(), ois_check_input(), ois_decode_deliver_sm_invoke(), ois_decode_submit_sm_result(), ois_deliver_sm_invoke(), ois_deliver_sm_result(), ois_extract_msg_from_buffer(), ois_open(), ois_open_listener(), ois_open_receiver(), ois_open_sender(), ois_reopen(), ois_submit_msg(), ois_submit_sm_invoke(), ois_submit_sm_result(), oisd_accept_message(), oisd_get_packet(), oisd_login(), oisd_receive_msg(), oisd_request(), open_connection(), open_file(), open_receiver(), open_send_connection(), open_transceiver(), open_transmitter(), ota_compile(), pack_challenge(), pack_content_disposition(), pack_content_range(), pack_credentials(), pack_known_header(), pack_md5(), pack_range(), pack_warning(), packet_display_error(), packet_extract(), packet_get_hex_parm(), packet_get_int_parm(), pap_compile(), pap_request_thread(), parachute_start(), parse_array_element(), parse_attr_value(), parse_attribute(), parse_body_part(), parse_cookie(), parse_data_element(), parse_date(), parse_document(), parse_element(), parse_fault_element(), parse_http_date(), parse_integer(), parse_member_element(), parse_methodcall_element(), parse_methodresponse_element(), parse_node(), parse_ota_syncsettings(), parse_param_element(), parse_params_element(), parse_preamble(), parse_rawmessage_to_msg(), parse_request_line(), parse_struct_element(), parse_text(), parse_url(), parse_value_element(), pass_extension_headers(), pass_optional_header(), pdu_to_msg(), poll_callback(), poller(), port_remove(), proxy_thread(), push_client_event_handle(), push_client_machine_find_or_create(), put_data(), radius_pdu_create(), radius_pdu_destroy(), radius_pdu_dump(), radius_pdu_pack(), radius_pdu_unpack(), read_data(), read_from_bearerbox_real(), read_from_box(), read_messages_from_bearerbox(), read_msg(), read_pdu(), read_test_ppg_config(), receive_push_reply(), receive_reply(), receive_request(), receive_smpp_thread(), reconnect(), remove_pid_file(), rename_store(), resp_event_handle(), resp_machine_find_or_create(), restart_box(), return_reply(), run_batch(), run_smsbox(), run_wapbox(), sanitize_capabilities(), sema_msg_session_mo(), sema_msg_session_mt(), sema_msglist_push(), sema_open(), sema_pending_smsmessage(), sema_receive_msg(), sema_reopen(), sema_submit_msg(), sema_submit_result(), semaphore_up(), send_acknowledge(), send_msg(), send_post(), send_request(), send_udp(), server_thread(), set_cookies(), setup_official_name(), si_compile(), signal_handler(), sl_compile(), smasi_pdu_destroy(), smasi_pdu_pack(), smasi_thread(), smpp_emu_handle_pdu(), smpp_emu_reader(), smpp_pdu_create(), smpp_pdu_destroy(), smpp_pdu_dump(), smpp_pdu_dump_line(), smpp_pdu_init(), smpp_pdu_pack(), smpp_pdu_read_len(), smpp_pdu_unpack(), sms_charset_processing(), smsbox_req_handle(), smsbox_req_sendota(), smsbox_req_sendsms(), smsbox_sendota_post(), smsbox_sendsms_post(), smsbox_start(), smsbox_thread(), smsbox_xmlrpc_post(), smsc2_add_smsc(), smsc2_reload_lists(), smsc2_remove_smsc(), smsc2_restart_smsc(), smsc2_rout(), smsc2_stop_smsc(), smsc_at2_create(), smsc_cgw_create(), smsc_cimd2_create(), smsc_emi2_create(), smsc_fake_create(), smsc_http_create(), smsc_oisd_create(), smsc_open(), smsc_smasi_create(), smsc_smpp_create(), smsc_soap_create(), smsc_wrapper_create(), smscconn_create(), smscenter_lock(), smscenter_pending_smsmessage(), smscenter_read_into_buffer(), smscenter_receive_msg(), smscenter_submit_msg(), soap_convert_token(), soap_format_xml(), soap_get_index(), soap_listener(), soap_msgdata_attribute(), soap_msgdata_deps(), soap_msgtype_deps(), soap_o2o_msgdata_attribute(), soap_parse_dlr(), soap_parse_mo(), soap_parse_response(), soap_release_dependences(), soap_select_function(), soap_server(), soap_server_start(), soap_start_cb(), soap_xmlnode_get_int64(), soap_xmlnode_get_long(), soap_xmlnode_get_octstr(), socket_set_blocking(), socket_set_nodelay(), spawn_thread(), start_client_threads(), start_fetch(), start_smsc(), store_file_load(), store_init(), store_spool_init(), store_spool_save(), tcpip_connect_nb_to_server_with_port(), tcpip_connect_to_server_with_port(), test_header_combine(), transform_message(), udp_bind(), udp_client_socket(), udp_create_address(), udp_receiver(), udp_recvfrom_flags(), udp_sendto(), udp_start(), udpc_create(), unlink_file(), unlocked_read(), unlocked_write(), unpack_cache_directive(), unpack_datagram(), unpack_parameter(), unpack_range_value(), unpack_warning_value(), unpack_wdp_datagram_real(), update_push_data_with_attribute(), update_table(), update_tables(), url_result_thread(), wait_for_ack(), wait_for_client(), wait_for_connections(), wap_msg_recv(), wap_msg_send(), wap_push_ppg_pushuser_authenticate(), wap_push_ppg_pushuser_client_phone_number_acceptable(), wapbox_start(), wapme_smsproxy_init(), wbmp_create(), wbmp_create_stream(), wml_compile(), write_data(), write_to_bearerbox_real(), write_to_socket(), ws_asm_linearize(), ws_bc_decode(), ws_bc_encode(), ws_encode_buffer(), ws_pragma_use(), wsp_cap_pack_list(), wsp_cap_unpack_list(), wsp_convert_http_status_to_wsp_status(), wsp_pack_retry_after(), wtp_event_dump(), wtp_event_is_for_responder(), X28_close_send_link(), X28_data_read(), X28_data_send(), X28_open_data_link(), X28_open_send_link(), X28_reopen_data_link(), xidris_init(), xidris_parse_reply(), xidris_receive_sms(), xml_error(), xmlrpc_call_print(), xmlrpc_doc_add_value(), xmlrpc_doc_print(), xmlrpc_doc_send(), xmlrpc_get_faultcode(), xmlrpc_get_faultstring(), xmlrpc_response_add_param(), xmlrpc_response_get_faultcode(), xmlrpc_response_get_faultstring(), xmlrpc_scalar_create(), xmlrpc_scalar_get_content(), xmlrpc_value_get_content(), xmlrpc_value_set_content(), and xmlrpc_value_set_type().

613 {
614  int e;
615 
616  if ((e = thread_to[thread_slot()])) {
618  } else {
619  FUNCTION_GUTS(GW_ERROR, "");
620  }
621 }
#define FUNCTION_GUTS_EXCL(level, place)
Definition: log.c:538
static unsigned int thread_to[(long) THREADTABLE_SIZE]
Definition: log.c:146
Definition: log.h:69
#define thread_slot()
Definition: log.c:153
#define FUNCTION_GUTS(level, place)
Definition: log.c:508
static void format ( char *  buf,
int  level,
const char *  place,
int  e,
const char *  fmt,
int  with_timestamp_and_pid 
)
static

Definition at line 394 of file log.c.

References FORMAT_SIZE, gw_gmtime(), gw_localtime(), gwthread_self(), and gwthread_self_ids().

396 {
397  static char *tab[] = {
398  "DEBUG: ",
399  "INFO: ",
400  "WARNING: ",
401  "ERROR: ",
402  "PANIC: ",
403  "LOG: "
404  };
405  static int tab_size = sizeof(tab) / sizeof(tab[0]);
406  time_t t;
407  struct tm tm;
408  char *p, prefix[1024];
409  long tid, pid;
410 
411  p = prefix;
412 
413  if (with_timestamp_and_pid) {
414  time(&t);
415 #if LOG_TIMESTAMP_LOCALTIME
416  tm = gw_localtime(t);
417 #else
418  tm = gw_gmtime(t);
419 #endif
420  sprintf(p, "%04d-%02d-%02d %02d:%02d:%02d ",
421  tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
422  tm.tm_hour, tm.tm_min, tm.tm_sec);
423 
424  p = strchr(p, '\0');
425 
426  /* print PID and thread ID */
427  gwthread_self_ids(&tid, &pid);
428  sprintf(p, "[%ld] [%ld] ", pid, tid);
429  } else {
430  /* thread ID only */
431  tid = gwthread_self();
432  sprintf(p, "[%ld] ", tid);
433  }
434 
435  p = strchr(p, '\0');
436  if (level < 0 || level >= tab_size)
437  sprintf(p, "UNKNOWN: ");
438  else
439  sprintf(p, "%s", tab[level]);
440 
441  p = strchr(p, '\0');
442  if (place != NULL && *place != '\0')
443  sprintf(p, "%s: ", place);
444 
445  if (strlen(prefix) + strlen(fmt) > FORMAT_SIZE / 2) {
446  sprintf(buf, "%s <OUTPUT message too long>\n", prefix);
447  return;
448  }
449 
450  if (e == 0)
451  sprintf(buf, "%s%s\n", prefix, fmt);
452  else
453  sprintf(buf, "%s%s\n%sSystem error %d: %s\n",
454  prefix, fmt, prefix, e, strerror(e));
455 }
long gwthread_self(void)
struct tm gw_gmtime(time_t t)
Definition: protected.c:137
void gwthread_self_ids(long *tid, long *pid)
#define FORMAT_SIZE
Definition: log.c:393
struct tm gw_localtime(time_t t)
Definition: protected.c:121
void gw_backtrace ( void **  stack_frames,
size_t  size,
int  lock 
)

Definition at line 563 of file log.c.

References gw_native_free(), and size.

Referenced by fatal_handler(), and gw_panic().

564 {
565 #if HAVE_BACKTRACE
566  void *frames[50];
567  size_t i;
568  char **strings;
569 
570  if (stack_frames == NULL) {
571  stack_frames = frames;
572  size = backtrace(stack_frames, sizeof(frames) / sizeof(void*));
573  }
574 
575  strings = backtrace_symbols(stack_frames, size);
576 
577  if (strings) {
578  for (i = 0; i < size; i++)
579  gw_panic_output(0, "%s", strings[i]);
580  }
581  else { /* hmm, no memory available */
582  for (i = 0; i < size; i++)
583  gw_panic_output(0, "%p", stack_frames[i]);
584  }
585 
586  /*
587  * Note: we must call gw_native_free directly because if gw_free points to gw_check_free we could
588  * panic's and we have endless loop with SEGFAULT at the end.
589  */
590  gw_native_free(strings);
591 #endif
592 }
int size
Definition: wsasm.c:84
void gw_native_free(void *ptr)
Definition: gwmem-native.c:123
void gw_panic ( int  err,
const char *  fmt,
  ... 
)

Definition at line 594 of file log.c.

References FUNCTION_GUTS, gw_backtrace(), and GW_PANIC.

595 {
596  /*
597  * we don't want PANICs to spread accross smsc logs, so
598  * this will be always within the main core log.
599  */
600  FUNCTION_GUTS(GW_PANIC, "");
601 
602  gw_backtrace(NULL, 0, 0);
603 
604 #ifdef SEGFAULT_PANIC
605  *((char*)0) = 0;
606 #endif
607 
608  exit(EXIT_FAILURE);
609 }
void gw_backtrace(void **stack_frames, size_t size, int lock)
Definition: log.c:563
#define FUNCTION_GUTS(level, place)
Definition: log.c:508
Definition: log.h:69
void info ( int  err,
const char *  fmt,
  ... 
)

Definition at line 636 of file log.c.

References FUNCTION_GUTS, FUNCTION_GUTS_EXCL, GW_INFO, thread_slot, and thread_to.

Referenced by accept_boxc(), alog_open(), at2_close_device(), at2_detect_modem_type(), at2_detect_speed(), at2_device_thread(), at2_init_device(), at2_login_device(), at2_open_device1(), at2_read_modems(), at2_read_pending_incoming_messages(), at2_set_speed(), at_dial(), authorise_username(), bb_smscconn_receive(), cgw_handle_op(), cgw_listener(), cgw_open_send_connection(), cgw_read_op(), cgw_receiver(), cgw_send_loop(), cgw_wait_command(), cgwop_add(), cimd2_accept_message(), cimd2_login(), cimd2_logout(), client(), client_session(), client_thread(), config_reload(), conn_config_ssl(), connect_to_bearerbox_real(), create_onetrans(), deliver_unit_push(), delivery_time_constraints(), dlr_flush(), dlr_init(), emi2_handle_smscreq(), emi2_idleprocessing(), emi2_idletimeout_handling(), emi2_listener(), emi2_receiver(), emi2_send_loop(), emi_close_ip(), emi_open_session(), emi_submit_msg(), empty_msg_lists(), eq_log(), expect_acknowledge(), fake_listener(), find_hb(), get_and_set_debugs(), get_cookies(), get_data(), handle_operation(), handle_pdu(), handle_push_message(), handle_submit_sm(), heartbeat_start(), heartbeat_stop(), heartbeat_thread(), help(), http_open_port_if(), httpadmin_run(), httpsmsc_receiver(), init_batch(), init_machine_find_or_create(), init_reroute(), init_smsbox(), init_wapbox(), log_open(), log_set_log_level(), log_thread_to(), main(), main_connection_loop(), mutex_destroy(), numhash_create(), obey_request_thread(), octstr_dump_real(), oisd_accept_message(), oisd_login(), open_send_connection(), ota_pack_message(), pap_request_thread(), parachute_sig_handler(), parachute_start(), parse_address(), parse_document(), producer(), proxy_thread(), push_thread(), radius_acct_init(), radius_acct_shutdown(), read_from_box(), read_messages_from_bearerbox(), reconnect(), reload_bool(), reload_int(), resp_machine_find_or_create(), run_batch(), run_requests(), sema_decode_msg(), sema_msg_session_mo(), sema_msg_session_mt(), sema_msglist_pop(), sema_msglist_push(), sema_submit_msg(), send_file(), send_message(), send_smpp_thread(), sendsms_thread(), server(), smsbox_req_handle(), smsbox_req_sendota(), smsbox_sendota_post(), smsbox_start(), smsbox_thread(), smsc2_graceful_restart(), smsc2_restart_smsc(), smsc2_rout(), smsc2_start(), smsc2_status(), smsc2_stop_smsc(), smsc_at2_create(), smsc_cgw_create(), smsc_emi2_create(), smsc_http_create(), smsc_soap_create(), smscconn_create(), start_fetch(), start_request(), store_file_load(), store_spool_load(), udp_addwdp_from_client(), udp_receiver(), udp_sender(), udp_start(), update_table(), update_tables(), wait_for_client(), wap_msg_recv(), wapbox_start(), wsp_headers_unpack(), wtp_event_dump(), wtp_tid_is_valid(), X28_open_data_link(), and X28_open_send_link().

637 {
638  int e;
639 
640  if ((e = thread_to[thread_slot()])) {
642  } else {
643  FUNCTION_GUTS(GW_INFO, "");
644  }
645 }
#define FUNCTION_GUTS_EXCL(level, place)
Definition: log.c:538
static unsigned int thread_to[(long) THREADTABLE_SIZE]
Definition: log.c:146
Definition: log.h:69
#define thread_slot()
Definition: log.c:153
#define FUNCTION_GUTS(level, place)
Definition: log.c:508
void log_close_all ( void  )

Definition at line 305 of file log.c.

References closelog(), file, filename, gw_rwlock_unlock(), gw_rwlock_wrlock(), logfiles, and num_logfiles.

Referenced by get_and_set_debugs(), log_shutdown(), and main().

306 {
307  /*
308  * Writer lock.
309  */
311 
312  while (num_logfiles > 0) {
313  --num_logfiles;
314  if (logfiles[num_logfiles].file != stderr && logfiles[num_logfiles].file != NULL) {
315  int i;
316  /* look for the same filename and set file to NULL */
317  for (i = num_logfiles - 1; i >= 0; i--) {
318  if (strcmp(logfiles[num_logfiles].filename, logfiles[i].filename) == 0)
319  logfiles[i].file = NULL;
320  }
321  fclose(logfiles[num_logfiles].file);
322  logfiles[num_logfiles].file = NULL;
323  }
324  }
325 
326  /*
327  * Unlock writer.
328  */
330 
331  /* close syslog if used */
332  if (dosyslog) {
333  closelog();
334  dosyslog = 0;
335  }
336 }
static struct @66 logfiles[MAX_LOGFILES]
static int dosyslog
Definition: log.c:175
int gw_rwlock_wrlock(RWLock *lock)
Definition: gw-rwlock.c:177
FILE * file
Definition: log.c:133
static RWLock rwlock
Definition: log.c:168
static int num_logfiles
Definition: log.c:138
static void closelog(void)
Definition: log.c:122
int gw_rwlock_unlock(RWLock *lock)
Definition: gw-rwlock.c:155
char filename[FILENAME_MAX+1]
Definition: log.c:135
void log_init ( void  )

Definition at line 194 of file log.c.

References add_stderr(), gw_rwlock_init_static(), thread_to, and THREADTABLE_SIZE.

Referenced by gwlib_init().

195 {
196  unsigned long i;
197 
198  /* Initialize rwlock */
200 
201  /* default all possible thread to logging index 0, stderr */
202  for (i = 0; i < THREADTABLE_SIZE; i++) {
203  thread_to[i] = 0;
204  }
205 
206  add_stderr();
207 }
#define THREADTABLE_SIZE
Definition: log.c:145
static unsigned int thread_to[(long) THREADTABLE_SIZE]
Definition: log.c:146
static RWLock rwlock
Definition: log.c:168
static void add_stderr(void)
Definition: log.c:180
void gw_rwlock_init_static(RWLock *lock)
Definition: gw-rwlock.c:96
int log_open ( char *  filename,
int  level,
enum excl_state  excl 
)

Definition at line 339 of file log.c.

References error(), gw_rwlock_unlock(), gw_rwlock_wrlock(), info(), logfiles, MAX_LOGFILES, and num_logfiles.

Referenced by get_and_set_debugs(), init_bearerbox(), init_smsbox(), init_wapbox(), main(), and smscconn_create().

340 {
341  FILE *f = NULL;
342  int i;
343 
345 
346  if (num_logfiles == MAX_LOGFILES) {
348  error(0, "Too many log files already open, not adding `%s'",
349  filename);
350  return -1;
351  }
352 
353  if (strlen(filename) > FILENAME_MAX) {
355  error(0, "Log filename too long: `%s'.", filename);
356  return -1;
357  }
358 
359  /*
360  * Check if the file is already opened for logging.
361  * If there is an open file, then assign the file descriptor
362  * that is already existing for this log file.
363  */
364  for (i = 0; i < num_logfiles && f == NULL; ++i) {
365  if (strcmp(logfiles[i].filename, filename) == 0)
366  f = logfiles[i].file;
367  }
368 
369  /* if not previously opened, then open it now */
370  if (f == NULL) {
371  f = fopen(filename, "a");
372  if (f == NULL) {
374  error(errno, "Couldn't open logfile `%s'.", filename);
375  return -1;
376  }
377  }
378 
379  logfiles[num_logfiles].file = f;
380  logfiles[num_logfiles].minimum_output_level = level;
381  logfiles[num_logfiles].exclusive = excl;
382  strcpy(logfiles[num_logfiles].filename, filename);
383  ++num_logfiles;
384  i = num_logfiles - 1;
386 
387  info(0, "Added logfile `%s' with level `%d'.", filename, level);
388 
389  return i;
390 }
void error(int err, const char *fmt,...)
Definition: log.c:612
void info(int err, const char *fmt,...)
Definition: log.c:636
static struct @66 logfiles[MAX_LOGFILES]
#define MAX_LOGFILES
Definition: log.c:131
int gw_rwlock_wrlock(RWLock *lock)
Definition: gw-rwlock.c:177
static RWLock rwlock
Definition: log.c:168
static int num_logfiles
Definition: log.c:138
int gw_rwlock_unlock(RWLock *lock)
Definition: gw-rwlock.c:155
char filename[FILENAME_MAX+1]
Definition: log.c:135
void log_reopen ( void  )

Definition at line 261 of file log.c.

References error(), file, filename, found, gw_rwlock_unlock(), gw_rwlock_wrlock(), logfiles, and num_logfiles.

Referenced by main(), and signal_handler().

262 {
263  int i, j, found;
264 
265  /*
266  * Writer lock.
267  */
269 
270  for (i = 0; i < num_logfiles; ++i) {
271  if (logfiles[i].file != stderr) {
272  found = 0;
273 
274  /*
275  * Reverse seek for allready reopened logfile.
276  * If we find a previous file descriptor for the same file
277  * name, then don't reopen that duplicate, but assign the
278  * file pointer to it.
279  */
280  for (j = i-1; j >= 0 && found == 0; j--) {
281  if (strcmp(logfiles[i].filename, logfiles[j].filename) == 0) {
282  logfiles[i].file = logfiles[j].file;
283  found = 1;
284  }
285  }
286  if (found)
287  continue;
288  if (logfiles[i].file != NULL)
289  fclose(logfiles[i].file);
290  logfiles[i].file = fopen(logfiles[i].filename, "a");
291  if (logfiles[i].file == NULL) {
292  error(errno, "Couldn't re-open logfile `%s'.",
293  logfiles[i].filename);
294  }
295  }
296  }
297 
298  /*
299  * Unlock writer.
300  */
302 }
void error(int err, const char *fmt,...)
Definition: log.c:612
static struct @66 logfiles[MAX_LOGFILES]
int gw_rwlock_wrlock(RWLock *lock)
Definition: gw-rwlock.c:177
FILE * file
Definition: log.c:133
static struct pid_list * found
static RWLock rwlock
Definition: log.c:168
static int num_logfiles
Definition: log.c:138
int gw_rwlock_unlock(RWLock *lock)
Definition: gw-rwlock.c:155
char filename[FILENAME_MAX+1]
Definition: log.c:135
void log_set_debug_places ( const char *  places)

Definition at line 710 of file log.c.

References MAX_LOGGABLE_PLACES.

Referenced by get_and_set_debugs().

711 {
712  char *p;
713 
714  p = strtok(gw_strdup(places), " ,");
715  num_places = 0;
716  while (p != NULL && num_places < MAX_LOGGABLE_PLACES) {
718  p = strtok(NULL, " ,");
719  }
720 }
static int num_places
Definition: log.c:162
static char * loggable_places[MAX_LOGGABLE_PLACES]
Definition: log.c:161
#define MAX_LOGGABLE_PLACES
Definition: log.c:160
void log_set_log_level ( enum output_level  level)

Definition at line 229 of file log.c.

References file, filename, info(), logfiles, and num_logfiles.

Referenced by config_reload(), and httpd_loglevel().

230 {
231  int i;
232 
233  /* change everything but stderr */
234  for (i = 0; i < num_logfiles; ++i) {
235  if (logfiles[i].file != stderr) {
236  logfiles[i].minimum_output_level = level;
237  info(0, "Changed logfile `%s' to level `%d'.", logfiles[i].filename, level);
238  }
239  }
240 }
void info(int err, const char *fmt,...)
Definition: log.c:636
static struct @66 logfiles[MAX_LOGFILES]
FILE * file
Definition: log.c:133
static int num_logfiles
Definition: log.c:138
char filename[FILENAME_MAX+1]
Definition: log.c:135
void log_set_output_level ( enum output_level  level)

Definition at line 217 of file log.c.

References file, logfiles, and num_logfiles.

Referenced by get_and_set_debugs(), and main().

218 {
219  int i;
220 
221  for (i = 0; i < num_logfiles; ++i) {
222  if (logfiles[i].file == stderr) {
223  logfiles[i].minimum_output_level = level;
224  break;
225  }
226  }
227 }
static struct @66 logfiles[MAX_LOGFILES]
FILE * file
Definition: log.c:133
static int num_logfiles
Definition: log.c:138
void log_set_syslog ( const char *  ident,
int  syslog_level 
)

Definition at line 248 of file log.c.

References debug(), LOG_PID, and openlog().

Referenced by get_and_set_debugs(), init_bearerbox(), init_smsbox(), init_wapbox(), and remove_pid_file().

249 {
250  if (ident == NULL)
251  dosyslog = 0;
252  else {
253  dosyslog = 1;
254  sysloglevel = syslog_level;
255  openlog(ident, LOG_PID, syslogfacility);
256  debug("gwlib.log", 0, "Syslog logging enabled.");
257  }
258 }
static int dosyslog
Definition: log.c:175
static void openlog(const char *ident, int option, int facility)
Definition: log.c:114
static int sysloglevel
Definition: log.c:173
Definition: log.c:106
void debug(const char *place, int err, const char *fmt,...)
Definition: log.c:690
static int syslogfacility
Definition: log.c:174
void log_set_syslog_facility ( char *  facility)

Definition at line 242 of file log.c.

References decode().

Referenced by init_bearerbox(), init_smsbox(), and init_wapbox().

243 {
244  if (facility != NULL)
245  syslogfacility = decode(facility);
246 }
static int decode(char *name)
Definition: log.c:109
static int syslogfacility
Definition: log.c:174
void log_shutdown ( void  )

Definition at line 209 of file log.c.

References gw_rwlock_destroy(), and log_close_all().

Referenced by gwlib_shutdown().

210 {
211  log_close_all();
212  /* destroy rwlock */
214 }
void gw_rwlock_destroy(RWLock *lock)
Definition: gw-rwlock.c:112
static RWLock rwlock
Definition: log.c:168
void log_close_all(void)
Definition: log.c:305
void log_thread_to ( int  idx)

Definition at line 723 of file log.c.

References filename, info(), logfiles, minimum_output_level, thread_slot, thread_to, and warning().

Referenced by at2_device_thread(), cgw_listener(), cgw_sender(), emi2_listener(), emi2_sender(), fake_listener(), httpsmsc_receiver(), httpsmsc_send_cb(), httpsmsc_sender(), io_thread(), smasi_thread(), wrapper_receiver(), and wrapper_sender().

724 {
725  long thread_id = thread_slot();
726 
727  if (idx > 0) {
728  info(0, "Logging thread `%ld' to logfile `%s' with level `%d'.",
729  thread_id, logfiles[idx].filename, logfiles[idx].minimum_output_level);
730  thread_to[thread_id] = idx;
731  } else if (idx != 0 && num_logfiles > 0) {
732  warning(0, "Logging thread `%ld' to logfile `%s' with level `%d'.",
733  thread_id, logfiles[0].filename, logfiles[0].minimum_output_level);
734  }
735 }
void info(int err, const char *fmt,...)
Definition: log.c:636
static struct @66 logfiles[MAX_LOGFILES]
static unsigned int thread_to[(long) THREADTABLE_SIZE]
Definition: log.c:146
int minimum_output_level
Definition: log.c:134
static int num_logfiles
Definition: log.c:138
void warning(int err, const char *fmt,...)
Definition: log.c:624
char filename[FILENAME_MAX+1]
Definition: log.c:135
#define thread_slot()
Definition: log.c:153
static void openlog ( const char *  ident,
int  option,
int  facility 
)
static

Definition at line 114 of file log.c.

Referenced by log_set_syslog().

115 {
116 }
static int place_is_not_logged ( const char *  place)
static

Definition at line 675 of file log.c.

References num_places, and place_matches().

Referenced by debug().

676 {
677  int i;
678 
679  if (num_places == 0)
680  return 0;
681  for (i = 0; i < num_places; ++i) {
682  if (*loggable_places[i] == '-' &&
683  place_matches(place, loggable_places[i]+1))
684  return 1;
685  }
686  return 0;
687 }
static int num_places
Definition: log.c:162
static char * loggable_places[MAX_LOGGABLE_PLACES]
Definition: log.c:161
static int place_matches(const char *place, const char *pat)
Definition: log.c:648
static int place_matches ( const char *  place,
const char *  pat 
)
static

Definition at line 648 of file log.c.

Referenced by place_is_not_logged(), and place_should_be_logged().

649 {
650  size_t len;
651 
652  len = strlen(pat);
653  if (pat[len-1] == '*')
654  return (strncasecmp(place, pat, len - 1) == 0);
655 
656  return (strcasecmp(place, pat) == 0);
657 }
static int place_should_be_logged ( const char *  place)
static

Definition at line 660 of file log.c.

References num_places, and place_matches().

Referenced by debug().

661 {
662  int i;
663 
664  if (num_places == 0)
665  return 1;
666  for (i = 0; i < num_places; ++i) {
667  if (*loggable_places[i] != '-' &&
668  place_matches(place, loggable_places[i]))
669  return 1;
670  }
671  return 0;
672 }
static int num_places
Definition: log.c:162
static char * loggable_places[MAX_LOGGABLE_PLACES]
Definition: log.c:161
static int place_matches(const char *place, const char *pat)
Definition: log.c:648
static void PRINTFLIKE ( ,
 
)
static

Definition at line 458 of file log.c.

459 {
460  vfprintf(f, buf, args);
461  fflush(f);
462 }
static void PRINTFLIKE ( ,
 
)
static

Definition at line 465 of file log.c.

References GW_DEBUG, GW_ERROR, GW_INFO, GW_PANIC, GW_WARNING, LOG_ALERT, LOG_DEBUG, LOG_ERR, LOG_INFO, LOG_WARNING, and syslog().

466 {
467  char buf[4096]; /* Trying to syslog more than 4K could be bad */
468  int translog;
469 
470  if (level >= sysloglevel && dosyslog) {
471  vsnprintf(buf, sizeof(buf), format, args);
472  /* XXX vsnprint not 100% portable */
473 
474  switch(level) {
475  case GW_DEBUG:
476  translog = LOG_DEBUG;
477  break;
478  case GW_INFO:
479  translog = LOG_INFO;
480  break;
481  case GW_WARNING:
482  translog = LOG_WARNING;
483  break;
484  case GW_ERROR:
485  translog = LOG_ERR;
486  break;
487  case GW_PANIC:
488  translog = LOG_ALERT;
489  break;
490  default:
491  translog = LOG_INFO;
492  break;
493  }
494  syslog(translog, "%s", buf);
495  }
496 }
Definition: log.c:106
static int dosyslog
Definition: log.c:175
static int sysloglevel
Definition: log.c:173
Definition: log.h:69
Definition: log.h:69
Definition: log.h:69
static void syslog(int translog, const char *msg,...)
Definition: log.c:118
Definition: log.h:69
Definition: log.c:106
Definition: log.c:106
Definition: log.c:106
Definition: log.h:69
static void syslog ( int  translog,
const char *  msg,
  ... 
)
static

Definition at line 118 of file log.c.

Referenced by PRINTFLIKE().

119 {
120 }
void warning ( int  err,
const char *  fmt,
  ... 
)

Definition at line 624 of file log.c.

References FUNCTION_GUTS, FUNCTION_GUTS_EXCL, GW_WARNING, thread_slot, and thread_to.

Referenced by add_item(), add_msisdn(), add_x_wap_tod(), alog_open(), at2_open_device1(), authorise_username(), bb_reload_smsc_groups(), bb_smscconn_receive_internal(), bb_smscconn_send_failed(), boxc_receiver(), cant_handle_event(), cfg_get_bool(), cgw_check_acks(), cgw_listener(), charset_convert(), charset_gsm_to_utf8(), charset_utf8_to_gsm(), check_config(), check_reversible(), check_variable_syntax(), cimd2_close_socket(), cimd2_destroy(), cimd2_get_packet(), cimd2_handle_request(), cimd2_login(), cimd2_receive_msg(), cimd2_request(), cimd2_send_alive(), cimd_submit_msg(), client_session(), concat_handling_check_and_handle(), concat_handling_clear_old_parts(), config_reload(), conn_read_withlen(), convert_addr_from_pdu(), convert_cimd2_to_gsm(), convert_si_to_sic(), convert_sl_to_slc(), convert_wml_to_wmlc(), convert_wmlscript_to_wmlscriptc(), copy_until_assign(), copy_until_coma(), copy_until_nul(), create_onetrans(), create_oneuser(), date_format_http(), deliver_sms_to_queue(), destroy_methodmachines(), destroy_pushmachines(), dispatch_datagram(), dlr_add(), dlr_find(), dlr_init(), do_queue_cleanup(), emi2_idleprocessing(), emi2_listener(), emi2_send_loop(), empty_msg_lists(), fake_listener(), fdset_destroy(), fdset_listen(), fdset_unregister(), fill_message(), generic_init(), generic_parse_reply(), get_fields(), get_mime_boundary(), get_pattern(), get_x_kannel_from_headers(), gw_check_area_size(), gwthread_dumpsigmask(), gwthread_join(), gwthread_join_every(), gwthread_shutdown(), gwthread_sleep(), gwthread_sleep_micro(), handle_dlr(), handle_method_event(), handle_operation(), handle_pdu(), handle_push_event(), handle_push_message(), handle_split(), headers_acceptable(), heartbeat_stop(), http_header_quoted_string_len(), httpsmsc_send_cb(), init_bearerbox(), io_thread(), ip_allowed_by_ppg(), ip_allowed_by_user(), log_thread_to(), main(), main_for_producer_and_consumer(), main_loop(), main_thread(), mime_decompile(), mime_parse(), msg_to_bb(), normalize_charset(), numhash_create(), obey_request_thread(), octstr_base64_to_binary(), octstr_dump_real(), octstr_url_decode(), ois_check_input(), ois_close(), ois_disconnect(), ois_disconnect_all(), ois_pending_smsmessage(), ois_submit_msg(), oisd_accept_message(), oisd_close_socket(), oisd_destroy(), oisd_get_packet(), oisd_login(), oisd_receive_msg(), oisd_request(), oisd_send_delivery_request(), ota_pack_push_headers(), pack_accept_encoding(), pack_challenge(), pack_content_disposition(), pack_content_range(), pack_credentials(), pack_range(), pack_warning(), packet_add_parm(), packet_check(), packet_check_can_receive(), packet_check_header(), packet_check_parameter(), packet_encode_message(), packet_extract(), pap_compile(), pap_request_thread(), parse_address(), parse_attribute(), parse_bearer(), parse_code(), parse_date(), parse_delivery_method(), parse_document(), parse_element(), parse_network(), parse_node(), parse_ota_syncsettings(), parse_priority(), parse_requirement(), parse_state(), pass_data_headers(), port_add(), proxy_thread(), proxy_unpack_credentials(), read_available(), read_messages_from_bearerbox(), receive_push_reply(), return_reply(), route_incoming_to_boxc(), route_msg(), sanitize_capabilities(), send_file(), send_post(), send_request(), server_thread(), set_dlr_mask(), signal_handler(), skip_until_after_colon(), smasi_pdu_create(), smasi_pdu_dump(), smasi_pdu_unpack(), smpp_emu(), sms_receive(), smsbox_req_handle(), smsbox_req_sendsms(), smsc2_add_smsc(), smsc2_restart_smsc(), smsc2_rout(), smsc2_start(), smsc_cimd2_create(), smsc_emi2_create(), smsc_http_create(), smsc_smpp_create(), smscconn_create(), smscconn_send(), soap_parse_response(), spawn_thread(), split_headers(), store_file_load(), store_to_dict(), timers_shutdown(), transform_message(), udp_receiver(), unpack_accept_language_general_form(), unpack_cache_directive(), unpack_challenge(), unpack_content_range(), unpack_credentials(), unpack_datagram(), unpack_disposition(), unpack_encoding_version(), unpack_field_name(), unpack_optional_q_value(), unpack_parameter(), unpack_range_value(), unpack_retry_after(), unpack_warning_value(), unpack_wdp_datagram_real(), update_table(), update_tables(), wait_for_ack(), wap_dispatch_datagram(), wdp_to_wapboxes(), write_data(), wsp_cap_unpack_list(), wsp_headers_pack(), wsp_headers_unpack(), wsp_pack_application_header(), wsp_pack_date(), wsp_pack_integer_string(), wsp_pack_separate_content_type(), wsp_pdu_unpack(), wsp_unpack_accept_charset_general_form(), wsp_unpack_accept_general_form(), wsp_unpack_app_header(), wsp_unpack_date_value(), wsp_unpack_integer_value(), wsp_unpack_well_known_field(), wtp_pdu_create(), wtp_pdu_destroy(), wtp_pdu_unpack(), wtp_unpack_wdp_datagram(), X28_open_send_link(), and xmlrpc_doc_destroy().

625 {
626  int e;
627 
628  if ((e = thread_to[thread_slot()])) {
630  } else {
632  }
633 }
#define FUNCTION_GUTS_EXCL(level, place)
Definition: log.c:538
static unsigned int thread_to[(long) THREADTABLE_SIZE]
Definition: log.c:146
Definition: log.h:69
#define thread_slot()
Definition: log.c:153
#define FUNCTION_GUTS(level, place)
Definition: log.c:508

Variable Documentation

int dosyslog = 0
static

Definition at line 175 of file log.c.

enum excl_state exclusive

Definition at line 136 of file log.c.

char* loggable_places[MAX_LOGGABLE_PLACES]
static

Definition at line 161 of file log.c.

int minimum_output_level

Definition at line 134 of file log.c.

Referenced by log_thread_to().

int num_logfiles = 0
static
int num_places = 0
static

Definition at line 162 of file log.c.

Referenced by place_is_not_logged(), and place_should_be_logged().

RWLock rwlock
static

Definition at line 168 of file log.c.

int syslogfacility = LOG_DAEMON
static

Definition at line 174 of file log.c.

int sysloglevel
static

Definition at line 173 of file log.c.

unsigned int thread_to[(long) THREADTABLE_SIZE]
static

Definition at line 146 of file log.c.

Referenced by debug(), error(), info(), log_init(), log_thread_to(), and warning().

See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.