News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Error logging levels

Started by Sarke, January 21, 2007, 05:14:13 AM

Previous topic - Next topic

Sarke

Quote from: Rudolf on January 24, 2007, 03:27:11 AM
The filters are there since 1.0, only that in DE they are improved and categorised.
That said, one can use filters in the 1.0 and 1.1 lines too. Sarke, until the next version of SMF you can use the small lenses, they let you to see similar errors.

That's the opposite of what I am suggesting (and Visualcode as well).  I don't need to see the same error several times, but it would be nice to be able to see each unique error once each.


Getting back to my original suggestion of leveled error reporting, I have another real world scenario.  I just installed TinyPortal with the Dilber MC theme, and wouldn't you know it, there are notice errors.  Yup, undefined variable and undefined index.  So, what I would like to do is stop those errors from being logged because my current options are:

1. Not to use TP and Dilber MC (not a good option)
2. Turn off error logging all together (I still want to be informed of other errors, so not good)
3. Ignore the errors and let them keep getting logged (winner by default I guess...)

Is giving people options so evil?

My MODs          Please don't PM me for support, post in the appropriate topic.

Dannii

There's a fourth option, fix the errors ;)
"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Sarke

Yeah, well most people don't sit down and fix other peoples code, and most people don't know how.  A fifth option would be to steal nuclear weapons and hold the world hostage until all coding errors are eliminated.  My point is that that's not a very realistic option for most people.

My MODs          Please don't PM me for support, post in the appropriate topic.

Visualcode

I still think categorizing the errors would be best. Not only for Sarke, but for those of us who do know what we are doing, as well. If we had categories, or some sort of nice sort, where we could easily get to what we want, it would really clean up the mess. I sort through tons of incorrect password things just to find what I want...

Assistance

Quote from: Visualcode on January 24, 2007, 08:22:29 AM

I still think categorizing the errors would be best. .............................., or some sort of nice sort, where we could easily get to what we want, it would really clean up the mess. I sort through tons of incorrect password things just to find what I want...

great idea, why dont they do that? or they do
why hasnt someone said that? oh they have.... twice in one page, oh wait three ....4? FIVE
Quote from: Rudolf on January 23, 2007, 11:31:30 AM
Quote from: Sarke on January 23, 2007, 03:41:49 AM

Thirdly, the error log filter I mention.  Make it easier to find unique errors in the code, so there's no need to wade through hundreds (in some cases) of pages with many of the same errors.

You can already filter logs in the error log. The fact that you don't see it, doesn't means that it's not there.


thats just 2 in 1 post and the bold quoted text is a classic

sorry if i come off rude or I just simply misread this page of this thread (clicks preview)
~playing poker~

Visualcode

Assistance, you most definitely come off rude, did you read Sarke's post?
Quote from: Sarke
That's the opposite of what I am suggesting (and Visualcode as well).  I don't need to see the same error several times, but it would be nice to be able to see each unique error once each....

Also, if after reading their posts, I am still suggesting that I am not satisfied, why would you quote them? That is great that it is there, despite the fact I can't see it. But come on now, if I can't find it, and Sarke can't find it, then it probably is pretty hard to find for others too. What good is a feature that is invisible? Do I need to press and hold control while I press C,D,E,4,9, and B for the feature to show?

Also, I agree with Sarke about the whole "personal opinion." I do NOT think initalizing variables is the most important thing in the world. Initializing before use, yes, initializing upon creation, not so much. Also, as long as we are speaking about "bad practice," I would suggest that everyone use (in normal practice):

++$i
NOT
$i++

Daniel15

QuoteAlso, I agree with Sarke about the whole "personal opinion." I do NOT think initalizing variables is the most important thing in the world. Initializing before use, yes, initializing upon creation, not so much.
As far as I can tell, Sarke was talking about initialising before use.

Quote
Also, as long as we are speaking about "bad practice," I would suggest that everyone use (in normal practice):

++$i
NOT
$i++

What's the difference between them?
Daniel15, former Customisation team member, resigned due to lack of time. I still love everyone here :D.
Go to smfshop.com for SMFshop support, do NOT email or PM me!

