Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom script logs are missing hyperlinks #16149

Open
hendrikbl opened this issue May 15, 2024 · 3 comments · May be fixed by #16271
Open

Custom script logs are missing hyperlinks #16149

hendrikbl opened this issue May 15, 2024 · 3 comments · May be fixed by #16271
Assignees
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application

Comments

@hendrikbl
Copy link

Deployment Type

Self-hosted

NetBox Version

v4.0.2

Python Version

3.11

Steps to Reproduce

  1. Create a custom script with logs using self.log_info(some_object, message)
  2. Run the script to write the logs
  3. View the logs in the jobs log view

Expected Behavior

Prior to 4.0 the object passed to log_info was displayed with a hyperlink to quicly reach the details view.

Observed Behavior

Now we have a URL column instead wich we have to copy and paste into the browser or search for the name of the object.

@hendrikbl hendrikbl added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels May 15, 2024
@hendrikbl
Copy link
Author

Having this functionality for script logs would also be nice. Currently the same logging functions are used in the run function as well as the test_ functions. But when called from inside the run function, the second parameter (which is the object) is never displayed in the logs on the front end. There is simply no column to display the value.
I think in an effort to merge scripts and reports it would be nice to also get some consistency there.

@Alef-Burzmali
Copy link
Contributor

Alef-Burzmali commented May 21, 2024

More generally, it seems that the logging functions for scripts (syntax log_info(message, obj)) ignore the obj argument in NetBox 4.0, despite the documentation saying otherwise. Note also that the documentation is naming the argument object= where it should be obj= according to the code.

elif message:
# Record to the script's log
self.messages.append({
'time': timezone.now().isoformat(),
'status': level,
'message': str(message),
})
# Record to the system log
if obj:
message = f"{obj}: {message}"
self.logger.log(LogLevelChoices.SYSTEM_LEVELS[level], message)

The obj parameter is not referenced in the JSON that is stored in the DB. It is however prepended to the message in the system/console logs. You can also verify in the DB directly: select * from core_job order by id desc limit 1 \gx (to get the results of the last script execution). data["log"] has no reference to any object.

@DanSheps DanSheps added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: needs triage This issue is awaiting triage by a maintainer labels May 21, 2024
@DanSheps DanSheps removed their assignment May 21, 2024
@arthanson arthanson self-assigned this May 23, 2024
@arthanson arthanson removed the status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation label May 23, 2024
@jeremystretch
Copy link
Member

@arthanson what is the status of this issue?

@jeremystretch jeremystretch added the status: accepted This issue has been accepted for implementation label May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: accepted This issue has been accepted for implementation type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants