Copy link to clipboard
Copied
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:
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)
Copy link to clipboard
Copied
sorry but I did not understand how to use it
you could put an example that I can understand
thank you
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
Once the 3 files have been created, I have to use them
I would like to understand this
excuse my curiosity
Copy link to clipboard
Copied
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)
Copy link to clipboard
Copied
Now I get it
thanks for sharing and further information
Find more inspiration, events, and resources on the new Adobe Community
Explore Now