Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals  

logging.c File Reference

#include "logging.h"

Go to the source code of this file.

Defines

#define MAX_TIME_SIZE   512
 Maximum number of characters for a date.

#define MAXLOGFILESIZE   2147381248
 Maximum size (in bytes) fir the log file. More...

#define MAC_ADDRESS_DOTED_SIZE   18
 Maximum number of characters (including the final zero) for a MAC address written with ':' separators. Example: "00:11:22:33:44:55".

#define GATEWAY_IP_MAX_SIZE   16
 Maximum number of characters (including the final zero) for the gateway IP address.

#define NODE_ID_MAX_SIZE   20
 Maximum number of characters (including the final zero) for a node ID.

#define ERROR_SIZE   2048
 Maximum number of characters for the error message.


Functions

void activate_log_size_management ()
 Activate the log size management.

char * logger_last_error ()
 Return the last error message. More...

void logger_set_last_error (const char *fmt,...)
 Set the last error message. More...

void clear_last_error ()
 Clear the last error (set all zeros).

void logging_new_tag ()
 Increment the value of the current tag. More...

void init_client_ids (char *mac, char *vnode_id, unsigned long int vshelf, unsigned long int vslot, unsigned long int vport, unsigned short int vvci, unsigned short int vvlan_id)
 Initialize the client's identifier. More...

void init_syslogger ()
 Initialize the logging system. More...

char * log_tag ()
 Return the current tag. More...

char * dater ()
 Return the current date as Apache's standard. More...

char * filetimestamp ()
 Return a timestamp usable for file name. More...

unsigned long int get_file_size (const char *file)
 Get the size of a given file (in bytes). More...

int my_syslog (const char *file, const char *fmt,...)
 Log one line in a given log file. More...

void logger_set_gateway (const char *g)
 Set the gateway for tag. More...

int my_syslog_skip_line (const char *file)
 Log 2 empty lines in a given log file. More...


Variables

char current_mac_address [MAC_ADDRESS_DOTED_SIZE]
 Current MAC address.

char gateway [GATEWAY_IP_MAX_SIZE]
 Current gateway.

char node_id [NODE_ID_MAX_SIZE]
 Current node ID.

unsigned long int shelf = 0
 Current shelf number.

unsigned long int slot = 0
 Current slot number.

unsigned long int port = 0
 Current port number.

unsigned short int vci = 0
 Current VCI.

unsigned short int vlan_id = 0
 Current VLAN id.

unsigned int current_tag = 0
 Numerical value of the current tag.

int logsize = 0
 This flag defines if the server should manage the size of the log file.

char last_error [ERROR_SIZE]
 Last error for this module.


Detailed Description

This file implements the logging facility.

Definition in file logging.c.


Define Documentation

#define MAXLOGFILESIZE   2147381248
 

Maximum size (in bytes) fir the log file.

Remarks:
2147381248 bytes = 2Go - 100ko

Definition at line 16 of file logging.c.

Referenced by my_syslog().


Function Documentation

char * dater  
 

Return the current date as Apache's standard.

Author:
Denis BEURIVE
Returns:
The function returns a pointer to a string of characters that contains the current date.
Warning:
The string is returned in a statically allocated buffer, which subsequent calls will overwrite.

Definition at line 213 of file logging.c.

References MAX_TIME_SIZE.

Referenced by log_profile(), my_syslog(), and packet_dump().

char* filetimestamp   [static]
 

Return a timestamp usable for file name.

Author:
Denis BEURIVE
Returns:
The function returns a timestamp that can be used for file names.
Warning:
The string is returned in a statically allocated buffer, which subsequent calls will overwrite.

Definition at line 230 of file logging.c.

References MAX_TIME_SIZE.

Referenced by my_syslog().

unsigned long int get_file_size const char *    file [static]
 

Get the size of a given file (in bytes).

Parameters:
file  Path to the file.
Returns:
Upon successful completion, the function returns the size of the file (in bytes). The value 0 can mean that:
  • The file is empty.
  • The file does not exist.
If an error occures, the function returns the value (unsigned long int)(-1).

Definition at line 252 of file logging.c.

References clear_last_error(), and logger_set_last_error().

Referenced by my_syslog().

void init_client_ids char *    mac,
char *    vnode_id,
unsigned long int    vshelf,
unsigned long int    vslot,
unsigned long int    vport,
unsigned short int    vvci,
unsigned short int    vvlan_id
 

