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_logfile

v1.2.0

Published

A basic logging file Class for Adobe ExtendScript with UMD wrapper for cross-compatability with AMD and node.js require.

Downloads

17

Readme

Summary

An Adobe ExtendScript compatible log file constructor with some built in convenience functions in a UMD wrapper for cross-compatability with AMD and node.js require.

Tries to be flexible but automate most things.

Features

  • Works with node.js require, AMD(probably), and vanilla ExtendScript.
  • Tries to make a log file in ./logs with fallback to ~/Desktop/ExtendScript_Log_UnsavedScripts/
  • Tries to clean up old files automatically (or keep them foreverrr)
  • Plays nice with ExtendScript_Log

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_logfile.jsxinc to your project

Include

NPM

var LogFile = require("ExtendScript_LogFile");

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_logfile.jsxinc")

Include in scripts

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

concatinate or copy-paste directly

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

Use:

Make new LogFile object

make a new log file and you get a separate instance

var myLogFile = new ExtendScript_LogFile();
myLogFile.log('Hey there.');

Constructor options

"new" constructor takes 4 optional arguments.

new ExtendScript_LogFile (root, logType, logDir, useDate)

Argument 1 : root

is an alternate root object to tack on a 'logFile' alias By passing $.global as first arg, we get global log and console objects!

root = $.global;// root to add convenience aliases to

var myExplicitLogFileVariable = new ExtendScript_LogFile(root);
myExplicitLogFileVariable.log('So explicit!');// call from a var
logFile.log('Like magic.');// uses the $.global.logFile we made

Argument 2 : logType

specifies a non-"default" type and makes a file name

var myLogFile = new ExtendScript_LogFile();
myLogFile.log('Hey there.');

var specialLogFile = new ExtendScript_LogFile(null,"special");
specialLogFile.log('Salutations.');

// prints to:
// ./logs/default_2021-05-28T16-15-37.611.log >>[2021-05-28T16:15:37.612] default : Hey there.
// ./logs/special_2021-05-28T16-15-37.656.log >>[2021-05-28T16:15:37.657] special : Salutations.

Argument 3 : logDir (default: './logs/')

a non-"default" directory path to save the log to

root = $.global;// root to add convenience aliases to
logType = "special";// name other than "default"
logDir = '~/Desktop/mylogcabin/';// custom log directory

var myLogFile = new ExtendScript_LogFile(root, logType, logDir);
myLogFile.log('Salutations.');

// prints to:
// ~/Desktop/mylogcabin/special_2021-05-28T16-15-37.656.log >>[2021-05-28T16:15:37.657] special : Salutations.

Argument 3 : useDate (default: true)

specifies if the date should be prepended to the log entries can be changed with .useDate(false)

root = $.global;// root to add convenience aliases to
logType = "special";// name other than "default"
logDir = '~/Desktop/mylogcabin/';// custom log directory
useDate = false;

var myLogFile = new ExtendScript_LogFile(root, logType, logDir, useDate);

myLogFile.log('Salutations.');

// prints to:
// ~/Desktop/mylogcabin/special_2021-05-28T16-15-37.656.log >> special : Salutations.

Use the log file

.log() and .writeln() do the same thing...

.useDate(false) will disable the date printing in each entry

Attatch to namespace or other log object

myLogFile = new ExtendScript_Log($.global);
logFile.log('Messages are good.');

var namespace = {};// maybe some other log system?

myLogSafeFile = new ExtendScript_Log(namespace);
namespace.logFile.log('This is way safer.');

Cleanup

You can .clear() the contents or .remove() the file from disk.

You can also clear out of the same type with .removeOld() for non-current or .removeAll() for all.

myLogFile = new ExtendScript_Log();
logfile.log('Messages are good.');

myLogSafeFile = new ExtendScript_Log(namespace,'special');
namespace.logFile.log('This is way safer.');

myLogSafeFile.remove();

// make a bunch of "default" logs...
myLogFile = new ExtendScript_Log();
myLogFile = new ExtendScript_Log();
myLogFile = new ExtendScript_Log();
myLogFile = new ExtendScript_Log();

// purge all but latest "default" log.
myLogFile.removeOld();

// now only the current "default" file is left
myLogFile.removeAll();

myLogSafeFile = new ExtendScript_Log(namespace);

Bonus Features

Logs for unsaved scripts:

Tries to make a log file in ./logs in the location of the currently running script, but will fall back to ~/Desktop/ExtendScript_Log_UnsavedScripts/

Compatible with ExtendScript_Log:

This is used as a optional extra in ExtendScript_Log

Like peanutbutter and chocolate...