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

83 views
Skip to first unread message

Jamie Jackson

unread,
Feb 23, 2015, 10:02:29 AM2/23/15
to lu...@googlegroups.com
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.

<cfscript>
writeLog("");
</cfscript>

<cflog text="">

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




Mark Drew

unread,
Feb 23, 2015, 10:11:12 AM2/23/15
to lu...@googlegroups.com
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 :
<cfscript>
if(Len(trim(message))){
writeLog(message);
}
</cfscript>

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

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 <cflog> Ignore blank lines, with a lovely attribute like… <cflog text=x ignoreifempty=true> (not a real suggestion for the name)
c) Keep the existing behaviour 
d) ... ? Dunno

Thoughts?


Mark Drew


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

--
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+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/e7d76dfa-dda1-4e8e-aee4-7a2d798419ed%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Kenneth Redler

unread,
Feb 23, 2015, 10:38:14 AM2/23/15
to lu...@googlegroups.com
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

Jamie Jackson

unread,
Feb 23, 2015, 10:54:01 AM2/23/15
to lu...@googlegroups.com
My preference would be solution a: It simply outputs a blank log line (which is my problem to figure out and/or minimize).

Adrian Lynch

unread,
Feb 23, 2015, 11:13:53 AM2/23/15
to lu...@googlegroups.com
I agree. Don't tell me I can't log an empty string, it might be meaningful to me.

Adrian

Mark Drew

unread,
Feb 23, 2015, 11:41:25 AM2/23/15
to lu...@googlegroups.com
Especially if you are doing some awesome log file art! 


On 23 Feb 2015, at 16:13, Adrian Lynch <adrian...@concreteplatform.com> wrote:

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


Mark Drew


Michael Offner

unread,
Feb 23, 2015, 1:09:50 PM2/23/15
to lu...@googlegroups.com
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
--
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+un...@googlegroups.com.
To post to this group, send email to lu...@googlegroups.com.

Mark Drew

unread,
Feb 23, 2015, 1:13:31 PM2/23/15
to lu...@googlegroups.com
Add it as a JIRA ticket?


Mark Drew


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

Michael Offner

unread,
Feb 23, 2015, 1:18:38 PM2/23/15
to lu...@googlegroups.com

Mark Drew

unread,
Feb 23, 2015, 1:33:43 PM2/23/15
to lu...@googlegroups.com

Mark Drew


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

On 23 Feb 2015, at 18:18, Michael Offner <mic...@lucee.org> wrote:

Sure

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


Mark Drew

<cmd.png>

Adam Cameron

unread,
Feb 23, 2015, 2:00:13 PM2/23/15
to lu...@googlegroups.com


On Tuesday, 24 February 2015 04:02:29 UTC+13, Jamie Jackson wrote:

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.

-- 
Adam
Reply all
Reply to author
Forward
0 new messages