Re: exception std::out_of_range in StringHelper::startsWith

2010-10-15 Thread Jacob L. Anawalt

On 10/12/2010 10:24 AM, Thorsten Schöning wrote:

I get an out_of_range exception everytime I use a logger which name is
longer than the name of the root logger


I'm not sure what this named root logger you're referring too. In xml 
config it's just root and in property format it's log4j.rootLogger.


I have logging hierarchies where the child logger's name is longer 
than the parent's in a java like way only I sometimes use 
abbreviations of my classes and sometimes use names/levels for 
non-class things. Eg, for a postgresql accessing class:


PQ
PQ.Worker
PQ.TX
PQ.TX.Lookup

I've been building with the GCC on Debian for a few years now without 
any out_of_range errors to do with log4cxx loggers.


--
Jacob Anawalt
Gecko Software, Inc.
janaw...@geckosoftware.com
435-752-8026


exception std::out_of_range in StringHelper::startsWith

2010-10-12 Thread Thorsten Schöning
Hello,

I get an out_of_range exception everytime I use a logger which name is
longer than the name of the root logger and wonder if anyone else ran
into this problem, too. We use a pretty old Borland Builder 5, may it
be an implementation issue of the stl? Reading how
basic_string::compare works for other implementations the current
startWith should work, in my opinion.

http://www.sgi.com/tech/stl/basic_string.html

I had to make the following changes:

Index: stringhelper.cpp
===
--- stringhelper.cpp(Revision 1652)
+++ stringhelper.cpp(Arbeitskopie)
@@ -79,6 +79,11 @@
 
 bool StringHelper::startsWith(const LogString s, const LogString prefix)
 {
+if (s.length()  prefix.length())
+{
+  return false;
+}
+
 return s.compare(0, prefix.length(), prefix) == 0;
 }

Mit freundlichen Grüßen,

Thorsten Schöning

-- 
Thorsten Schöning
AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig
 
Telefon: Potsdam: 0331-743881-0
E-Mail:  tschoen...@am-soft.de
Web: http://www.am-soft.de

AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow