6 Replies Latest reply on Jan 15, 2014 11:45 AM by johnrellis

    LrLogger - any simple way to specify directory for logfile output?

    areohbee Level 5

      I realize one can rewrite the log function to do whatever, but is there a way to simply specify a different directory for log output than the Lr default (documents), when using default implementation of LrLogger. - maybe config.lua?

        • 1. Re: LrLogger - any simple way to specify directory for logfile output?
          johnrellis Most Valuable Participant

          When LR 4 came out, I tried to figure out config.lua from the poor documention of the LrLogger API.  Using hints from a thread between you and escouten in 2010, I tried putting the file in various locations without any apparent effect.

          1 person found this helpful
          • 2. Re: LrLogger - any simple way to specify directory for logfile output?
            DawMatt Level 3

            To the best of my knowledge there is no way to influence the log file's location using config.lua or any other mechanism.

             

            Config.lua is most useful for explicitly enabling multiple logging mechanisms or logging levels for a single logger. e.g. you could enable trace level logging for your program using Config.lua, but by default only use warning level logging within your plugin.  The LR team occassionally reveal other uses - e.g. switching on or off functionality in the product - but I haven't seen any other settings related to LrLogger.

             

            Matt

            • 3. Re: LrLogger - any simple way to specify directory for logfile output?
              johnrellis Most Valuable Participant

              The "Lightroom 4 SDK Programmers Guide", page 32, describes how to make an entry into config.lua for finding deprecated API calls.  (That's the only reference to config.lua in the Guide.)

              • 4. Re: LrLogger - any simple way to specify directory for logfile output?
                areohbee Level 5

                John R. Ellis wrote:

                 

                The "Lightroom 4 SDK Programmers Guide", page 32, describes how to make an entry into config.lua for finding deprecated API calls.  (That's the only reference to config.lua in the Guide.)

                I'll be danged - that's new in Lr4 (or at least the documentation of it is new), and a very good idea, and one I requested but assumed had been ignored. - I'm stoked. - thanks for bringing it to my attention.

                 

                And, just for the sake of completeness, this is from the api doc:

                 

                Configure loggers using the config.lua file as follows:

                • Create an entry for each logger of interest by specifying loggers.loggerName = {...}
                • Arguments in the table include logLevel and a string "fatal", "error", "warn", "info", "debug", or "trace".
                • For each valid log level, you can add an entry to modify the behavior of log messages for that level. For example, to log to a file, add the entry trace = 'logfile',
                • To specify an action for all log levels, add the entry action = 'logfile',

                 

                PS - I just solved the problem in my own plugins by using a custom log function (like in the debugging toolkit's Debug.lua).

                 

                UPDATE: sdkDeprecation.action = "{whatev}" -- needs the quotes.

                • 5. Re: LrLogger - any simple way to specify directory for logfile output?
                  kamaji

                  I know this is a necropost, however things haven't really changed at all with LrLogger with Lightroom 5 -- even just improving the docs provided.

                   

                  What I'm after is more detail on the 'action' logger configuration parameter.

                  Right now per the docs, the only valid action is 'logfile'.  Why did they even specify action at all, if it isn't configurable?

                  It would certainly be nice to direct the log to the syslog itself (on Mac at least).  If that was possible, one could use any number of tools that hook into syslog.

                   

                  Has anyone learned anything new about LrLogger?  Some improved community documentation would be nice.

                  I haven't really learned anything outside of what's in the docs -- creating a Logger, enabling and disabling it programmatically, however it only creates the logger in ~/Documents (mac) or %USERPROFILE%/My Documents (windows)

                   

                  ~Keith

                  • 6. Re: LrLogger - any simple way to specify directory for logfile output?
                    johnrellis Most Valuable Participant

                    Here's the code I use to log to "debug.log" in the current plugin's directory (this is from my Debugging Toolkit):

                     

                    --[[----------------------------------------------------------------------------
                    public LrLogger log
                    
                    
                    The "log" is an LrLogger log file that by default writes to the file "debug.log"
                    in the current plugin directory.
                    ------------------------------------------------------------------------------]]
                    
                    
                    Debug.log = LrLogger ("com.johnrellis.logger")
                        --[[ This apparently must be unique across all of Lightroom and plugins.]]
                    
                    
                    logFilename = LrPathUtils.child (_PLUGIN.path, "debug.log")
                    
                    
                    Debug.log:enable (function (msg)
                        local f = io.open (logFilename, "a")
                        if f == nil then return end
                        f:write (
                            LrDate.timeToUserFormat (LrDate.currentTime (), "%y/%m/%d %H:%M:%S"), 
                            msg, Newline)
                        f:close ()
                        end)