You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by "David S. Faller" <df...@hursley.ibm.com> on 2001/06/06 18:23:40 UTC
LoggingService getLogLevel
Hi everyone...
I have a question regarding the LoggingService:
Has anybody thought about adding a get-method for the loglevel?
I am asking, because in performance critical environments problems might
arise for debug messages.
Most debug statements look like this:
Log.debug("myMethod() entered. param1="+param1+";param2="+param2);
In a production system, the log level is INFO or higher, so all string
operations for the call are unnecessary.
What about something like:
if (Log.getLogLevel() > Log.LEVEL_DEBUG) {
Log.debug("myMethod() entered. param1="+param1+";param2="+param2);
}
This would reduce unnecessary operations and improve performance...
Any comments?
cya,
David
-----
public void mystery_of_life()
{
do
{
System.breatheIn();
System.breatheOut();
}
while( !dead );
}
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: LoggingService getLogLevel
Posted by Daniel Rall <dl...@finemaltcoding.com>.
"David S. Faller" <df...@hursley.ibm.com> writes:
> Hi everyone...
>
> I have a question regarding the LoggingService:
> Has anybody thought about adding a get-method for the loglevel?
>
> I am asking, because in performance critical environments problems might
> arise for debug messages.
>
> Most debug statements look like this:
> Log.debug("myMethod() entered. param1="+param1+";param2="+param2);
>
> In a production system, the log level is INFO or higher, so all string
> operations for the call are unnecessary.
>
> What about something like:
> if (Log.getLogLevel() > Log.LEVEL_DEBUG) {
> Log.debug("myMethod() entered. param1="+param1+";param2="+param2);
> }
>
> This would reduce unnecessary operations and improve performance...
I'm in favor of this. We've noted the same thing at CollabNet, and
often use per-class private boolean constants to achieve the same
effect.
Daniel Rall
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: Table comment
Posted by Benoit Jacquemont <be...@smile.fr>.
Hi,
I finished the modification I described below on the Column.java object.
I attached the patch file.
Benoît
> Hi everybody,
>
> I made a little change to the Table object
> (org.apache.turbine.torque.engine.database.model.Table) that allow the use
> of a comment attribute. It can be retrieved from the XML file that describe
> the database structure.
> I know that Oracle can stored comment for table.
>
> I joined the path file.
>
> I scheduled to do the same (i.e. comment attribute) for the Column object
> (org.apache.turbine.torque.engine.database.model.Column), and some other
> changes listed below:
> - getJavaAttributeName : return the name of the column following the
> JavaBean naming convention: word1Word2. Very useful to generate JavaBean
> - getStandardObjectType : return the Java object type associated to the
> column type. It is different from getJavaNative, because it returns only
> standard java.lang type, not DateKey or StringKey, etc... The type returns
> can only be Object and not primitive type (Integer instead of int, Double
> instead of double...).
> - getStandardType : return the Java type, including primitive type, but not
> the xxxxKey type.
> - hasDefaultValue : return true if the default value has been set for the
> column. False otherwise.
>
> That's all (for the moment ;-)).
>
> I'm waiting for your comments.
>
> TIA
>
> Benoît
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: Table comment
Posted by Benoit Jacquemont <be...@smile.fr>.
I forgot to join the file...
Sorry about that.
Benoît
> Hi everybody,
>
> I made a little change to the Table object
> (org.apache.turbine.torque.engine.database.model.Table) that allow the use
> of a comment attribute. It can be retrieved from the XML file that describe
> the database structure.
> I know that Oracle can stored comment for table.
>
> I joined the path file.
>
> I scheduled to do the same (i.e. comment attribute) for the Column object
> (org.apache.turbine.torque.engine.database.model.Column), and some other
> changes listed below:
> - getJavaAttributeName : return the name of the column following the
> JavaBean naming convention: word1Word2. Very useful to generate JavaBean
> - getStandardObjectType : return the Java object type associated to the
> column type. It is different from getJavaNative, because it returns only
> standard java.lang type, not DateKey or StringKey, etc... The type returns
> can only be Object and not primitive type (Integer instead of int, Double
> instead of double...).
> - getStandardType : return the Java type, including primitive type, but not
> the xxxxKey type.
> - hasDefaultValue : return true if the default value has been set for the
> column. False otherwise.
>
> That's all (for the moment ;-)).
>
> I'm waiting for your comments.
>
> TIA
>
> Benoît
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Table comment
Posted by Benoit Jacquemont <be...@smile.fr>.
Hi everybody,
I made a little change to the Table object
(org.apache.turbine.torque.engine.database.model.Table) that allow the use of
a comment attribute. It can be retrieved from the XML file that describe the
database structure.
I know that Oracle can stored comment for table.
I joined the path file.
I scheduled to do the same (i.e. comment attribute) for the Column object
(org.apache.turbine.torque.engine.database.model.Column), and some other
changes listed below:
- getJavaAttributeName : return the name of the column following the JavaBean
naming convention: word1Word2. Very useful to generate JavaBean
- getStandardObjectType : return the Java object type associated to the
column type. It is different from getJavaNative, because it returns only
standard java.lang type, not DateKey or StringKey, etc... The type returns
can only be Object and not primitive type (Integer instead of int, Double
instead of double...).
- getStandardType : return the Java type, including primitive type, but not
the xxxxKey type.
- hasDefaultValue : return true if the default value has been set for the
column. False otherwise.
That's all (for the moment ;-)).
I'm waiting for your comments.
TIA
Benoît
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: LoggingService getLogLevel [Patch]
Posted by Daniel Rall <dl...@finemaltcoding.com>.
"David S. Faller" <df...@hursley.ibm.com> writes:
> Daniel,
>
> can you commit the patch? (I am no committer...)
I will commit the patch to the tip of the 2.1 branch, likely tonight.
Daniel
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: LoggingService getLogLevel [Patch]
Posted by "David S. Faller" <df...@hursley.ibm.com>.
Daniel,
can you commit the patch? (I am no committer...)
cya,
David
-----
public void mystery_of_life()
{
do
{
System.breatheIn();
System.breatheOut();
}
while( !dead );
}
----- Original Message -----
From: "Jon Stevens" <jo...@latchkey.com>
To: "turbine-dev" <tu...@jakarta.apache.org>
Sent: Friday, June 15, 2001 8:01 PM
Subject: Re: LoggingService getLogLevel [Patch]
> Well, it doesn't matter that much anymore since Jason just got rid of the
> entire logging service in the HEAD tree...but for those of you using 2.1.x
> it will matter I guess...
>
> I say go for it...
>
> -jon
>
> on 6/15/01 9:25 AM, "David S. Faller" <df...@hursley.ibm.com> wrote:
>
> > Any more opinions?
> >
> > We have two +1's...
> >
> >
> >
> >
> >> on 6/7/01 3:09 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:
> >>
> >>> I am +1 on this commit. Other comments?
> >>
> >> +1
> >>
> >> -jon
>
> --
> "Open source is not available to commercial companies."
> -Steve Ballmer, CEO Microsoft
> <http://www.suntimes.com/output/tech/cst-fin-micro01.html>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: LoggingService getLogLevel [Patch]
Posted by Jon Stevens <jo...@latchkey.com>.
Well, it doesn't matter that much anymore since Jason just got rid of the
entire logging service in the HEAD tree...but for those of you using 2.1.x
it will matter I guess...
I say go for it...
-jon
on 6/15/01 9:25 AM, "David S. Faller" <df...@hursley.ibm.com> wrote:
> Any more opinions?
>
> We have two +1's...
>
>
>
>
>> on 6/7/01 3:09 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:
>>
>>> I am +1 on this commit. Other comments?
>>
>> +1
>>
>> -jon
--
"Open source is not available to commercial companies."
-Steve Ballmer, CEO Microsoft
<http://www.suntimes.com/output/tech/cst-fin-micro01.html>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: LoggingService getLogLevel [Patch]
Posted by "David S. Faller" <df...@hursley.ibm.com>.
Any more opinions?
We have two +1's...
> on 6/7/01 3:09 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:
>
> > I am +1 on this commit. Other comments?
>
> +1
>
> -jon
>
> --
> "Open source is not available to commercial companies."
> -Steve Balmer, CEO Microsoft
> <http://www.suntimes.com/output/tech/cst-fin-micro01.html>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: LoggingService getLogLevel [Patch]
Posted by Jon Stevens <jo...@latchkey.com>.
on 6/7/01 3:09 PM, "Daniel Rall" <dl...@finemaltcoding.com> wrote:
> I am +1 on this commit. Other comments?
+1
-jon
--
"Open source is not available to commercial companies."
-Steve Balmer, CEO Microsoft
<http://www.suntimes.com/output/tech/cst-fin-micro01.html>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: LoggingService getLogLevel [Patch]
Posted by Daniel Rall <dl...@finemaltcoding.com>.
I am +1 on this commit. Other comments?
"David S. Faller" <df...@hursley.ibm.com> writes:
[snip]
> I would prefer a 'dynamic' method,too. Otherwise it would be necessary to
> recompile your code, if you want to see the debug messages.
>
> What about this?
>
>
> --- Logger.java 2001/04/12 02:22:58 1.9
> +++ Logger.java 2001/06/07 12:15:03
> @@ -151,6 +151,26 @@
> public void setLogLevel(int level);
>
> /**
> + * Checks if DEBUG statements are enabled.
> + */
> + public boolean isDebugEnabled();
> +
> + /**
> + * Checks if INFO statements are enabled.
> + */
> + public boolean isInfoEnabled();
> +
> + /**
> + * Checks if WARN statements are enabled.
> + */
> + public boolean isWarnEnabled();
> +
> + /**
> + * Checks if ERROR statements are enabled.
> + */
> + public boolean isErrorEnabled();
> +
> + /**
> * This method should be implemented by user.
> * It performs action that are need for deterimne whether
> * logger was well configured or has any output
>
>
>
> --- BaseLogger.java 2001/04/06 18:41:51 1.9
> +++ BaseLogger.java 2001/06/07 12:27:11
> @@ -222,6 +222,38 @@
> }
> /**
> + * Checks if DEBUG statements are enabled.
> + */
> + public boolean isDebugEnabled()
> + {
> + return (logLevel == DEBUG);
> + }
> +
> + /**
> + * Checks if INFO statements are enabled.
> + */
> + public boolean isInfoEnabled()
> + {
> + return (logLevel <= INFO);
> + }
> +
> + /**
> + * Checks if WARN statements are enabled.
> + */
> + public boolean isWarnEnabled()
> + {
> + return (logLevel <= WARN);
> + }
> +
> + /**
> + * Checks if ERROR statements are enabled.
> + */
> + public boolean isErrorEnabled()
> + {
> + return (logLevel <= ERROR);
> + }
> +
> + /**
> * This method should be implemented by user if the logger can handle
> files.
> * It adds local file as destinations for logger.
> *
>
> cya,
> David
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: LoggingService getLogLevel [Patch]
Posted by "David S. Faller" <df...@hursley.ibm.com>.
> Jon Stevens <jo...@latchkey.com> writes:
>
> > on 6/6/01 9:23 AM, "David S. Faller" <df...@hursley.ibm.com> wrote:
> >
> > > What about something like:
> > > if (Log.getLogLevel() > Log.LEVEL_DEBUG) {
> > > Log.debug("myMethod() entered. param1="+param1+";param2="+param2);
> > > }
> >
> > Actually, that still doesn't work 100% well...here is some test
> > code...compile it and then run javap -c Test and you will see that using
a
> > method like that does not compile out the code as you would hope it
does...
If you want the compiler to optimize the code, it should look like this:
public class Test
{
public static final boolean debug = false;
public static void debug(String log_me) {
if (debug) {
System.out.println(log_me);
}
}
public static void main(String args[]) {
if (debug) debug("strings");
debug("still");
debug("in");
debug("class");
debug("file");
}
}
The debug("strings") call is not compiled, since it is never used (public
static _final_ will never change)...
>
> Regardless of whether the log level thing compiles code out (which it
> does not, as you say), it does save numerous method calls to
> StringBuffer's append() method, and one call to its toString() method
> for a standard String concatenation operation.
>
> Dan
I would prefer a 'dynamic' method,too. Otherwise it would be necessary to
recompile your code, if you want to see the debug messages.
What about this?
--- Logger.java 2001/04/12 02:22:58 1.9
+++ Logger.java 2001/06/07 12:15:03
@@ -151,6 +151,26 @@
public void setLogLevel(int level);
/**
+ * Checks if DEBUG statements are enabled.
+ */
+ public boolean isDebugEnabled();
+
+ /**
+ * Checks if INFO statements are enabled.
+ */
+ public boolean isInfoEnabled();
+
+ /**
+ * Checks if WARN statements are enabled.
+ */
+ public boolean isWarnEnabled();
+
+ /**
+ * Checks if ERROR statements are enabled.
+ */
+ public boolean isErrorEnabled();
+
+ /**
* This method should be implemented by user.
* It performs action that are need for deterimne whether
* logger was well configured or has any output
--- BaseLogger.java 2001/04/06 18:41:51 1.9
+++ BaseLogger.java 2001/06/07 12:27:11
@@ -222,6 +222,38 @@
}
/**
+ * Checks if DEBUG statements are enabled.
+ */
+ public boolean isDebugEnabled()
+ {
+ return (logLevel == DEBUG);
+ }
+
+ /**
+ * Checks if INFO statements are enabled.
+ */
+ public boolean isInfoEnabled()
+ {
+ return (logLevel <= INFO);
+ }
+
+ /**
+ * Checks if WARN statements are enabled.
+ */
+ public boolean isWarnEnabled()
+ {
+ return (logLevel <= WARN);
+ }
+
+ /**
+ * Checks if ERROR statements are enabled.
+ */
+ public boolean isErrorEnabled()
+ {
+ return (logLevel <= ERROR);
+ }
+
+ /**
* This method should be implemented by user if the logger can handle
files.
* It adds local file as destinations for logger.
*
cya,
David
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: LoggingService getLogLevel
Posted by Daniel Rall <dl...@finemaltcoding.com>.
Jon Stevens <jo...@latchkey.com> writes:
> on 6/6/01 9:23 AM, "David S. Faller" <df...@hursley.ibm.com> wrote:
>
> > What about something like:
> > if (Log.getLogLevel() > Log.LEVEL_DEBUG) {
> > Log.debug("myMethod() entered. param1="+param1+";param2="+param2);
> > }
>
> Actually, that still doesn't work 100% well...here is some test
> code...compile it and then run javap -c Test and you will see that using a
> method like that does not compile out the code as you would hope it does...
Regardless of whether the log level thing compiles code out (which it
does not, as you say), it does save numerous method calls to
StringBuffer's append() method, and one call to its toString() method
for a standard String concatenation operation.
Dan
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org
Re: LoggingService getLogLevel
Posted by Jon Stevens <jo...@latchkey.com>.
on 6/6/01 9:23 AM, "David S. Faller" <df...@hursley.ibm.com> wrote:
> What about something like:
> if (Log.getLogLevel() > Log.LEVEL_DEBUG) {
> Log.debug("myMethod() entered. param1="+param1+";param2="+param2);
> }
Actually, that still doesn't work 100% well...here is some test
code...compile it and then run javap -c Test and you will see that using a
method like that does not compile out the code as you would hope it does...
import java.io.*;
import java.lang.*;
import java.util.*;
public class Test
{
public static boolean getDebug()
{
return false;
}
public static void debug(String log_me) {
if (getDebug()) {
System.out.println(log_me);
}
}
public static void main(String args[]) {
if (getDebug()) debug("strings");
debug("still");
debug("in");
debug("class");
debug("file");
}
}
A better solution is to do something like this:
if (Log.DEBUG && Log.getLogLevel() > Log.LEVEL_DEBUG )
We can then use Ant to do a <replace> in the .java code in the Log.java
class for the Log.DEBUG return value.
Feel free to submit a patch. :-)
-jon
--
"Open source is not available to commercial companies."
-Steve Balmer, CEO Microsoft
<http://www.suntimes.com/output/tech/cst-fin-micro01.html>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org