Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 74613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:23:08+00:00 2026-05-10T20:23:08+00:00

I have an interesting problem and would appreciate your thoughts for the best solution.

  • 0

I have an interesting problem and would appreciate your thoughts for the best solution. I need to parse a set of logs. The logs are produced by a multi-threaded program and a single process cycle produces several lines of logs.

When parsing these logs I need to pull out specific pieces of information from each process – naturally this information is across the multiple lines (I want to compress these pieces of data into a single line). Due to the application being multi-threaded, the block of lines belonging to a process can be fragmented as other processes at written to the same log file at the same time.

Fortunately, each line gives a process ID so I’m able to distinguish what logs belong to what process.

Now, there are already several parsers which all extend the same class but were designed to read logs from a single threaded application (no fragmentation – from original system) and use a readLine() method in the super class. These parsers will keep reading lines until all regular expressions have been matched for a block of lines (i.e. lines written in a single process cycle).

So, what can I do with the super class so that it can manage the fragmented logs, and ensure change to the existing implemented parsers is minimal?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T20:23:09+00:00Added an answer on May 10, 2026 at 8:23 pm

    It sounds like there are some existing parser classes already in use that you wish to leverage. In this scenario, I would write a decorator for the parser which strips out lines not associated with the process you are monitoring.

    It sounds like your classes might look like this:

    abstract class Parser {     public abstract void parse( ... );     protected String readLine() { ... } }  class SpecialPurposeParser extends Parser {     public void parse( ... ) {          // ... special stuff         readLine();         // ... more stuff     } } 

    And I would write something like:

    class SingleProcessReadingDecorator extends Parser {     private Parser parser;     private String processId;     public SingleProcessReadingDecorator( Parser parser, String processId ) {         this.parser = parser;         this.processId = processId;     }      public void parse( ... ) { parser.parse( ... ); }      public String readLine() {         String text = super.readLine();         if( /*text is for processId */ ) {              return text;          }         else {             //keep readLine'ing until you find the next line and then return it             return this.readLine();         }     } 

    Then any occurrence you want to modify would be used like this:

    //old way Parser parser = new SpecialPurposeParser(); //changes to Parser parser = new SingleProcessReadingDecorator( new SpecialPurposeParser(), 'process1234' ); 

    This code snippet is simple and incomplete, but gives you the idea of how the decorator pattern could work here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 64k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer In your CSS, change #left ul li{ font-size:.7em; margin:5px 0;… May 11, 2026 at 11:00 am
  • added an answer Why not just do this: var = None Python is… May 11, 2026 at 11:00 am
  • added an answer UITextView does not have any methods which will be called… May 11, 2026 at 11:00 am

Related Questions

I have an interesting problem and would appreciate your thoughts for the best solution.
He're an interesting problem that looks for the most Pythonic solution. Suppose I have
So I came across an interesting problem today. We have a WCF web service
I have an interesting situation where I need to deploy an ASP.NET MVC app
I have an interesting query to do and am trying to find the best
This is a bit of a stretch, but I have an interesting (to me)
I have found an interesting issue in windows which allows me to cause the
Hey all, I have something of an interesting requirement for my project. I need
I met an interesting issue about C#. I have code like below. List<Func<int>> actions
I just came across an interesting situation in JavaScript. I have a class with

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.