npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

extendscript_log

v1.4.0

Published

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.

Downloads

3

Readme

Summary

An ExtendScript compatible log constructor object with shims for basic Console calls, log file, and custom "ExtendScript_Log" events sent to CEP panels.

Trying to split the difference between too-basic and OMG-features-and-dependencies.

Features

  • Works with node.js require, AMD(probably), and vanilla ExtendScript.
  • Adds 'log' and 'console' aliases to optional parameter (like $.global)
  • Tries to JSON.stringify your message for you
  • Optional ExtendScript_LogFile support
  • Event delivery to CEP (panels) (with secret support for passing data packets)
  • Make multiple logs with different names and levels and files
  • Graceful fallbacks or omissions if optional dependencies missing

Non-Blocking Dependencies

  • JSON.stringify() via whatever library you care to include
  • Event to CEP panels with new ExternalObject("lib:\PlugPlugExternalObject")
  • ExtendScript_LogFile

Import

NPM

If running Node NPM, you can npm install ExtendScript_Log to add to your node_modules folder

github

Clone or download the repo and copy the ExtendScript_Log.jsxinc to your project

Include

NPM

var extlog = require("ExtendScript_Log");

AMD

I don't know but it's probably not difficult? Firmly in the untested-but-should-work category

ExtendScript

Eval into environment

$.evalFile("<path>/ExtendScript_Log.jsxinc")

Include in scripts

//@include "<path>/ExtendScript_Log.jsxinc"

concatinate or copy-paste directly

Add to a build script or, I dunno, just copy-pasta it in there?

Use:

Default log levels are:

  • 0 - trace
  • 1 - debug
  • 2 - info (also default if not specified)
  • 3 - warn
  • 10 - error

Make new log object

make a new log and you get a separate instance

var myLog = new ExtendScript_Log();
myLog.log('Hey there.');
var specialLog = new ExtendScript_Log(null,"special");
specialLog.log('Salutations.');
myLog.warn('Special log thinks they're all that...');
specialLog.info('Default log is jealous cause I have a label.');

// prints:
// Hey there.
// SPECIAL:Salutations.
// [WARN] Special log thinks they're all that...
// SPECIAL:[INFO] Default log is jealous of my label.

Constructor options

"new" constructor takes 6 optional arguments. First arg is an alternate root object to tack on a 'log' and 'console' alias By passing $.global as first arg, we get global log and console objects!

root = $.global;// root to add convenience alisases to
logName = "specialLog";// name other than "defualt"
logLevel = 2;// log level filter
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, logFileDir);

Use the log

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);
console.log('Messages are good.');
console.info('So informative...');
log.warn('Duck!');
log.error('Not a good thing');

mySecretLog = new ExtendScript_Log(null, "secret");
mySecretLog.warn('Tell no one...');

// prints:
// Messages are good.
// [INFO] So informative...
// [WARN] Duck!
// [ERROR] Not a good thing
// SECRET:[WARN] Tell no one...

Second argument sends up an blocking alert dialog in app if true

log.error('Not a good thing', true);

Bonus Features

Log file:

Tries to make a log file in ./logs or to ~/Desktop/ExtendScript_Log_UnsavedScripts/ or you can specify a custom log folder path as the 6th argument. Needs ExtendScript_LogFile, but will make a new log file automatically if that has been included.

Note: Different logs get different log files, even if they all print to the same console.

CEP event:

Tries to send type, level, label, and message as a packet in a custom event "ExtendScript_Log" No JSON support needed in the script to send, but you have to un-strigify on receipt: 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.

Add custom labels and levels:

// add a custom log level
Log.addLogLevel("gui",3);
Log.gui('Making dialog');