Giter Site home page Giter Site logo

cutelog's Introduction

cutelog – GUI for logging

PyPi

This is a graphical log viewer for Python's logging module. It can be targeted with a SocketHandler with no additional setup (see Usage).

It can also be used from other languages or logging libraries with little effort (see the Wiki). For example, a Go library gocutelog shows how to enable regular Go logging libraries to connect to cutelog.

Features

  • Allows any number of simultaneous connections
  • Customizable look of log levels and columns, with presets for each
  • Filtering based on level and namespace, as well as filtering by searching
  • Search through all records or only through filtered ones
  • Display extra fields under the message with Extra mode
  • View exception tracebacks or messages in a separate window
  • Dark theme (with its own set of colors for levels)
  • Pop tabs out of the window, merge records of multiple tabs into one
  • Save/load records to/from a file in JSON format

Screenshots

Light theme Dark theme

Installation

If you're using Linux, install PyQt5 (or PySide2) from your package manager before installing cutelog (package name is probably python3-pyqt5 or python-pyqt5). Or just run pip install pyqt5 to install it from pip, which is sub-optimal.

$ pip install cutelog

Or install the latest development version from the source (requires PyQt5 to build resources):

$ pip install git+https://github.com/busimus/cutelog.git

Requirements

  • Python 3.5 (or newer)
  • PyQt5 (preferably 5.6 or newer) or PySide2
  • QtPy

Usage

  1. Start cutelog
  2. Put the following into your code:
import logging
from logging.handlers import SocketHandler

log = logging.getLogger('Root logger')
log.setLevel(1)  # to send all records to cutelog
socket_handler = SocketHandler('127.0.0.1', 19996)  # default listening address
log.addHandler(socket_handler)
log.info('Hello world!')

Afterwards it's recommended to designate different loggers for different parts of your program with log_2 = log.getChild("Child logger"). This will create "log namespaces" which allow you to filter out messages from various subsystems of your program.

Attributions

Free software used:

And thanks to logview by Vinay Sajip for UI inspiration.

Copyright and license

This program is released under the MIT License (see LICENSE file).

Copyright © 2023 bus and contributors.

cutelog's People

Contributors

aberrya avatar busimus avatar ggajoch avatar luziferius avatar sienczak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cutelog's Issues

Feature request: keep focus on the log record when toggling levels

First, I wanted to thank the authors for the nice piece of software.

I have the following feature request, which would help studying the logs.

Use case

Let's say, I have INFO (not too many) and DEBUG (a lot!) messages. When disabling display of DEBUG messages in the Levels panel, I can conveniently browse through the INFO messages and find the one I am interested in. I click on it in the entry list to select it. Then I click on a DEBUG tick box to start showing more detailed log.

What happens now

The list of log entries is scrolled and the selected INFO entry moves out of the screen. It takes effort to find it by its time, for example.

Desired behavior

The selected entry stays on the screen, and I can immediately explore DEBUG entries just before and just after the selected one.

Hope this is clear and you will find it useful too.
Regards,
Dima.

Support HiDPI displays

Currently, at default, cutelog looks like this on my display (3840x2160, 2x scale)

screenshot from 2018-01-12 14-44-09

It gets worse on Settings dialog

screenshot from 2018-01-12 14-46-54

Thanks for your awesome work! ;)

Create a Flatpak package

Hi! Have you considered creating a Flatpak package which then could be uploaded to Flathub for easy installation on Linux? Thanks in advance.

Remote logging?

Hi -

First of all, great tool, thanks! It really scratches an itch I had 🥇

Could you elaborate in the docs on how to set up remote logging (if such a thing is possible)? Specifically tailing a log on another server and watching it in a cutelog client on another machine.

Feature Request? Record a log compatible with cutelog via Python script

I'm exploring using the Python logging module in an automated test system. I'd like to automatically start the logger in my Python tests and archive the log file. I'd like people to be able to download the log file after the test is completed and view it in a UI like cutelog. Is this possible?

Debug Cutelog itself

I updated cutelog but it closes immediately after I start the windows application. Is there any chance to get a log or see the message?

Plans for lighter / LGPL version?

Hello, I really like your application and would like to include it in a project. However I only release MIT / BSD licensed code, so can only use stuff with similar or dynamically linked with LGPL licenses.

I was curious if you perchance had a lighter version of its core functionally that you may be releasing in the future that is more friendly licensed?

Thanks for the great program either way!

Feature request: Close all old tabs

A button "Close other tabs" that closes all but the active tab. This feature exists in for example Eclipse.

Background: When I develop a program, I often restart the program to load changes. This will (very reasonably) create a new tab in Cutelog. But often I'm not interested in the old tabs and I just want to close them all. This could be 20 tabs so it's a lot of clicking.

For more control, an option "close all to the left" could close all but a set of most recent tabs.

Error while starting the server

cutelog failed to start (and restart) the server

I changed the ip and server port, however cutelog doens't work and I keep on getting a screen with the following message

"Error while starting the..." permission denied

sudo doesn't help

Requirement qtpy is not installed by pip

pip install cutelog does not install the qtpy package (it does install PyQt5).

This results in a ModuleNotFoundError: No module named 'qtpy' when trying to start cutelog.

It seems just to be a missing dependency in the package info, because after a pip install qtpy things are ok.

Bug: Time tab not getting the created time field

The created time field is a string (not int nor float).
In this case the Time tab gets the cutelog current time (logger_tab.py:155).

How to test:
Saving the record and loading again will give always the current time and not the created time.

How to solve (proposition):
Convert the created time from str to float.

