Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable console.log() messages #5278

Closed
vinothox opened this issue Oct 25, 2018 · 9 comments · Fixed by #5301
Closed

Disable console.log() messages #5278

vinothox opened this issue Oct 25, 2018 · 9 comments · Fixed by #5301

Comments

@vinothox
Copy link

I see many console log messages in the browser generated by Sonata admin bundle.

7kwb0

These messages are generated from /vendor/sonata-project/admin-bundle/src/Resources/public/Admin.js by the code,

/**
 * render log message
 * @param mixed
 */
log: function() {
    var msg = '[Sonata.Admin] ' + Array.prototype.join.call(arguments,', ');
    if (window.console && window.console.log) {
        window.console.log(msg);
    } else if (window.opera && window.opera.postError) {
        window.opera.postError(msg);
    }
},

I don't need these logs to be generated in the browser. Is there a way to control these from configuration file or something?

@OskarStark
Copy link
Member

Does these logs occur on prod?

@vinothox
Copy link
Author

Yes. Both dev and prod environment.

@bgaleotti
Copy link
Contributor

You can customize the layout and override that function:

{% extends 'SonataAdminBundle::standard_layout.html.twig' %}

{% block javascripts %}
  {{ parent() }}
  <script>
    if ('undefined' !== typeof window.Admin) {
      window.Admin.log = function() {}
    }
  </script>
{% endblock %}

@vinothox
Copy link
Author

@bgaleotti Thanks, it works.

@vinothox
Copy link
Author

But logging console messages even in production environment is the actual implementation or is it a bug?

@core23
Copy link
Member

core23 commented Oct 26, 2018

IMHO we should switch the actual behaviour. So that we have a logger function that does nothing, but you can override/enable it if you want

@vinothox
Copy link
Author

Yes, I have overrided the standard_layout to disable it. Thanks for the support. Can I close this issue now?

@OskarStark
Copy link
Member

No please keep it to open until we have a better solution

@vinothox
Copy link
Author

Sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants