Should Empty-String be a Valid Argument for writeLog()?

Hi Folks,

First, let me say I’m not heavily invested in this issue (I gave it a
priority of minor), but the current behavior struck me as slightly wrong,
so I wanted to get some feedback.

writeLog("");

Either of those will throw an error of:

you must define attribute text or attribute exception with the tag cflog

I would expect a blank log line, instead. Empty string should be valid,
especially because the value can be dynamic, and if it is, it might be
empty. Of course a blank log probably isn’t too useful, but I’m not sure
throwing a runtime error is the better behavior. The error thrown is
slightly misleading, as well, since the argument is defined.

Here’s the ticket, with Micha’s response:
https://bitbucket.org/lucee/lucee/issue/175/error-with-empty-string-as-text-parameter

Beyond this particular function, there might also be a matter of precedent
involved.

Thoughts?

Thanks,

Jamie

Since it wouldn’t be a useful line in the logs, I can see why it wouldn’t let you log an empty string (and throw an error) but you are right this now leads to you having to do :

if(Len(trim(message))){
writeLog(message);
}

<cfif Len(trim(message))>
<cflog text=“">

What are the solutions?

a) That it lets you log it and now you have an extra line in a log file that makes no sense. But who cares, that’s up to logstash or whatever you are using to parse your logs
b) Make Ignore blank lines, with a lovely attribute like… (not a real suggestion for the name)
c) Keep the existing behaviour
d) … ? Dunno

Thoughts?

Mark Drew

develop • deploy • deliver
http://charliemikedelta.com ttp://charliemikedelta.com> On 23 Feb 2015, at 15:02, Jamie Jackson <@Jamie_Jackson> wrote:

Hi Folks,

First, let me say I’m not heavily invested in this issue (I gave it a priority of minor), but the current behavior struck me as slightly wrong, so I wanted to get some feedback.

writeLog(""); Either of those will throw an error of: you must define attribute text or attribute exception with the tag cflog I would expect a blank log line, instead. Empty string should be valid, especially because the value can be dynamic, and if it is, it might be empty. Of course a blank log probably isn't too useful, but I'm not sure throwing a runtime error is the better behavior. The error thrown is slightly misleading, as well, since the argument is defined. Here's the ticket, with Micha's response: https://bitbucket.org/lucee/lucee/issue/175/error-with-empty-string-as-text-parameter Beyond this particular function, there might also be a matter of precedent involved. Thoughts? Thanks, Jamie


You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com mailto:lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com mailto:lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/e7d76dfa-dda1-4e8e-aee4-7a2d798419ed%40googlegroups.com https://groups.google.com/d/msgid/lucee/e7d76dfa-dda1-4e8e-aee4-7a2d798419ed%40googlegroups.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.

I would expect a blank log line, instead. Empty string should be valid,
especially because the value can be dynamic, and if it is, it might be
empty. Of course a blank log probably isn’t too useful, but I’m not sure
throwing a runtime error is the better behavior. The error thrown is
slightly misleading, as well, since the argument is defined.

Here’s the ticket, with Micha’s response:
https://bitbucket.org/lucee/lucee/issue/175/error-with-empty-string-as-text-parameter

I would expect two things:

  1. an empty log line to be created. The job of writeLog() is to log the
    string it’s given, not to decide whether it thinks it’s worth while logging
    it;
  2. Micha to not presuppose how you should or should not be writing your
    code. His job is to make the Lucee code work, not to decide whether your
    code is appropriate or not.On Tuesday, 24 February 2015 04:02:29 UTC+13, Jamie Jackson wrote:


Adam

SureAm Montag, 23. Februar 2015 schrieb Mark Drew :

Add it as a JIRA ticket?

Mark Drew

develop • deploy • deliver
http://charliemikedelta.com

On 23 Feb 2015, at 18:09, Michael Offner <@Michael_Offner <javascript:_e(%7B%7D,‘cvml’,’@Michael_Offner’);>> wrote:

