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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:45:57+00:00 2026-06-15T05:45:57+00:00

The Mozilla Developer Network page on the browser-provided Javascript console object says: Note: At

  • 0

The Mozilla Developer Network page on the browser-provided Javascript console object says: “Note: At least in Firefox, if a page defines a console object, that object overrides the one built into Firefox.“. Is there any way to overwrite this object, but still interact with the browser’s Web Console?

A use case is to intercept console.log() calls and do something extra or take different parameters, such as a log classification, while retaining the line number/file information provided when logging to console by tools like Firebug or Google Chrome Inspect Element. The closest matching answer I could find is: Intercepting web browser console messages, but it doesn’t dive into interacting with the web console through a custom console object, and using a custom defined debug service like

debug.log = function(string, logLevel) {
    checkLogLevel(logLevel); // return false if environment log setting is below logLevel 
    var changedString = manipulate(string); 
    console.log(changedString); 
}

doesn’t retain the line number/file source of the function calling debug.log(). An option is to do something with console.trace() and crawl one level up the trace stack, but I was curious about extending console.log() first. I’d also like to find a solution that works with existing Web Consoles/tools like Firebug rather than creating a custom browser extension or Firebug plugin, but if anybody knows of existing solutions for this I’d be interested in them.

Obviously something like:

    console = {
        log: function (string) {
            console.log('hey!');
        }
    }
    console.log('hey!');

won’t work and results in infinite recursion.

  • 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-06-15T05:46:02+00:00Added an answer on June 15, 2026 at 5:46 am

    It’s easy, just save a reference to the (original) console before overwriting it:

    var originalConsole = window.console;
    console = {
        log: function(message) {
            originalConsole.log(message);
            // do whatever custom thing you want
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was reading Introduction to Object-Oriented JavaScript from Mozilla Developer Network, time to learn
https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/defineProperty states: configurable : True if and only if the type of this property
I was looking in the javascript reference manual on the indexOf page at developer.mozilla.org
Hello people of Stackoverflow! I have been going through the Mozilla Developer Network's JavaScript
stated here https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function the constructor property of an instance of a function object specifies
According to this page https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Reserved_Words You can't use these reserved words as variables, but
from the page https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/Details_of_the_Object_Model : When JavaScript sees the new operator, it creates a
I was reading the MDN page for the JS Function's arguments variable: https://developer.mozilla.org/en/JavaScript/Reference/Functions_and_function_scope/arguments I
I've been looking over the JavaScript reference on the Mozilla Developer Network , and
On this page: https://developer.mozilla.org/en/DOM/element.addEventListener It is warned that the value of this will be

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.