navit  0.5.3-trunk
log.h File Reference

Go to the source code of this file.

Macros

#define LOG_BUFFER_SIZE   256
 

Enumerations

enum  log_flags {
  log_flag_replace_buffer =1 , log_flag_force_flush =2 , log_flag_keep_pointer =4 , log_flag_keep_buffer =8 ,
  log_flag_truncate =16
}
 

Functions

int log_get_attr (struct log *this_, enum attr_type type, struct attr *attr, struct attr_iter *iter)
 Gets an attribute. More...
 
struct loglog_new (struct attr *parent, struct attr **attrs)
 Creates and initializes a new log object. More...
 
void log_set_header (struct log *this_, char *data, int len)
 Sets the header for a log file. More...
 
void log_set_trailer (struct log *this_, char *data, int len)
 Sets the trailer for a log file. More...
 
void log_write (struct log *this_, char *data, int len, enum log_flags flags)
 Writes to a log. More...
 
void * log_get_buffer (struct log *this_, int *len)
 Returns the data buffer of a log object and its length. More...
 
void log_printf (struct log *this_, char *fmt,...)
 Writes a formatted string to a log. More...
 
void log_destroy (struct log *this_)
 Destroys a log object and frees up its memory. More...
 

Macro Definition Documentation

◆ LOG_BUFFER_SIZE

#define LOG_BUFFER_SIZE   256

Navit, a modular navigation system. Copyright (C) 2005-2008 Navit Team

This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License version 2 as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details.

You should have received a copy of the GNU Library General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Enumeration Type Documentation

◆ log_flags

enum log_flags

printf-style writing to the log file. A buffer of LOG_BUFFER_SIZE bytes is preallocated for the complete format message, longer messages will be truncated.

Enumerator
log_flag_replace_buffer 
log_flag_force_flush 
log_flag_keep_pointer 
log_flag_keep_buffer 
log_flag_truncate 

Function Documentation

◆ log_destroy()

void log_destroy ( struct log this_)

Destroys a log object and frees up its memory.

Parameters
this_The log object.

References attr_list_free(), callback_destroy(), dbg, event_remove_timeout(), log_close(), log_flush(), lvl_debug, log::timer, and log::timer_callback.

◆ log_get_attr()

int log_get_attr ( struct log this_,
enum attr_type  type,
struct attr attr,
struct attr_iter iter 
)

Gets an attribute.

Parameters
this_The log object.
attr_typeThe attribute type to return
attrPoints to a struct attr to store the attribute
iterAn attribute iterator
Returns
True for success, false for failure

References attr_generic_get_attr(), and type.

Referenced by navit_add_log(), vehicle_add_log(), and vehicle_log_gpx().

◆ log_get_buffer()

void* log_get_buffer ( struct log this_,
int *  len 
)

Returns the data buffer of a log object and its length.

Parameters
this_The log object.
lenPoints to an int which will receive the length of the buffer. This can be NULL, in which case no information on buffer length will be stored.
Returns
Pointer to the data buffer.

References log_data::data, log::data, and log_data::len.

Referenced by vehicle_log_binfile().

◆ log_new()

struct log* log_new ( struct attr parent,
struct attr **  attrs 
)

Creates and initializes a new log object.

Parameters
parentThe parent object.
attrsPoints to an array of pointers to attributes for the new log object
Returns
The new log object, or NULL if creation fails.

References attr_list_dup(), attr_search(), callback_cast, callback_new_1, data, dbg, event_add_timeout(), expand_filenames(), file_wordexp_destroy(), file_wordexp_get_array(), file_wordexp_get_count(), file_wordexp_new(), log::filename, filename, log::flush_size, log::flush_time, log::lazy, log_func, log_open(), log_set_last_flush(), log_timer(), lvl_debug, log::mkdir, navit_object_ref(), attr::num, log::overwrite, log::timer, log::timer_callback, and attr::u.

◆ log_printf()

void log_printf ( struct log this_,
char *  fmt,
  ... 
)

Writes a formatted string to a log.

This function formats a string in a fashion similar to

printf()

and related functions and writes it to a log using

void log_write(struct log *this_, char *data, int len, enum log_flags flags)
Writes to a log.
Definition: log.c:468

.

Parameters
this_The log object.
fmtThe format string.
...Additional arguments must be specified for each placeholder in the format string.

References LOG_BUFFER_SIZE, log_write(), and size.

◆ log_set_header()

void log_set_header ( struct log this_,
char *  data,
int  len 
)

Sets the header for a log file.

This function sets the header, which is to be inserted into any log file before the actual log data.

Parameters
this_The log object.
dataThe header data.
lenSize of the header data to be copied, in bytes.

References log_data::data, data, log::header, log_data::len, and log_data::max_len.

Referenced by navit_add_log(), and vehicle_add_log().

◆ log_set_trailer()

void log_set_trailer ( struct log this_,
char *  data,
int  len 
)

Sets the trailer for a log file.

This function sets the trailer, which is to be added to any log file after the actual log data.

Parameters
this_The log object.
dataThe trailer data.
lenSize of the trailer data to be copied, in bytes.

References log_data::data, data, log_data::len, log_data::max_len, and log::trailer.

Referenced by vehicle_add_log().

◆ log_write()

void log_write ( struct log this_,
char *  data,
int  len,
enum log_flags  flags 
)

Writes to a log.

This function appends data to a log. It rotates the log, if needed, before adding the new data. After adding, the log is flushed if the buffer exceeds its maximum size or if the

@ log_flag_force_flush
Definition: log.h:31

flag is set.

Parameters
this_The log object.
dataPoints to a buffer containing the data to be appended.
lenLength of the data to be appended, in bytes.
flagsFlags to control behavior of the function:
@ log_flag_replace_buffer
Definition: log.h:30
: discards any data in the buffer not yet written to the log file
: forces a flush of the log after appending the data
{code log_flag_keep_pointer}: ignored
@ log_flag_keep_buffer
Definition: log.h:33
: ignored
@ log_flag_truncate
Definition: log.h:34
: ignored

References log_data::data, log::data, data, dbg, log_data::len, log_change(), log_change_required(), log_flag_force_flush, log_flag_replace_buffer, log_flush(), log_flush_required(), lvl_debug, lvl_info, and log_data::max_len.

Referenced by log_printf(), navit_textfile_debug_log(), navit_textfile_debug_log_at(), vehicle_log_binfile(), vehicle_log_gpx(), vehicle_log_nmea(), and vehicle_log_textfile().