Jump to content

How to parse a log file?

I have to create a program myself to parse and interpret the logs of a program, but I don't want the program to keep hammering my disk-io and keep writing to the drive. I know there are virtual files like stdout or something. Where do I actually output the log and interpret it?

Microsoft owns my soul.

 

Also, Dell is evil, but HP kinda nice.

Link to comment
Share on other sites

Link to post
Share on other sites

Out of curiosity, what's the sample rate that you're worried about "hammering diskIO"? 
What program? If you look at the documentation you can see if it's possible to redirect to stdout and then yeah, you can pipe that to stdin of your program, but you're either gonna have to write to disk eventually or you've built a memory leak

5950X/3080Ti primary rig  |  1920X/1070Ti Unraid for dockers  |  200TB TrueNAS w/ 1:1 backup

Link to comment
Share on other sites

Link to post
Share on other sites

You will need to set up some interprocess communication mechanism which involves modifying the source code of both the producer and consumers to handle this, one to produce the log, and one to consume it. Without access to the source code, you can only do piping and redirect using the stdin, stdout, and stderr on the terminal so instead of redirect to a file like say 

programA > file.tx 

(This is stdout from programA written to a text file)

 

You do

programA | programB

This is basically stdout of programA piped as the stdin of programB. 

 

If you want to understand the computer science behind this, unix terminal accomplishes this by calling the pipe and dup on the children processes files descriptors after forking them but before an execve

 

Edit: fix a minor technical error. 

Sudo make me a sandwich 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×