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 825475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:15:43+00:00 2026-05-15T03:15:43+00:00

What design pattern might apply to logging? What is normally used in this type

  • 0

What design pattern might apply to logging? What is normally used in this type of situation? Any good tutorials?

I am writing a client-server application using C89 and gcc 4.4.4. I now need to implement some logging feature that will display log messages on the screen as well as log to a file.

However, I don’t want to display all log messages (warning, error, critical, unrecoverable, debug, etc). Maybe I can set so that it will display just errors and nothing else. For example, the user might not be interested in the debug messages on the screen output.

  • 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. Editorial Team
    Editorial Team
    2026-05-15T03:15:44+00:00Added an answer on May 15, 2026 at 3:15 am

    Some hints/concepts:

    1. A mechanism to generate the log entry with either a parameter for log level or implied by the function name.
    2. Usually a printf-style format string followed by parameters.
    3. A data structure to collect the messages from one or more threads generating them.
    4. Some form of timestamping.
    5. A back end thread that processes the collected messages and performs the output generation. This can be where you configure what levels get displayed and/or written to a file.
    6. vsnprintf() is a function which takes a variable number of parameters and is often used in the back end processing section.

    Often the idea is to defer the string processing to the background thread so the actual work threads generating the log aren’t wasting time with string manipulation. However, it makes printing variable strings difficult since they tend to go out of scope by the time the background processes them. So in these cases numeric values are preferred. If real time is not as much an issue, you can copy strings through the log interface instead of just passing the pointers and numeric parameter values.

    Good luck.

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

Sidebar

Related Questions

The singleton pattern is a design pattern that is used to restrict instantiation of
Whats the best design pattern to use for LINQ and type tables that exist
Does anybody recommend a design pattern for taking a binary data file, parsing parts
What is the Action Design Pattern, I haven't heard of it before? I am
We're creating a Interaction design pattern website for a class. We've been using google
I have learnt the factory method design pattern, and at the same time, I
I have the following code for factory design pattern implementation. class Pen{ public: virtual
Is there such a thing as having the most prefered design pattern for building
What is an efficient way to implement a singleton design pattern in Java?
What is the difference between applying the visitor design pattern to your code and

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.