nautobot / nautobot

Network Source of Truth & Network Automation Platform
https://docs.nautobot.com
Apache License 2.0
1.05k stars 279 forks source link

Nornir job logging #4484

Open gsnider2195 opened 1 year ago

gsnider2195 commented 1 year ago

As ...

P.D. - Plugin Developer

I want ...

To be able to use nornir in a job and use the job's logger to log to the console and database simultaneously

So that ...

I don't have to pass around the JobResult object to perform job logging in nornir tasks

I know this is done when...

I can create a job that calls a nornir task, passes in the job's self.logger that can be used by nornir's task_instance_completed to log to the database and console. This doesn't currently work because task_instance_completed runs in a separate thread that celery is not aware of so celery does not know which task to associate the log to (celery._state.get_current_task returns None)

Optional - Feature groups this request pertains to.

Database Changes

No response

External Dependencies

No response

itdependsnetworks commented 1 year ago

Thanks to @gsnider2195 for creating this!!

In general, I think the request can be broadened to allowing logging for threaded processes.