All Projects → ccampbell → Chromelogger Python

ccampbell / Chromelogger Python

Python library for logging variables to Google Chrome console

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Chromelogger Python

Home
Project Glimpse: Node Edition - Spend less time debugging and more time developing.
Stars: ✭ 260 (+12.07%)
Mutual labels:  console, middleware, logging
Logger
HTTP middleware for Go that logs web requests to an io.Writer.
Stars: ✭ 24 (-89.66%)
Mutual labels:  middleware, logging
Logging Helpers
Basic template helpers for printing messages out to the console. Useful for debugging context in templates. Should work with any template engine.
Stars: ✭ 5 (-97.84%)
Mutual labels:  console, logging
Node Draftlog
📜 Create updatable log lines into the terminal, and give life to your logs!
Stars: ✭ 1,117 (+381.47%)
Mutual labels:  console, logging
Concurrency Logger
Log HTTP requests/responses separately, visualize their concurrency and report logs/errors in context of a request.
Stars: ✭ 400 (+72.41%)
Mutual labels:  middleware, logging
Gear
A lightweight, composable and high performance web service framework for Go.
Stars: ✭ 544 (+134.48%)
Mutual labels:  middleware, logging
Gin Glog
Gin middleware to use glog
Stars: ✭ 53 (-77.16%)
Mutual labels:  middleware, logging
Console Logging
Better, prettier commandline logging for Python--with colors! 👻
Stars: ✭ 111 (-52.16%)
Mutual labels:  console, logging
Chromephp
class for logging PHP variables to Google Chrome console
Stars: ✭ 1,339 (+477.16%)
Mutual labels:  console, logging
Yurnalist
An elegant console reporter, borrowed from Yarn
Stars: ✭ 88 (-62.07%)
Mutual labels:  console, logging
Laravel Logger
An out the box activity logger for your Laravel or Lumen application. Laravel logger is an activity event logger for your laravel application. It comes out the box with ready to use with dashboard to view your activity. Laravel logger can be added as a middleware or called through a trait. This package is easily configurable and customizable. Supports Laravel 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 6, and 7+
Stars: ✭ 366 (+57.76%)
Mutual labels:  middleware, logging
Clog
Package clog is a channel-based logging package for Go
Stars: ✭ 151 (-34.91%)
Mutual labels:  console, logging
Go Grpc Middleware
Golang gRPC Middlewares: interceptor chaining, auth, logging, retries and more.
Stars: ✭ 4,170 (+1697.41%)
Mutual labels:  middleware, logging
Electron Log
Just a simple logging module for your Electron application
Stars: ✭ 765 (+229.74%)
Mutual labels:  console, logging
Console
OS X console application.
Stars: ✭ 298 (+28.45%)
Mutual labels:  console, logging
Loglevelnext
A modern logging library for Node.js that provides log level mapping to the console
Stars: ✭ 33 (-85.78%)
Mutual labels:  console, logging
Diary
📑 Zero-dependency, fast logging library for both Node and Browser.
Stars: ✭ 79 (-65.95%)
Mutual labels:  middleware, logging
Quicklogger
Library for logging on files, console, memory, email, rest, eventlog, syslog, slack, telegram, redis, logstash, elasticsearch, influxdb, graylog, Sentry, Twilio, ide debug messages and throw events for Delphi/Firemonkey/freepascal/.NET (Windows/Linux/OSX/IOS/Android).
Stars: ✭ 137 (-40.95%)
Mutual labels:  console, logging
Logging
Powershell Logging Module
Stars: ✭ 167 (-28.02%)
Mutual labels:  console, logging
Mulog
μ/log is a micro-logging library that logs events and data, not words!
Stars: ✭ 222 (-4.31%)
Mutual labels:  logging

Overview

Chromelogger is a Python library for logging variables to the Google Chrome console using the Chrome Logger extension.

For more information about Chrome Logger check out http://chromelogger.com.

This module is designed to be used during development and not in production. It is not thread safe, and you do not want to risk leaking sensitive data to users!

Getting Started

  1. Install Chrome Logger from the Chrome Web Store

  2. Click the extension icon to enable on the current tab's domain

    toggling

  3. Install the Python library

    pip install chromelogger
    
  4. Start logging

    import chromelogger as console
    console.log('Hello console!')
    console.get_header()
    

Sending Headers

Since every framework deals with setting headers slightly differently the library stores the header information and it is up to you to send it at the end of your request.

Using with Django

The library includes a middleware for using with Django. All you have to do is in your settings.py file make sure to update your list of middleware and add

MIDDLEWARE_CLASSES = (
    'chromelogger.DjangoMiddleware'
)

After that you can import the chromelogger class from any file in your application and add logs.

Using with Tornado

Using with tornado is slightly more complicated. You have to make sure you are using your own custom request handler and that all your requests you want logged inherit from that. Here is an example of how you could implement it

import tornado
import chromelogger

class CustomRequestHandler(tornado.web.RequestHandler):
    def finish(self, chunk=None):
        header = chromelogger.get_header()

        if header is not None:

            # in Tornado RequestHandler.set_header() function limits
            # header length to 1000 bytes, so set directly for this case
            self._headers[header[0]] = header[1]

        return super(CustomRequestHandler, self).finish(chunk=chunk)

Using with Flask

For using chromelogger with Flask, you can use a custom response-handler like this:

# put this somewhere in your application setup

if app.debug:
    import chromelogger as console
 
    @app.after_request
    def chromelogger(response):
        header = console.get_header()
        if header is not None:
            response.headers.add(*header)
        return response

This ensures that chromelogger is only active, if the apllication runs in debug-mode.

API Documentation

The chromelogger module exposes some of the chrome logger methods. The others will be coming in a future release.

chromelogger.log(*args)

chromelogger.warn(*args)

chromelogger.error(*args)

chromelogger.info(*args)

chromelogger.group(*args)

chromelogger.group_end(*args)

chromelogger.group_collapsed(*args)

chromelogger.table(*args)

Logs data to the console. You can pass any number of arguments just as you would in the browser.

chromelogger.log('width', width, 'height', height)

chromelogger.version

Outputs a string of the current version of this module

chromelogger.get_header(flush=True)

Returns a tuple with the header name and value to set in order to transmit your logs.

If flush argument is True all the data stored during this request will be flushed.

This is the preferred way to use this module. At the end of each request you should call this method and add this header to the response.

import chromelogger
chromelogger.log(123)
chromelogger.get_header()
# ('X-ChromeLogger-Data', 'eyJyb3dzIjogW1tbMTIzXSwgIjxzdGRpbj4gOiAxIiwgWyJsb2ciXV1dLCAidmVyc2lvbiI6ICIwLjIuMiIsICJjb2x1bW5zIjogWyJsb2ciLCAiYmFja3RyYWNlIiwgInR5cGUiXX0=')

chromelogger.get_header() will return None if there is no data to log.

chromelogger.set_header = None

As an alternative to get_header you can specify a function that can be used to set a header. The function should accept two parameters (header name and value). Usage would look something like:

def set_header(name, value):
    # do stuff here to set header
    pass

chromelogger.set_header = set_header

When chromelogger.set_header is not equal to None it will be called each time data is logged to set the header. The class is a singleton so it will just keep overwriting the same header with more data as more data is added.

If you are going to use this you have to make sure to call chromelogger.reset() at the beginning of each request or at the end of each request in order to ensure the same data does not carry over into future requests.

chromelogger.reset()

Clears out any data that has been set during this request.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].