AstuteSource / chasten

:dizzy: Chasten Uses XML and XPATH to Check a Python Program's AST for Specified Patterns!
https://pypi.org/project/chasten/
GNU General Public License v2.0
7 stars 8 forks source link

Syslog added to documentation #70

Closed KellerLiptrap closed 11 months ago

KellerLiptrap commented 1 year ago

Addition of Chasten Log command documentation to the read me.

gkapfham commented 1 year ago

Hello @KellerLiptrap can you please write a description for this PR?

simojo commented 1 year ago

When you run chasten log, chasten opens up a websocket server on 127.0.0.1:2525 (See chasten/server.py). This then implements a handler callback that prints messages to the console and logs them to the file .discover.log:

# server.py
class SyslogUDPHandler(socketserver.BaseRequestHandler):
    """Syslog UDP handler for receiving debugging messages."""

    def handle(self):
        """Receive a message and then display it in output and log it to a file."""
        global logger  # noqa: disable=PLW0603
        # receive the message from the syslog logging client
        message = bytes.decode(
            self.request[0].strip(), encoding=constants.server.Utf8_Encoding
        )
        # remove not-printable characters that can appear in message
        enhanced_message = str(message).replace(
            constants.markers.Bad_Fifteen, constants.markers.Empty_String
        )
        enhanced_message = enhanced_message.replace(
            constants.markers.Bad_Zero_Zero, constants.markers.Empty_String
        )
        # display the message inside of the syslog's console
        output.console.print(enhanced_message)
        # write the logging message to a file using a rotating file handler
        logger.debug(enhanced_message)

You can learn more about this by reading the source code.

I'm not completely sure about the whole intended functionality of this, but I would assume that, depending on the log level specified, the separate syslog process would pick up on this. Does anyone else have any more ideas as to how this works? I've only looked at it for a few minutes.

boulais01 commented 1 year ago

@KellerLiptrap Did you resolve the issue that Simon pointed out? If so, we can check that as resolved and add this to the list of PRs we can merge by Tuesday.

KellerLiptrap commented 1 year ago

@boulais01 Yes I have resolved these issues and updated this issue and added to the documentation. I believe that it can be added to the list to be merged.

hayleepierce commented 12 months ago

@KellerLiptrap If this PR is ready for review, make sure to add the label ready-for-review. Also, please ensure that you are working with the most up-to-date version of chasten.

laurennevill commented 12 months ago

@gkapfham, this is priority 4

laurennevill commented 11 months ago

Hello @KellerLiptrap, can you ensure that this PR is up to date with the main branch? From there we can get this merged

boulais01 commented 11 months ago

@laurennevill @jnormile I believe the issues you both brought up should be resolved now, if you wouldn't mind reviewing again.

boulais01 commented 11 months ago

@laurennevill this is ready to be merged when you deem it fit.