Skip to content

lorenzfleerackers/MagicMirrorLogging

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages