How to write code for a Logging Event?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to write code for a Logging Event?
# 8  
Old 12-05-2011
I'm approaching this as more of an Administrator so I apologise for that.

I have studied some C on and off but that is it. Are Logging Events and "Events as in OOP the same? Are those what are being sent to a log file? Interactions between OOP objects?
# 9  
Old 12-05-2011
An "event" isn't a thing the way, say, a variable is. It's a generic term. What it means in this context pretty much depends on who's asking it why. Is there a book you're following or something?
# 10  
Old 12-05-2011
Lets go back to your code of
Quote:
if(error)
. How would I know if an error occurred? How is an Error Determined?

Last edited by theKbStockpiler; 12-05-2011 at 08:54 PM..
# 11  
Old 12-05-2011
This is getting very philosophical. An error isn't a 'thing'. An error is when you tried to do something and couldn't. Is it trying to open a file? If it can't, that's an error. Is it trying to write data to a socket? If it can't, that's an error. It can also be when you find unexpected conditions, like a NULL pointer that ought to not be null. And so on.

What are you actually trying to do?
# 12  
Old 12-05-2011
Lets say I'm trying to write to a file and the operation of doing this fails. Wouldn't I have to write additional code to make sure every outcome of my code was successful ,make sure data was written to the said file? If an error is not checked the application will just go on running code. An error is only an error if it is defined as one, otherwise the CPU continues running the code with erroneous data.

An analogy would be checking a simple mathematical addition equation by subtracting one of the addends from the sum to see if the other addend was left. If this check is not made we are not aware of the error and computations using this faulty data continue.


This webpage gives my original post some structure http://wiki.webratio.com/index.php/Debugging_with_application's_logs

I got to this topic indirectly from ELF files so that won't help much. Let's say I'm writing an application and think it will be useful to have some log files to view so when it crashes I will have a clue of what to look at to solve the problems the application is experiencing.

Last edited by theKbStockpiler; 12-05-2011 at 09:58 PM..
# 13  
Old 12-05-2011
If you're not making sure every call is successful, how do you know any of them were? You should be checking everything anyway. If you're not in the habit of doing so, there's no time like the present.

You can also view some things from the outside with a system utility like strace.
# 14  
Old 12-05-2011
So is about one half of a applications code there just to make sure that the other one half actually worked? Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

5 More Discussions You Might Find Interesting

1. Linux

Syslog not logging successful logging while unlocking server's console

When unlocking a Linux server's console there's no event indicating successful logging Is there a way I can fix this ? I have the following in my rsyslog.conf auth.info /var/log/secure authpriv.info /var/log/secure (1 Reply)
Discussion started by: walterthered
1 Replies

2. Shell Programming and Scripting

Logging success event into file

Hi, I've the following code to log the errors any after the command is executed. # Ksh 88 Version log_path=/home/etc/fls/fls_log.log del_path=/home/etc/fls/to_day rm $del_path/* >> $log_path 2>&1 But I even want to log if the rm command is success without any error along with... (1 Reply)
Discussion started by: smile689
1 Replies

3. Shell Programming and Scripting

Event logging to file and display to console | tee command is not able to log all info.

My intention is to log the output to a file as well as it should be displayed on the console > I have used tee ( tee -a ${filename} ) command for this purpose. This is working as expected for first few outputs, after some event loggin nothing is gettting logged in to the file but It is displaying... (3 Replies)
Discussion started by: sanoop
3 Replies

4. IP Networking

read/write,write/write lock with smbclient fails

Hi, We have smb client running on two of the linux boxes and smb server on another linux system. During a backup operation which uses smb, read of a file was allowed while write to the same file was going on.Also simultaneous writes to the same file were allowed.Following are the settings in the... (1 Reply)
Discussion started by: swatidas11
1 Replies

5. UNIX for Dummies Questions & Answers

How does Unix write events into event log?

Hi to everyone. I'm new to this forum and also pretty new to Unix. I'm developing a cross-platform software and I need to register informational and error messages into the event log of the system. Under Windows, this is implemented so far, I need to implement it unded Unix by now. I do know that... (7 Replies)
Discussion started by: mariano_donati
7 Replies
Login or Register to Ask a Question