Rudolf

The difference is that the first increments the $i before it's value is used, the second after.
I don't see how using the first should be a best practice, because there are times when you need one and others when you need the other.
Both of them will throw an error if you don't have $i declared.
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

Visualcode

Rudolf, Daniel, the difference is how they work, in practice. If you increment a variable AFTER (post-increment) you return the previous value. This requires more work in the background. If you do the increment first, it doesn't need to worry about the previous value. It can simply increment, and work on the new value. Think of it as a function:

function PostIncrement()
{
    $SomeVar = Self
    ++Self;
    return $SomeVar;
}

As you can see, this includes a pre-increment in it, to do a post-increment. So, using this method is a waste, if you are not requiring the previous value of the variable.

Pre-increment on the other hand...

function PreIncrement()
{
   Self = Self+1;
   return Self;
}


While this may not seem like a big deal, in practice it is best to use the proper case. This is a very small performance and memory issue. But, when you get into C++ and classes, the increments can become very costly, due to the added functionality to the increment functions.

Rudolf

I am sorry, but your explanation makes no sense.
I mean you talk about efficiency and then you write a function like:

function PreIncrement()
{
   Self = Self+1;
   return Self;
}


Why you don't do simply:

function PreIncrement()
{
   return ++Self;
}


The pre-increment and post-increment is not a performance issue, but a functionality issue. There are times when you have to increment your value before doing something with it and times when you have to increment after.

Take this silly example (in a C-like language):
you have an array and grab the index of the last value in a variable
Code (Javascript) Select

var lastIndex = somearray.length-1;

then you do some work on the last value of the array using the lastIndex. After 200 lines of code where you work on the last value you decide to add another value to the array,and realise that you want to do some work on that one too.
In this (extreme) case the best and most elegant solution would be to do
Code (Javascript) Select

somearray[++lastIndex] = 'the new value';


You have the new value inserted and after it is inserted the lastIndex is incremented with one.
Normally you would write:
Code (Javascript) Select

lastIndex = lastIndex +1; /*or*/ lastIndex++; /*or*/  ++lastIndex; //they are all the same
somearray[lastIndex] = 'the new value';


Hope I was clear.
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

Sarke

Are we still talking about error logging levels?

My MODs          Please don't PM me for support, post in the appropriate topic.

Rudolf

Quote from: Sarke on January 25, 2007, 10:03:01 AM
Are we still talking about error logging levels?

Yes. And about 'good' and 'bad' practices.
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

Visualcode

Rudolf, I applaud your useless need to argue. Why would you post such a stupid response to what I have said? Did you even read what I wrote? I don't mean to continue an argument here, but I can't help but respond to your post in such a way. You are now just complaining about non-sense, my argument was about bad-code, and was a real, useful suggestion (Not meant to insult ANYBODY, but meant to educate). Let's take a look at why what you said, was just plain rude (maybe that is common here, look at Assistant's post . . . .)

First, if anyone's code makes no sense here, it is YOURS. Why would I have a function (Pre-increment) which calls the function, pre-increment? Can we say, "killer recursion?" Your code:

function PreIncrement()
{
   return ++Self;
}

Would be calling itself, because this is the definition for the usage of "++" as a pre-increment. So, you would have an ever-lasting loop . . . . My code was accurate. For the pre-increment to work, it must first increment, then return that incremented value. My code was meant to show the inner-workings of post and pre-increments. It was not meant to say that you shouldn't use "++," but instead my code. In fact, using my code would be inefficient. The fact that it would need to call the function in itself, and pass data, whether a pointer or a value, both ways, is a waste when you can use increments.

Second, my post made it clear that I was not saying never to use post-increments (At least, I thought it did). Here, let's take a look:

Quote
As you can see, this includes a pre-increment in it, to do a post-increment. So, using this method is a waste, if you are not requiring the previous value of the variable.

My post was just meant to say, that when you are simply incrementing, and not requiring the value prior to the increment, you should use a pre-increment and not a post-increment. The code I offered was trying to help you to see why you should do it this way. The reason because internally, a post-increment requires more work than a pre-increment.

