Code Monkey home page Code Monkey logo

magicmirrorlogging's Introduction

Magic Mirror Logging

This is for logging the Magic Mirror on your Raspberry Pi

First you need to install the Magic Mirror

Magic Mirror

After that you need to install the "MMM-Logging" module on your Magic-Mirror.

MMM-Logging

As last you need to clone this repo in the Raspberry Pi home directory

cd ~
git clone https://github.com/lorenzfleerackers/MagicMirrorLogging.git

When you cloned the repo copy the logging.py file to the MagicMirror directory.

cp ~/MagicMirrorLogging/logging.py ~/MagicMirror

Use npm scripts to start the logging

cd ~/MagicMirror
nano package.json

Add the following lines

"start:log": "python logging.py",
"start:searchLog": "python /home/pi/MagicMirrorLogging/localLogging.py",

after :

"start": "sh run-start.sh",

Save the file end leave

Install express-logging to log the HTTP requests

If you want to log the http requests that you made or those from MMM-Remote-Control or MMM-ChangeConfig

  1. Go to the module you want to log (this can be your own module or the one from above)
  2. Install the package with
    • npm install express-logging
    • npm install logops
  3. Open the node_helper or the javascript file where you define your API's with express
  4. add the folowing code
        var express = require('express'),
            expressLogging = require('express-logging'),
            logger = require('logops');
        var app = express();
            app.use(expressLogging(logger));
      

What can you do with the logging?

You can start the Magic Mirror with only showing the info/logs/error or the HTTP requests.

npm run start:log

options explanation
Start mirror without options Start the mirror and show all the logs,errors and requests
Show info With this option the mirror will start and you will see console.info logs from all the modules without showing other errors or logs
Show logs With this option the mirror will start and you will seee console.log logs from all the modules without showing other errors or info
Show errors With this option the mirror will start and show only the errors without all the logs or info
Show requests With this option you will start the magic mirror without showing any logs or errors only the http requests from express-logging will be visible
Leave Quit the option list without starting the mirror
options explanation
Logging to file The logs will be saved to the log.log file and the errors will be saved to err.log
No logging No logs will be saved to a file

npm run start:searchLog

options explanation
Show info Show all the info from the logfile in the terminal
Show logs You can filter all the logs from the logfile on date/modulename
Show errors Show the error log file in the terminal
Show requests Show all the http requests from the logfile in the terminal
Quit Stop the loop

magicmirrorlogging's People

Contributors

lorenzfleerackers avatar

Watchers

James Cloos avatar

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.