Initialize the client's identifier.

Author:
Denis BEURIVE
Parameters:
mac  pointer to a zero terminated string of characters that represents the current MAC address.
vnode_id  Current node ID.
vshelf  Current shelf.
vslot  Current slot.
vport  Current port.
vvci  Current VCI.
vvlan_id  Current vlan_id.

Definition at line 160 of file logging.c.

References current_mac_address, gateway, GATEWAY_IP_MAX_SIZE, MAC_ADDRESS_DOTED_SIZE, node_id, NODE_ID_MAX_SIZE, port, shelf, slot, vci, and vlan_id.

Referenced by main().

void init_syslogger  
 

Initialize the logging system.

Author:
Denis BEURIVE

Definition at line 182 of file logging.c.

References current_mac_address, gateway, GATEWAY_IP_MAX_SIZE, MAC_ADDRESS_DOTED_SIZE, node_id, and NODE_ID_MAX_SIZE.

Referenced by main().

char* log_tag   [static]
 

Return the current tag.

Author:
Denis BEURIVE
Returns:
The function returns a pointer to a statically allocated, zero terminated string of characters that represents the current tag.

Definition at line 195 of file logging.c.

References current_tag.

Referenced by my_syslog().

char* logger_last_error  
 

Return the last error message.

Returns:
The function returns a pointer to a statically alocated string of characters that represents the last error.

Definition at line 105 of file logging.c.

References last_error.

void logger_set_gateway const char *    g
 

Set the gateway for tag.

Parameters:
g  Pointer to a zero terminated string of characters that represents the gateway.

Definition at line 356 of file logging.c.

References gateway, and GATEWAY_IP_MAX_SIZE.

Referenced by main().

void logger_set_last_error const char *    fmt,
...   
[static]
 

Set the last error message.

Parameters:
error  Pointer to a string that represents the last error message.

Definition at line 111 of file logging.c.

References ERROR_SIZE, and last_error.

Referenced by get_file_size(), my_syslog(), and my_syslog_skip_line().

void logging_new_tag  
 

Increment the value of the current tag.

Author:
Denis BEURIVE

Definition at line 131 of file logging.c.

References current_mac_address, current_tag, gateway, GATEWAY_IP_MAX_SIZE, MAC_ADDRESS_DOTED_SIZE, node_id, NODE_ID_MAX_SIZE, port, shelf, slot, vci, and vlan_id.

Referenced by main().

int my_syslog const char *    file,
const char *    fmt,
...   
 

Log one line in a given log file.

Author:
Denis BEURIVE
Parameters:
file  Pointer to a zero terminated string of characters that represents the path to the log file.
ftm  Pointer to a zero terminated string of characters that defines the output formats (same as printf()).
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function returns the value 1.
Remarks:
This function behaves just like the function printf().

Definition at line 277 of file logging.c.

References clear_last_error(), current_mac_address, dater(), filetimestamp(), gateway, get_file_size(), log_tag(), logger_set_last_error(), MAXLOGFILESIZE, node_id, port, shelf, slot, vci, and vlan_id.

Referenced by add_option_to_profile(), ascii_to_binary(), connect_to_mysql(), context2profile(), create_socket(), dump_packet_hexa(), find_ip_and_reply(), get_unix_timestamp(), haddr_to_hexa(), hexa_to_binary(), ip_to_network_byte_order(), load_mysql_configuration_from_file(), look_up_logistic(), main(), packet_dump(), packets_parse_options(), packets_send_ack(), packets_send_dummy_nak(), packets_send_nack(), packets_send_offer(), remove_option_from_profile(), reply_to_inform(), sql_select(), standard_query(), uint16_to_network_byte_order(), and uint32_to_network_byte_order().

int my_syslog_skip_line const char *    file
 

Log 2 empty lines in a given log file.

Author:
Denis BEURIVE
Parameters:
file  Pointer to a zero terminated string of characters that represents the path to the log file.
Returns:
Upon successful completion, the function returns the value 0. Otherwize, the function returns the value 1.

Definition at line 368 of file logging.c.

References clear_last_error(), and logger_set_last_error().

Referenced by main().


Generated on Mon Jun 19 12:31:06 2006 for MyDhcp_V2 by doxygen1.2.15