In the future, before insulting someone trying to help the community, perhaps you should into your comments and their accuracy.

Visualcode

Sarke, I apologize for helping to lead this off-topic. I too would like some sort of solution to the error-logging troubles. But, it is very hard for me not to respond to someone insulting my code, when it is not wrong, and was only meant to help. Well, I did miss a semi-colon in there, but that's not too bad when I am not really in a "coding mode," and it did get the proper idea across. As for the whole start of my post, I was not meaning to start an argument, just wanted to inform people about post vs. pre-increments, it is sort of a pet peeve of mine.

Rudolf

Quote from: Visualcode on January 25, 2007, 06:46:17 PM
My code was meant to show the inner-workings of post and pre-increments.
It is not what your previous post says, because your previous post doesn't says this.
Whatever.
I will update all my mods in the next few weeks. Thanks for your patience.

SVG-Collapse (you need an SVG compliant browser)

Sarke

Well, this one's derailed. 

A suggestion for an option to control the level of errors that are getting logged (and other various error log improvement suggestions), turned into a philosophical discusssion about coding practises, turned into a "my way of coding is better" and "I know more about coding than you".  Any takers for "my dad codes better than your dad"?

Sad...  ::)

My MODs          Please don't PM me for support, post in the appropriate topic.

Sarke

My point was there's lots of pointless hostility in this thread, and nothing that's dealing with the topic at hand.  I started this thread because I wanted to make SMF better but for some reason all you do is criticise.

My MODs          Please don't PM me for support, post in the appropriate topic.

Visualcode

#37
Quote from: Rudolf on January 26, 2007, 03:39:23 AM
Quote from: Visualcode on January 25, 2007, 06:46:17 PM
My code was meant to show the inner-workings of post and pre-increments.
It is not what your previous post says, because your previous post doesn't says this.
Whatever.

Quote from: My previous post
It can simply increment, and work on the new value. Think of it as a function:

I think I made myself fairly clear as to what I was showing, Rudolf. I was asked the difference between using post and pre-increment. I think it is fairly important that people are taught the difference. Here is why:

Quote
/*or*/ lastIndex++; /*or*/  ++lastIndex; //they are all the same

The fact is they are not all the same. Adding the '++' after is actually more work, internally. Which is why I brought up the idea in the first place. It really is better practice to use pre-increment whenever possible. Post-increment should only be used when requiring the value it returns.

Which, should help you to understand why I can't help but see you as being rude. You respond, incorrectly, saying I am wrong, when I am only trying to help. Also, based on your previous post, it is obvious that this is something that you didn't know. So, I am not only helping others, but you as well. For that, wouldn't a thank you be more appropriate than an argument? Like Sarke has said, all the rudeness here has done nothing but derail this conversation. If we want to be rude, perhaps we should take it elsewhere.

Back on topic...

The problem with the error-log filter, is it is the reverse of what we want. It shows all of one error, when we want one of every. For example, a good error log could do something like this:

Error Log:

Error:     Quantity:
Password incorrect     10
Database Error     2
Your email address needs to be validated before you can login     5

Something like this would allow us to see how many of something, and not be flooded by them. This would allow us to find errors easier. Then, each error could be clicked to either expand or go to a new page, which shows the errors inside. That way, when I have 1000 users, 600 of which entered a wrong password today, I am not flooded by these when looking for that one DB error which MAY or may not exist.

Edit: Added a table, the pre-formatting apparently didn't work.

JayBachatero

Well hopefully this screenshot should end all the arguments here.  In DE the errors are separated in categories.
Follow me on Twitter

"HELP!!! I've fallen and I can't get up"
This moment has been brought to you by LifeAlert

Sarke

Looks good! Thanks SMF team!

Was it like that before this topic was started? :P


The other stuff would be nice as well, like an error flood limit, and the code Daniel15 posted (show that there are errors in the log).  To the latter I would add a "this script had # of errors" as well.  If they're not going to be included, let me know and I'll probably write a mod for them.

My MODs          Please don't PM me for support, post in the appropriate topic.

Advertisement: