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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:43:57+00:00 2026-05-20T06:43:57+00:00

In my PHP web application, I want to have the ability to perform the

  • 0

In my PHP web application, I want to have the ability to perform the following logging operations:

  1. Write a database record to an ‘error_log’ table.
  2. Write a database record to a ‘history_log’ table.
  3. Log all queries to the Firebug console via FirePHP.
  4. Log any arbitrary data to the Firebug console using FirePHP.

I am trying to decide on the better achitecture. I have two in mind. Which of these is the better one? I’m open to others as well.

Design #1

  • abstract class Logger
    • class FirebugConsoleLogger
      • getInstance()
      • log(string)
    • class DatabaseLogger
      • getInstance()
      • logError(logTypeId, affiliateId, detailsArray)
      • logHistory(logTypeId, affiliateId, detailsArray)

Design #2

  • class Logger
  • getInstance()
  • logToFirebugConsole(string)
  • logError(string)
  • logHistory(string)

EDIT Here’s what I’m probably going to go with.

  • class FirebugConsoleLogger
    • public getInstance()
    • public log(string)
  • abstract class Logger
    • abstract public log(typeId, affiliateId, details)
    • class ErrorLogger
      • public getInstance()
      • public log(typeId, affiliateId, details)
    • class HistoryLogger
      • public getInstance()
      • public log(typeId, affiliateId, details)
  • 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-20T06:43:58+00:00Added an answer on May 20, 2026 at 6:43 am

    I would use neither. I’d use a design that implements the same log method for each implementation. So it looks like Design #1, but a little different.

    • abstract class Logger
      • log(string)

    Create descendants for each type of log you have and override the log method.

    Then, create a factory for specific purposes, so:

    • class QueryLoggerFactory
      • getInstance() // Returns a/the FireBugConsoleLogger instance
    • class ErrorLoggerFactory
      • getInstance() // Returns a database logger instance
    • class HistoryLoggerFactory
      • getInstance() // Returns same or different database logger instance

    That way, when you need to log a query, you just call

    QueryLoggerFactory->getInstance()->log($query);
    

    And nowhere in your application you need to call a specific method. If you decide you want to store the query in the database too, you just instantiate a different logger in your factory. You can even instantiate a logger that logs itself to two other loggers, so you can store errors in FireBug and in the database. Or you can instantiate a void logger that doesn’t log anything.

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

Sidebar

Related Questions

I have a PHP web application which uses a MySQL database for object tagging,
I want to run a web application on php and mysql, using the CakePHP
I just want to send SMS from my web application in PHP. Can anyone
I am writing a web application using PHP. I want to use the MVC
I have a PHP web application on an intranet that can extract the IP
I'm making a php web application which stores user specific information that is not
I'm working profesionally on a php web application which contains contacts, among other data.
I am starting a new web application in PHP and this time around I
I am writing an web application powered by PHP, Smarty, JavaScript, CSS, MySQL. There
I'm starting to develop a web application in PHP that I hope will become

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.