Author Topic: Please make current active log file accessible to the API  (Read 499 times)

phrrngtn

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Please make current active log file accessible to the API
« on: August 14, 2015, 04:38:20 PM »
I would like to know which file pyxll is currently configured to write log messages to. The purpose is to have a menu item whose action is to spawn a tail -f in a separate window. Another likely application is to have an RTD func which show the most recent N entries in a table in a worksheet.

it would be nice to have this without having to poke around in the logging API

Tony

  • Administrator
  • Hero Member
  • *****
  • Posts: 544
  • Karma: +12/-1
    • View Profile
Re: Please make current active log file accessible to the API
« Reply #1 on: August 14, 2015, 04:47:24 PM »
Hi,

you can get it from the config. See the menus example, copied below.

Code: [Select]
from pyxll import xl_menu, get_config

@xl_menu("Open log file", order=3)
def on_open_logfile():
    # the PyXLL config is accessed as a ConfigParser.ConfigParser object
    config = get_config()
    if config.has_option("LOG", "path") and config.has_option("LOG", "file"):
        path = os.path.join(config.get("LOG", "path"), config.get("LOG", "file"))
        webbrowser.open("file://%s" % path)

Best regards,
Tony

phrrngtn

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Please make current active log file accessible to the API
« Reply #2 on: August 14, 2015, 05:25:29 PM »
I had not seen that example (my internal distribution of Pyxll is a stripped down one and I had not looked at the official dist in some time).

I copied it in and it works just fine! Thanks very much.

pjjH
 

phrrngtn

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Please make current active log file accessible to the API
« Reply #3 on: September 11, 2015, 11:56:34 PM »
You did a very nice job on the RTD stuff. Thanks!

Tony

  • Administrator
  • Hero Member
  • *****
  • Posts: 544
  • Karma: +12/-1
    • View Profile
Re: Please make current active log file accessible to the API
« Reply #4 on: September 15, 2015, 09:37:40 AM »
Thanks! Glad you're finding it useful.

Best regards,
Tony