# \[Bro-Commits\] \[git/bro\] topic/robin/reporting: Overhauling the internal reporting of messages to the user. (93894ee)

**URL:** <https://community.zeek.org/t/bro-commits-git-bro-topic-robin-reporting-overhauling-the-internal-reporting-of-messages-to-the-user-93894ee/1911>\
**Category:** Development\
**Tags:** development\
**Created:** [June 27, 2011, 3:48am UTC](https://community.zeek.org/t/bro-commits-git-bro-topic-robin-reporting-overhauling-the-internal-reporting-of-messages-to-the-user-93894ee/1911 "2011-06-27T03:48:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gregor\_Maier](https://avatars.discourse-cdn.com/v4/letter/g/94ad74/32.png) [@Gregor\_Maier](https://community.zeek.org/u/Gregor_Maier)\
**Post date:** [June 27, 2011, 3:48am UTC](https://community.zeek.org/t/bro-commits-git-bro-topic-robin-reporting-overhauling-the-internal-reporting-of-messages-to-the-user-93894ee/1911/1 "2011-06-27T03:48:33Z")

</div>

How are errors in the script layer handled? If there's an error in a script you can't really call an event handler for to handle that error, since it might well be that the error is either in the event handler or that the error will prevent the event handler from working properly.

cu  
gregor

---

<div class="post-metadata">

**Author:** ![robin](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/robin/32/599_2.png) [@robin](https://community.zeek.org/u/robin)\
**Post date:** [June 27, 2011, 4:00am UTC](https://community.zeek.org/t/bro-commits-git-bro-topic-robin-reporting-overhauling-the-internal-reporting-of-messages-to-the-user-93894ee/1911/2 "2011-06-27T04:00:29Z")

</div>

It's not really \*handled\*, it just raises a new log\_error event that  
reports the error with a message. That event is then just queued  
normally, which shouldn't cause any further trouble.

(Well, I guess the handler for log\_error better doesn't cause any new  
errors; but even if, it will just flood the log file, Bro will keep  
processing.)

Robin

---

<div class="post-metadata">

**Author:** ![Gregor\_Maier](https://avatars.discourse-cdn.com/v4/letter/g/94ad74/32.png) [@Gregor\_Maier](https://community.zeek.org/u/Gregor_Maier)\
**Post date:** [June 27, 2011, 2:26pm UTC](https://community.zeek.org/t/bro-commits-git-bro-topic-robin-reporting-overhauling-the-internal-reporting-of-messages-to-the-user-93894ee/1911/3 "2011-06-27T14:26:01Z")

</div>

I really like the idea of having event handlers to handle error messages! A couple more comments:

Can the log\_\* handlers also write to stderr instead of stdout? I think that would be better.

It appears that there are several places, esp. in Expr.cc and Stmt.cc that still use the old Error(), Internal(), etc. functions (including the SetError). Is this on purpose?

> > How are errors in the script layer handled? If there's an error in a  
> > script you can't really call an event handler for to handle that  
> > error,
> 
> It's not really \*handled\*, it just raises a new log\_error event that  
> reports the error with a message. That event is then just queued  
> normally, which shouldn't cause any further trouble.

I was more wondering what would happen if due to an error the handler for log\_error cannot run properly. I.e., whether there can be a case were we don't see any error messages.

> (Well, I guess the handler for log\_error better doesn't cause any new  
> errors; but even if, it will just flood the log file, Bro will keep  
> processing.)

Well, log\_error will go in an endless loop and continue to queue events. So bro won't process any more packets because the event queue never gets empty, right?

cu  
Gregor

---

<div class="post-metadata">

**Author:** ![robin](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/robin/32/599_2.png) [@robin](https://community.zeek.org/u/robin)\
**Post date:** [June 27, 2011, 3:32pm UTC](https://community.zeek.org/t/bro-commits-git-bro-topic-robin-reporting-overhauling-the-internal-reporting-of-messages-to-the-user-93894ee/1911/4 "2011-06-27T15:32:40Z")

</div>

> Can the log\_\* handlers also write to stderr instead of stdout?

The current implementation is just a placeholder. The output should  
probably go into its own log file but I let Seth figure that out. 🙂

> It appears that there are several places, esp. in Expr.cc and Stmt.cc  
> that still use the old Error(), Internal(), etc. functions (including  
> the SetError). Is this on purpose?

Yes, these are BroObj's Error() etc. methods; I just removed the  
methods in the util.h. Generally, I left object-specific error methods  
in because (1) they sometimes do additional things, and (2) it would  
have required touching lots of places without making things much  
better.

But: these methods used to call error() for doing their output and  
\*that\* has been replaced with Logger::Error().

Let me know if you still find a method logging errors directly to  
stderr/out (except for debugging stuff, I didn't touch that, like in  
Rule\*.cc).

> I was more wondering what would happen if due to an error the handler  
> for log\_error cannot run properly. I.e., whether there can be a case  
> were we don't see any error messages.

Can't think of anything.

> Well, log\_error will go in an endless loop and continue to queue events.

Hmm, that's right. I forgot that we aren't limiting how many events we  
process each time we drain the manager (we do limit timers per  
packet). Seems that should be caught and errors reported in a  
log\_error hanlder be written out to stderr.

Another question: what do you guys think about merging Logger and  
LogMgr now? I.e., let LogMgr do both error reporting and normal log  
output.

Robin

---

<div class="post-metadata">

**Author:** ![Jonathan\_Siwek](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@Jonathan\_Siwek](https://community.zeek.org/u/Jonathan_Siwek)\
**Post date:** [June 27, 2011, 4:12pm UTC](https://community.zeek.org/t/bro-commits-git-bro-topic-robin-reporting-overhauling-the-internal-reporting-of-messages-to-the-user-93894ee/1911/5 "2011-06-27T16:12:59Z")

</div>

> Another question: what do you guys think about merging Logger and  
> LogMgr now? I.e., let LogMgr do both error reporting and normal log  
> output.

Are you talking about just merging the Logger's currently implemented interface as-is under the LogMgr class, or was there some additional integration of the two you were thinking about? If the former, it seems like maybe just finding a better name for the Logger class would do (MsgReporter, maybe?).

- Jon

---

<div class="post-metadata">

**Author:** ![robin](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/robin/32/599_2.png) [@robin](https://community.zeek.org/u/robin)\
**Post date:** [June 27, 2011, 4:15pm UTC](https://community.zeek.org/t/bro-commits-git-bro-topic-robin-reporting-overhauling-the-internal-reporting-of-messages-to-the-user-93894ee/1911/6 "2011-06-27T16:15:06Z")

</div>

> Are you talking about just merging the Logger's currently implemented  
> interface as-is under the LogMgr class,

Just as-is. I'm kind of torn whether the two belong together or not.

> (MsgReporter, maybe?).

Yeah, I can see that.

Robin

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/zeek/original/1X/f09d732bc2cc7c7cc7e35db67cf4e1d5233ce7a7.png) [@system](https://community.zeek.org/u/system)\
**Post date:** [May 6, 2022, 3:39pm UTC](https://community.zeek.org/t/bro-commits-git-bro-topic-robin-reporting-overhauling-the-internal-reporting-of-messages-to-the-user-93894ee/1911/7 "2022-05-06T15:39:38Z")

</div>

Closed on May 6, 2022, 3:39pm UTC


