extendscript_log
Advanced tools
+22
| #### 1.4.0 (2021-05-27) | ||
| ##### New Features | ||
| * add option for custom log file output directory | ||
| * add stack trace to error object | ||
| ##### Other Changes | ||
| * removed source from error object | ||
| #### 1.3.2 (2021-05-27) | ||
| ##### Other Changes | ||
| * Fixes for error object handling | ||
| * Properly escape control characters for json | ||
| * description and comments update | ||
| * Rollback uppercase change cause it broke things and was not useful. | ||
| * Bug fix: added quotes around key values in JSON string sent via CSXSEvent() | ||
| * [Bug Fix]: don't stringify a string... added check to return original string if string passed to _stringifyMessage(). Was always wrapping strings in quotes... | ||
| * Documentation and license typos | ||
| * First push... | ||
| * Initial commit |
+1
-1
| { | ||
| "name": "extendscript_log", | ||
| "version": "1.3.1", | ||
| "version": "1.4.0", | ||
| "description": "A log constructor for Adobe ExtendScript with optional log file, and broadcasts to CEP panels with \"ExtendScript_Log\" events. UMD wrapper for cross-compatability with AMD and node.js require.", | ||
@@ -5,0 +5,0 @@ "main": "./dist/extendscript_log.jsxinc", |
+30
-37
@@ -37,6 +37,6 @@ # Summary | ||
| ### Eval into environment | ||
| `$.evalFile("<path>/extendscript_log.jsxinc")` | ||
| `$.evalFile("<path>/ExtendScript_Log.jsxinc")` | ||
| ### Include in scripts | ||
| `//@include "<path>/extendscript_log.jsxinc"` | ||
| `//@include "<path>/ExtendScript_Log.jsxinc"` | ||
@@ -48,9 +48,9 @@ ### concatinate or copy-paste directly | ||
| Default log levels are: | ||
| * trace:0 | ||
| * debug:1 | ||
| * info:2 (also default if not specified) | ||
| * warn:3 | ||
| * error:4 | ||
| * critical:5 | ||
| - 0 - trace | ||
| - 1 - debug | ||
| - 2 - info (also default if not specified) | ||
| - 3 - warn | ||
| - 10 - error | ||
| ## Make new log object | ||
@@ -73,3 +73,3 @@ make a new log and you get a separate instance | ||
| ### Constructor options | ||
| "new" constructor takes 4 optional arguments. | ||
| "new" constructor takes 6 optional arguments. | ||
| First arg is an alternate root object to tack on a 'log' and 'console' alias | ||
@@ -82,6 +82,7 @@ By passing $.global as first arg, we get global log and console objects! | ||
| logLevel = 2;// log level filter | ||
| useLogFile = true;// make a log file? Deafults to false | ||
| useLogFile = true;// make a log file? Deafults to false. (see Bonus Features) | ||
| keepOldLogs = false;// keep or delete all but latest log file? | ||
| logFileDir = undefined;// a string filepath to save logs to. | ||
| myLog = new ExtendScript_Log(root, logName, logLevel, useLogFile, keepOldLogs); | ||
| myLog = new ExtendScript_Log(root, logName, logLevel, useLogFile, keepOldLogs, logFileDir); | ||
| ``` | ||
@@ -91,2 +92,9 @@ | ||
| ``` | ||
| Log.log (message, useAlert);// standard use | ||
| // send custom level/label; doesn't work with Log.info() etc. | ||
| Log.log (message, level, label, useAlert); | ||
| ``` | ||
| ``` | ||
| myLog = new ExtendScript_Log($.global); | ||
@@ -110,2 +118,3 @@ console.log('Messages are good.'); | ||
| Second argument sends up an blocking alert dialog in app if true | ||
| ``` | ||
@@ -118,5 +127,7 @@ log.error('Not a good thing', true); | ||
| Tries to make a log file in ./logs or to ~/Desktop/ExtendScript_Log_UnsavedScripts/ | ||
| Needs [ExtendScript_LogFile](https://github.com/MaxJohnson/extendscript_logfile) | ||
| or you can specify a custom log folder path as the 6th argument. | ||
| Needs [ExtendScript_LogFile](https://github.com/MaxJohnson/extendscript_logfile), | ||
| *but will make a new log file automatically* if that has been included. | ||
| *Note: Differnt logs get different log files, even if they all print to the same console.* | ||
| *Note: Different logs get different log files, even if they all print to the same console.* | ||
@@ -127,27 +138,9 @@ ## CEP event: | ||
| data string looks like: `{type: "default", level:2, label:"info", message:"Important things!"}` | ||
| Note: the "clear()" function sends a packet with "clear" label and log level 99. | ||
| *Note: the "clear()" function sends a packet with "clear" label and log level 99.* | ||
| # CEP Integration | ||
| ## Catch log events in CEP panel | ||
| This example assumes there is already an ExtendScript_Log sending logs from a script. The code below would be in the main CEP panel javascript. | ||
| ## Add custom labels and levels: | ||
| ``` | ||
| var csInterface = new CSInterface(); | ||
| // Hook up internal logging messages from extendscript scripts that support it | ||
| csInterface.addEventListener( 'ExtendScript_Log', handleExtendscriptLog); | ||
| function handleExtendscriptLog(evt) { | ||
| var label = evt.data.label; | ||
| var logger = ( !label || label == 'undefined')? 'log':label; | ||
| var data = (typeof evt.data == 'string')? JSON.parse(sanitizeStringForJSON(evt.data)):evt.data; | ||
| console[logger]('[ES]', data.message); | ||
| } | ||
| ``` | ||
| Any logs coming from ExtendScripts would then print to the debug console of the chrome(ium) window you are testing in with warnings and errors displaying as such in the console... | ||
| ``` | ||
| //--- ExtendScript ---// | ||
| myLog = new ExtendScript_Log($.global); | ||
| console.log('Messages are good.'); | ||
| log.warn('Duck!'); | ||
| log.error('Not a good thing'); | ||
| ``` | ||
| // add a custom log level | ||
| Log.addLogLevel("gui",3); | ||
| Log.gui('Making dialog'); | ||
| ``` |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
24597
6.38%5
25%1
-50%138
-5.48%