Presets for columns other than Level

I have a column in my logs that is "app". It would be nice to (in single log mode) be able to temporarily filter to just show rows matching with a specific "app".

More generally, can we be able to filter rows based of a particular column value?

Conflicting Licenses

Hello, I am exploring a simple "wrapper" of cutelog to add "actions" (such as opening the source file to the location of a logged error).

While I am attempting to provide a clean sub-classing of qutelog classes (with possible monkey-patching -- if needed), there are a couple of cutelog files (such as __main__.py) which I need to copy and then slightly alter.

Cutelog's "Main" LICENSE is currently MIT (from commit f9e7ce1 on 5 May 2019 at 17:28)

Unfortunately your UI's about box still lists your LICENSE as GPLv3.

My goal here is to make my project's license the same as your (current?) license, so that my changes, should they prove useful, may (some day) be incorporated directly into the main cutelog project.

Which LICENSE is the currently correct license, and which license should I use for my project ( https://github.com/stephengaito/cutelogActions )?

Regards,
Stephen Gaito

Clear the log programmtically

Very nice application, it really does everything what I need. Except that I always need manually trim the log before starting my code again. Would be nice if there would be a option to this either after the connection is dropped and started again, or programmatically from python code.

Decrease UI size on Windows

Hi,
Thanks for your project. I'm running on Windows with 150% scaling, and the entire cutelog interface is enlarged. Is there a way to decrease the UI size as a whole?

See screenshot, with notepad++ in the background, showing normal appearance of app menu:

image

Thanks

Reuse tabs when a new session is created

Hello,

Really love this tool. I have a few uvicorn services that restart whenever a file is changed. That closes the connection, and it means when the process restarts, it makes a new tab. Is there any way to reuse a tab after a connection is closed?

Thanks :)

Error when deserializing received data

Hi, thanks for this nice software.

Sometimes I get an error

Traceback (most recent call last):
  File "d:\pf\ana3\lib\site-packages\cutelog\listener.py", line 149, in run
    data = self.deserialize(data)
_pickle.UnpicklingError: pickle data was truncated

It leads to the crash of the program. I am not sure why it happens, but wrapping whose lines in LogConnection.run() in listener.py with try... except... seems to help (probably as a workaround until more stable data reading can be done):

            if not data:
                continue

            try:
                data = self.deserialize(data)
            except Exception as e:
                self.log.warning('Error deserializing data (len={}). ' 
                                 'The following exception was raised: {}'
                                 .format(len(data), e))
                continue
            record = logging.makeLogRecord(data)
            self.new_record.emit(record)

Best regards,
Dima.

Logs sometimes appear out of chronological order

I had a bug where I was logging things a bit more often than i intended.. I thought cutelog was working just fine, but then noticed that some logs were not in time-based order:

image

Notice how the log between the 2 marked ones is after the second marked one.

Can we have the logs order based off of time stamp (instead of process'd order)?

log namespaces multi-selection not effective

Hey,

Thanks for this tool! 😄 A good GUI for Python logging was something I have been missing for a very long time!

One issue I encountered:
It seems to be possible to multi-select the wanted loggers in the "log namespaces" area using the CTRL+click, or by holding the left button.
However, only the last logger is taken into account.

As a result, the only way to display multiple loggers in a tab is to enable the children of the selected logger. This is useful, but often not enough: being able to manually multi-select the wanted loggers to display would be great!

Feature request: Add extras_require for pyqt and pyside

It would be nice to be able to do an install like pip install cutelog[pyqt5] and have it also install the qt libraries. This would come in handy in cases like when you want to use it as a standalone app via pipx where it is not as easy to install additional requirements in that venv yourself.

They are fairley easy to add to setup.py, i.e.:

    extras_require={
        "pyqt5":  ["pyqt5"]
    }

It also wouldn't change any current usage, as it will still support pip install cutelog without any of those included.

https://setuptools.readthedocs.io/en/latest/setuptools.html#declaring-extras-optional-features-with-their-own-dependencies

Logging from multiple threads?

Does cutelog support logging from multiple threads? If I run each of these in two terminals:

logger = logging.getLogger('fruit.apple') 
socket_handler = SocketHandler('127.0.0.1', 19996) 
logger.addHandler(socket_handler) 
logger.error('apples are great')
logger = logging.getLogger('fruit.banana') 
socket_handler = SocketHandler('127.0.0.1', 19996) 
logger.addHandler(socket_handler) 
logger.error('peanutbutterjelly')

I expect to see them in the same cutlog tab, but instead I get two tabs, one with fruit.apple and the other with fruit.banana. Am I missing something?

Feature request: Embedded cutelog

It would be nice to have a separate entry that used an existing QT MainWindow that would make cutelog easily added to other QT based programs.

Possibly add a way to pass through a custom program name as well, so it could display in the title bar "ProgramName Logs (powered by cutelog)" or similar.

Time log display problem

Screenshot 2024-04-24 115500

When we import a log file to the program, there is a problem in the time table that does not show the events of each log correctly! And it shows the time of importing the file to the program and it is shown for all the logs of the same time! In case, the time of occurrence of the log must be the same as the time recorded in the file
As you can see in the photo, the login time is what is displayed at the bottom of the menu (the details section of each log) and the time in the table is all wrong.

Autosave records?

Hi,

Is there a way to have cutelog autosave logs that it receives so that upon reopen, logs can come back up?

file format support

Hi,

I am looking to see if is possible to open a logger saved directly from logging module, is would be a matter of maybe giving it the right format so cutelog can open correctly the file?

Will appreciate your comments,

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.