Custom script logs are missing hyperlinks #9683

Closed
opened 2025-12-29 21:20:49 +01:00 by adam · 3 comments
Owner

Originally created by @hendrikbl on GitHub (May 15, 2024).

Originally assigned to: @arthanson on GitHub.

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.

Originally created by @hendrikbl on GitHub (May 15, 2024). Originally assigned to: @arthanson on GitHub. ### 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.
adam added the type: bugstatus: acceptedseverity: low labels 2025-12-29 21:20:49 +01:00
adam closed this issue 2025-12-29 21:20:49 +01:00
Author
Owner

@hendrikbl commented on GitHub (May 15, 2024):

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.

@hendrikbl commented on GitHub (May 15, 2024): 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.
Author
Owner

@Alef-Burzmali commented on GitHub (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.

44771d1221/netbox/extras/scripts.py (L496-L508)

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.

@Alef-Burzmali commented on GitHub (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](https://docs.netbox.dev/en/stable/customization/custom-scripts/#logging) saying otherwise. Note also that the documentation is naming the argument `object=` where it should be `obj=` according to the code. https://github.com/netbox-community/netbox/blob/44771d1221f617cc8175397bf75bd0c4c7797f9b/netbox/extras/scripts.py#L496-L508 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.
Author
Owner

@jeremystretch commented on GitHub (May 24, 2024):

@arthanson what is the status of this issue?

@jeremystretch commented on GitHub (May 24, 2024): @arthanson what is the status of this issue?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#9683