How can profile (log the charging and discharging current for some time period) my battery? As the question reads, I want to log the current in milliAmpere or Ampere (both charging and discharging) over a period of time.

Please note I am not asking about charging or discharging rate, but rather on the current. I am aware of the app called Ampere which displays the current, which is good but I want them logged over a period of time.  I am also aware of the app Battery Log, which logs the details but not the current.

Device info: Nexus 5 rooted, running stock 5.1.1. Ready to install custom kernel but stock ROM only.

Edit: Based on a comment from Firelord, I could see a file in /sys/class/power_supply/battery/current_now which at the moment of writing had a number 835910 and after a second it became 695229, then 673163. All these values were during the discharge phase.

When plugged in, it showed 412190 and the Ampere app showed 160mA.  It seems this is the current, but I guess I have to average it out to compare it with Ampere's output.

Interestingly, there is another file named status which has values charging and discharging.

I also happen to know another question in this site.
This is not as in-depth as FireLord's answer, but I found a few apps that might be useful.  

These all appear monitor current and have a log feature:  


Current Widget: Battery Monitor by RmDroider   
Battery Utility Free by SUXD   
Advanced Battery Monitor by Codeka   
Battery Monitor Widget by 3c   
Battery Spy by Vertiform Technologies


These are more general system monitors but they appear to include battery stats and logging:


Elixir 2 by Tamás Barta   
AndroSensor by Fiv Asim