Forum Discussion

angelodiego's avatar
angelodiego
Occasional Contributor
6 years ago

Extracting file posted with log.file from logs

Hello everyone,

I'm posting a file in the logs with logs.file(), I'd like to access the logs with a script and extract that file, to give you some context I have several reference text file and when the code that generates the files in our application changes I'd like to visually inspect all the differences in the logs and if the differences are what I expected replace all the reference files with the files in the logs.

4 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Why extract from the log?  You already have the file when you post it to the log... do the replacement real time rather than try to extract after the fact.  So, as soon as you find the difference in your test, replace the reference file with the file you are about to write to the log.  No need to do an extract.

     

     

    • angelodiego's avatar
      angelodiego
      Occasional Contributor

      The files are created on a host machine, I have the log files on the master, several tests projects are run on the host machine and every time it's wiped clean, I have potentially 100's of files to change and doing a procedure that updates all the files is way more effective

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Then, alternatively, rather than extracting them from the log, in your script code, save the file to a centralized location.

         

        I'm not saying it's not possible to extract the files from the log (I've not had need to) but the code for doing so is probably going to be a bit complex to be able to read the native log format, find the reference to the file, extract and decode the bit-stream, etc.  So, rather than overcomplicating things, pick a shared directory location on some centralized file server, write the files to that, and then use that location as your source for processing and updating the files.