Skip to main content

Logger from python to HTML

Project description

web_logger

Get your log through the web. Why having a web logger rather than a native interface?

  • Remote access (although it works perfectly locally)
  • UI customization (if you are confortable with CSS)

This application was built to run smoothly on a Raspberry Pi, however it has been designed on a platform agnostic way.

Getting started

You need Python 3.5+ to run this package.

Browser support

A banner pops in on browsers which don't support the needed feature. Also, it has been developed for those browsers:

  • Chrome 62+

On Windows the HTTP server is quite instable, you may need to reload the page (press F5) if the logger get stuck before getting ready.

Please specify your browser path to the API.

from web_logger import Logger, LoggerException

def demo(logger):
    logger.log("Logger ready")

Logger("/path/to/browser", onReady=demo)

Note: Currently the python script needs to run on the www directory containing the interface files. However it is enough for the purpose of my projects so I don't plan to fix this. If this behavior upsets you, you are very welcome to submit a fix.

To customize the interface, you can copy all the files in another directory specific to your project, you can do versioning on this folder and use this folder as the working directory.

API

Please see the demo.py file to see an example.

logger = Logger(
        browser_path, # if None or none provided, Logger will start in remote mode
        http_port=3000, # TCP port to use for the HTTP server
        ws_port=3001, # TCP port to use for the WebSocket server
        onReady=lambda _: None, # callback for when logger is ready
    )
# the Logger constructor will block the thread until logger.stop is called
# or the browser is closed if run in local mode

# All methods should be called after the onReady callback has been called
try:
    logger.defineNewMenu(menu) # defines the menu items and action to be displayed on top of the logger
    logger.printMessage(message) # logs a message on the HTML interface
    logger.printMessage(message, audioFile="/audio.mp3") # logs a message on the HTML interface and play the audio
except LoggerException:
    print("Logger was not ready or has already terminated")
    pass
Audio files

You have the ability to play audio sound on the interface by specifying a audioFile argument. Check what are the supported audio formats for the browser you want to use.

N.B.: The path to audio file will be sent to the browser and therefore need to be relative to the root of the HTTP server. The root of the HTTP server can be set by changing the current directory. Because of HTTP specification, you cannot access the parent directory of the HTTP root folder.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

web_logger-0.3.1.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

web_logger-0.3.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file web_logger-0.3.1.tar.gz.

File metadata

  • Download URL: web_logger-0.3.1.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for web_logger-0.3.1.tar.gz
Algorithm Hash digest
SHA256 fedc238669938f2f2b0c2a2a412de0c68f2520ad93110fd12da624c673aa8ecb
MD5 421ff34b417ff33cccdd76838c660e21
BLAKE2b-256 e2b27df51185353cb0ddc40b81339945060071162099e728698d4b1f6cfed3d6

See more details on using hashes here.

File details

Details for the file web_logger-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: web_logger-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for web_logger-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 645207bc7287ae6cb810035450ad0a8e275ce220f72763d13153e724ba416b1c
MD5 8c67d7d19a25065ff9684b7ec912dfe1
BLAKE2b-256 9cc92f535f016a1bcc66e787b78fb81dfd78ead9508516d2a2a4cc456585edb9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page