Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
1

Simple Logging Utility

Explorer ,
Jun 01, 2018 Jun 01, 2018

Hi Everyone --

I wanted a way to easily create unique log files for each run of my scripts so I wrote a simple library to help with that:

GitHub - sidpalas/extendscript-logging: logging utility for Adobe ExtendScript

I'm using Photoshop CC 19.1.3 on macOS High Sierra. If you are on another version/system YMMV (May need to tweak path definitions for Windows?).

Example usage can be found in main.jsx, the contents of which are included below:

#target photoshop

//@include "./logging.jsxlib"

var defaultLog = new LogFile();

defaultLog.log("Logging to the default log!");

defaultLog.log("Logging to the default log again...");

var normalLog = new LogFile('normal');

normalLog.log("Logging to the normal log!");

var specialLog = new LogFile('special');

specialLog.log("Logging to the special log!");

This produces 3 log files with a date/time stamp in the filename and each logged message:

Screen Shot 2018-06-01 at 9.42.29 AM.png

Feel free to use/adapt to your needs. I'm happy to answer any questions people have about it as well.

Cheers,

Sid

Message was edited by: sid palas (changed syntax from original posting and updated usage examples)

TOPICS
Actions and scripting
1.9K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
Advocate ,
Jun 01, 2018 Jun 01, 2018

sorry but I did not understand how to use it

you could put an example that I can understand

thank you

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 01, 2018 Jun 01, 2018

If you go to the GitHub repository I linked you will find both the library file ("logging.jsxlib") and a script showing an example of how to use it ("main.jsx").

You can download a copy of the whole repo as a zip file using this link: https://github.com/sidpalas/extendscript-logging/archive/master.zip

Then simply run main.jsx (either from Photoshop or using ExtendScript Toolkit) and it should generate 3 log files as described.

One thing to point out is the relative path I used within main.jsx of "./logging.jsxlib". The two files need to be in the same directory for that include statement to work properly.

Hopefully that helps!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 02, 2018 Jun 02, 2018

Once the 3 files have been created, I have to use them

I would like to understand this

Schermata 2018-06-02 alle 09.50.06.png

excuse my curiosity

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 02, 2018 Jun 02, 2018

Oh so you were able to run the script, and now you are asking why you might use something like this?

The primary use for log files is to help with things like monitoring, troubleshooting and debugging of your program. This post (programming practices - Logging: Why and What? - Software Engineering Stack Exchange ) provides some more detailed answers as to why logging is useful for software programs.

To give a simple Photoshop example, imagine your script is processing a batch of images and rescaling them for use on the web. One thing you might want to use logging for is to record a warning every time the input image is below a certain size threshold. This would enable you to look at the log after the fact and see which images might not be of high enough resolution.

Does that clarify things?

(Also -- I don't think this was your question, but if you were asking how to open/view the log files, just open with a text editor)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 02, 2018 Jun 02, 2018
LATEST

Now I get it

thanks for sharing and further information

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines