Coder Social home page Coder Social logo

mmm-logging's Introduction

MMM-Logging

This is a module for the MagicMirror².

This module extends the Node.js console logging capabilities of the MagicMirror² project through implementation of the tracer Node.js module, including adding timestamps and stack traces.

By default, this module will intercept and format ALL console log messages from the MagicMirror instance once it is loaded.

Examples:

Before MMM-Logging:

0|mm  | Starting MagicMirror: v2.6.0-dev
0|mm  | Loading config ...
0|mm  | Loading module helpers ...
0|mm  | Initializing new module helper ...
0|mm  | Module helper loaded: MMM-Logging
0|mm  | No helper found for module: alert.

After MMM-Logging:

Example 1

Note: You can find more detailed information on debugging your MagicMirror here: Module Debugging. If you also want the Electron rederer (web browser) console logs to be printed to the standard console (or PM2 logs), change the following line to the very top of ~/MagicMirror/run-start.sh

export ELECTRON_ENABLE_LOGGING=true

Installing the module

To install the module, assuming you have MagicMirror installed with the default configuration:

cd ~/MagicMirror/modules
git clone https://github.com/shbatm/MMM-Logging.git
cd MMM-Logging/
npm install

Updating the module

cd ~/MagicMirror/modules/MMM-Logging
git pull
npm install

Using the module

To use this module, add the following configuration block to the TOP of the modules array in the config/config.js file:

var config = {
    modules: [
        {
            module: 'MMM-Logging',
            config: {
                // Module functions out of the box with nothing set here.
                // See below for configurable options.
            }
        }
    ]
}

Configuration options

Refer to documentation for tracer for most configuration options. They can be applied directly in the config section.

Module specific options:

Option Description
useColor Optional Whether or not to use tracer's colorConsole method or regular console method.
Type: bool Default true.
overwriteConsoleMethods Optional Whether or not to overwrite the default Node.JS console methods. If true any console.log, console.error, etc. function calls in any module will be formatted. If false, only calls to tracer.log, etc. will be formatted. In most cases for MagicMirror, if you're using this module, you want true
Type: bool Default true.
overwriteBrowserMethods Optional Whether or not to overwrite the default web browser console methods. If true any console.log, console.error, etc. function calls in the DevTools console in any module will be formatted. If false, only calls to tracer.log, etc. will be formatted.
Type: bool Default false--usually the DevTools console is good enough for tracing errors.
echoModuleNotifications Optional If set any module notifications sent on the front-end will be printed on the Node.JS console log. Can be set to 'notification' to just send the notifications, or 'payload' to include the payloads as well.
Type: string Default 'notification'.
echoErrors Optional If true, any errors in the web browser (front-end) will be printed on the Node.JS console log.
Type: bool Default true.
ignoreModules Optional Option to ignore notifications sent from certain modules. Defaults to ignoring clock, calendar and newsfeed since these send a lot of nusance notifications.

Default configuration:

{
    format: "{{timestamp}} <{{title}}> {{message}} ({{folder}}/{{file}}:{{line}} {{method}})",
    dateformat: "yyyy-mm-dd'T'HH:MM:ss",
    stackIndex: 2,
}

mmm-logging's People

Contributors

shbatm avatar dathbe avatar

Stargazers

Kristjan ESPERANTO avatar Robin Blaauw avatar  avatar Dirk avatar Johan avatar

Watchers

James Cloos avatar  avatar Johan avatar  avatar Kristjan ESPERANTO avatar

mmm-logging's Issues

[FEATURE REQUEST] Display Logs on MM Screen

Describe the solution you'd like
A clear and concise description of what you want to happen.

I was wondering if is possible to get the output displayed on the MM screen?

Browser Error, why?

I receive this notification error. Do you know why?

2019-03-16T06:30:00 <log> Browser Error: {
   "isTrusted": true
} (/home/pi/MagicMirror/modules/MMM-Logging/node_helper.js:37 Class.socketNotificationReceived)

payload: undefined

1|MagicMir | 2019-03-10T19:05:12 payload: undefined (/home/pi/MagicMirror/modules/MMM-Logging/node_helper.js:34 Class.socketNotificationReceived)

Do you know why appears this message?

[Bug] Constant "Browser Error" that only reports "isTrusted": true

Describe the bug

To Reproduce
Steps to reproduce the behavior:

  1. Add some modules (it seems to appear with MMM-GoogleMaps-Tracking among others)
  2. Watch logs
  3. Browser Error appears

Expected behavior
Either this is not really an error that needs to be reported, or more information should be displayed.

Configuration
Please include:
Unknown

Logs

0|mm  | [2024-05-16 13:32:12.447] [LOG]   2024-05-16T13:32:12 <log> Browser Error: {
0|mm  |    "isTrusted": true
0|mm  | } (/home/username/MagicMirror/modules/MMM-Logging/node_helper.js:37 Class.socketNotificationReceived) 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.