There is no deeper meaning behind this, lucee is simply using
StringUtil.isEmpty(…) in that case that handles null the same way as a
empty string, i personally never had empty strings to log, even I do a lot
of dynamic logging. But in the end I think there is no downside in allowing
it …

Micha

Am Montag, 23. Februar 2015 schrieb Mark Drew :

Especially if you are doing some awesome log file art!

On 23 Feb 2015, at 16:13, Adrian Lynch <@Adrian_Lynch> wrote:

I agree. Don’t tell me I can’t log an empty string, it might be
meaningful to me.

Mark Drew


You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/67E16CC1-9249-462F-95C3-F3DCC41E22A2%40gmail.com
https://groups.google.com/d/msgid/lucee/67E16CC1-9249-462F-95C3-F3DCC41E22A2%40gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com
<javascript:_e(%7B%7D,‘cvml’,‘lucee%2Bunsubscribe@googlegroups.com’);>.
To post to this group, send email to lucee@googlegroups.com
<javascript:_e(%7B%7D,‘cvml’,‘lucee@googlegroups.com’);>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/CAG%2BEEBx4STQoyeP1%2BYxHHPNfNkbkc9njyXiryPJMcy%3DNEJ3tKA%40mail.gmail.com
https://groups.google.com/d/msgid/lucee/CAG%2BEEBx4STQoyeP1%2BYxHHPNfNkbkc9njyXiryPJMcy%3DNEJ3tKA%40mail.gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups
“Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an
email to lucee+unsubscribe@googlegroups.com
<javascript:_e(%7B%7D,‘cvml’,‘lucee%2Bunsubscribe@googlegroups.com’);>.
To post to this group, send email to lucee@googlegroups.com
<javascript:_e(%7B%7D,‘cvml’,‘lucee@googlegroups.com’);>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/lucee/C557B17F-801F-4D1A-B7A1-968A7C3D527A%40gmail.com
https://groups.google.com/d/msgid/lucee/C557B17F-801F-4D1A-B7A1-968A7C3D527A%40gmail.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

Especially if you are doing some awesome log file art!> On 23 Feb 2015, at 16:13, Adrian Lynch <@Adrian_Lynch> wrote:

I agree. Don’t tell me I can’t log an empty string, it might be meaningful to me.

Mark Drew

Add it as a JIRA ticket?

Mark Drew

develop • deploy • deliver
http://charliemikedelta.com ttp://charliemikedelta.com> On 23 Feb 2015, at 18:09, Michael Offner <@Michael_Offner> wrote:

There is no deeper meaning behind this, lucee is simply using StringUtil.isEmpty(…) in that case that handles null the same way as a empty string, i personally never had empty strings to log, even I do a lot of dynamic logging. But in the end I think there is no downside in allowing it …

Micha

Am Montag, 23. Februar 2015 schrieb Mark Drew :
Especially if you are doing some awesome log file art!

On 23 Feb 2015, at 16:13, Adrian Lynch <@Adrian_Lynch <javascript:_e(%7B%7D,‘cvml’,’@Adrian_Lynch’);>> wrote:

I agree. Don’t tell me I can’t log an empty string, it might be meaningful to me.

Mark Drew


You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com <javascript:_e(%7B%7D,‘cvml’,‘lucee%2Bunsubscribe@googlegroups.com’);>.
To post to this group, send email to lucee@googlegroups.com <javascript:_e(%7B%7D,‘cvml’,‘lucee@googlegroups.com’);>.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/67E16CC1-9249-462F-95C3-F3DCC41E22A2%40gmail.com https://groups.google.com/d/msgid/lucee/67E16CC1-9249-462F-95C3-F3DCC41E22A2%40gmail.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com mailto:lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com mailto:lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/CAG%2BEEBx4STQoyeP1%2BYxHHPNfNkbkc9njyXiryPJMcy%3DNEJ3tKA%40mail.gmail.com https://groups.google.com/d/msgid/lucee/CAG%2BEEBx4STQoyeP1%2BYxHHPNfNkbkc9njyXiryPJMcy%3DNEJ3tKA%40mail.gmail.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.

Sorry, was already created:
https://bitbucket.org/lucee/lucee/issue/175/error-with-empty-string-as-text-parameter https://bitbucket.org/lucee/lucee/issue/175/error-with-empty-string-as-text-parameter

(long day)

Mark Drew

develop • deploy • deliver
http://charliemikedelta.com ttp://charliemikedelta.com> On 23 Feb 2015, at 18:18, Michael Offner <@Michael_Offner> wrote:

Sure

Am Montag, 23. Februar 2015 schrieb Mark Drew :
Add it as a JIRA ticket?

Mark Drew

<cmd.png>
develop • deploy • deliver
http://charliemikedelta.com <>

On 23 Feb 2015, at 18:09, Michael Offner <@Michael_Offner <javascript:_e(%7B%7D,‘cvml’,’@Michael_Offner’);>> wrote:

There is no deeper meaning behind this, lucee is simply using StringUtil.isEmpty(…) in that case that handles null the same way as a empty string, i personally never had empty strings to log, even I do a lot of dynamic logging. But in the end I think there is no downside in allowing it …

Micha

Am Montag, 23. Februar 2015 schrieb Mark Drew :
Especially if you are doing some awesome log file art!

On 23 Feb 2015, at 16:13, Adrian Lynch <@Adrian_Lynch <>> wrote:

I agree. Don’t tell me I can’t log an empty string, it might be meaningful to me.

Mark Drew


You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com <>.
To post to this group, send email to lucee@googlegroups.com <>.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/67E16CC1-9249-462F-95C3-F3DCC41E22A2%40gmail.com https://groups.google.com/d/msgid/lucee/67E16CC1-9249-462F-95C3-F3DCC41E22A2%40gmail.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com <javascript:_e(%7B%7D,‘cvml’,‘lucee%2Bunsubscribe@googlegroups.com’);>.
To post to this group, send email to lucee@googlegroups.com <javascript:_e(%7B%7D,‘cvml’,‘lucee@googlegroups.com’);>.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/CAG%2BEEBx4STQoyeP1%2BYxHHPNfNkbkc9njyXiryPJMcy%3DNEJ3tKA%40mail.gmail.com https://groups.google.com/d/msgid/lucee/CAG%2BEEBx4STQoyeP1%2BYxHHPNfNkbkc9njyXiryPJMcy%3DNEJ3tKA%40mail.gmail.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com <javascript:_e(%7B%7D,‘cvml’,‘lucee%2Bunsubscribe@googlegroups.com’);>.
To post to this group, send email to lucee@googlegroups.com <javascript:_e(%7B%7D,‘cvml’,‘lucee@googlegroups.com’);>.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/C557B17F-801F-4D1A-B7A1-968A7C3D527A%40gmail.com https://groups.google.com/d/msgid/lucee/C557B17F-801F-4D1A-B7A1-968A7C3D527A%40gmail.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.


You received this message because you are subscribed to the Google Groups “Lucee” group.
To unsubscribe from this group and stop receiving emails from it, send an email to lucee+unsubscribe@googlegroups.com mailto:lucee+unsubscribe@googlegroups.com.
To post to this group, send email to lucee@googlegroups.com mailto:lucee@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/CAG%2BEEBz%3D2DzCmEYKFc944NxCQTyp%2BExZuL%3D54CkXs%2BJEmE70kg%40mail.gmail.com https://groups.google.com/d/msgid/lucee/CAG%2BEEBz%3D2DzCmEYKFc944NxCQTyp%2BExZuL%3D54CkXs%2BJEmE70kg%40mail.gmail.com?utm_medium=email&utm_source=footer.
For more options, visit https://groups.google.com/d/optout https://groups.google.com/d/optout.

I don’t think an empty string should throw an error, especially in a
logging function; it should be liberal in what it accepts.

Logging may very well be put in place to sleuth out tricky edge cases –
cases where the value of a variable being logged may unintentionally be an
empty string. I’ve had instances where informational logging is itself the
inadvertent cause of vexing errors as a result of this behavior.
Consequently, I use a wrapped logging function that gracefully handles
empty-string, null, or undefined variables, among other things.

  • Ken