RE: glib's g_logv 1024 byte maximum character array



On Tue, 22 Jul 2003 martyn 2 russell bt com wrote:

> > What is you are logging more exactly?
>
> I am logging all information that is inbound and outbound from a TCP socket.
> My application is Gnome-Jabber (http://gnome-jabber.sourceforge.net/) and I
> need to record all presence events, messages, chats, etc, etc.....
>
> I want to use g_log (or g_message/g_warning/g_error/etc) because that is a
> common interface to the logging in my code, this includes warnings, errors
> and any other information I am interested about from other domains (i.e.
> XML, Glade, GObject, etc) to.

the logging string limitation is not related to syslog in any way.

also, the limitation is not shared by glib's printf-style functions
or libc's printf-style functions.

> Frankly, I am surprised no one saw this bug sooner.

it's not a bug. if you actually take a look at gmessage.c, it says:

  /* we use a stack buffer of fixed size, because we might get called
   * recursively.
   */
  _g_vsnprintf (buffer, 1024, format, args1);

the code has been reordered quite bit since this was first written.
nowadays, the _g_vsnprintf() could be changed to a g_strdup_printf()
directly before log_func() if this is not a recursive call. so
for the common case, the 1024 byte limit can be removed.
(keep in mind, that g_malloc/g_strdup/etc. also use g_log(), so
if not enough memory is available to hold the log string, we
will end up in a recursive call).

> Regards,
> Martyn.
>

---
ciaoTJ





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]