Machine name doesn't change in papertrail slug if changed

Issue #9 new
Daniel Sun created an issue

My app requires users to log in to access features, but we'd like capture logs from user input prior to log in, so we initialize our paper trail logger before we have a user's email address. Once the user does log in, I set the machine name of the paper trail logger to be a variation of the user's email address.

However, I've noticed that though this does change the name of the reported system on the papertrail dashboard, it DOESN'T change the slug for the logs for that system, instead it keeps the generated UUID.

https://papertrailapp.com/systems/<UUID>/events vs https://papertrailapp.com/systems/<user email>/events

Is there a way to override the slug once it is registered to a system?

Comments (4)

  1. George Malayil

    Hi Daniel,

    I had come across something similar during my tests - if I started off with a null machine name, and switched to a defined one after logging commenced, it wouldn't show the updated name. I suspect this might be due to establishing a socket only once during the program lifetime. Papertrail might just be using the first machine name on a socket - but, this is speculative on my part.

    We could try to close the socket and re-open a new one, when the machine name is changed - and test to see if this makes a difference. If you would like to test and submit a PR, I would be glad to accept it. Else, I'll try to get to it at some point myself :)

    Thanks

    George

    Edit: I had misunderstood your issue. So, edited the portion with regards to machine name change

  2. Daniel Sun reporter

    I will try and close the socket and the reopen it. However, I've found that in my testing, even if I start the socket with a defined machine name, I still get a UUID for the slug.

  3. Daniel Sun reporter

    Ah, I now see what is happening. I am setting the machine name to be a variant of a user email, which contains the reserved "@" character. When I set the machine name to be a string without any reserved or unsafe characters, then the slug gets updated accordingly.

    Resolving this issue now.

  4. Yves-Eric Martin

    This old issue can probably be closed now: by the looks of it, it is the same as:

    https://bitbucket.org/rmonkey/papertraillumberjack/issues/13/parentheses-in-machinename-or-brackets-in

    The "machine name does not change" behavior was a Papertrail-side fallback behavior, but caused by PaperTrailLumberjack sending invalid log messages: with the old log format used (RFC3164), PaperTrailLumberjack should have removed much more than spaces from the machine name: the machine name needed to be a hostname, so only alphanums and hyphens were allowed. Seeing an invalid message, Papertrail does its best to parse it, and falls back to previous values where parsing failed.

    By changing the log format to a more recent one (RFC5424), v0.1.9 now allows pretty much any character (except spaces, which are removed automatically) in the machine name.

  5. Log in to comment