Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zschuessler/sketch-plugin-log
A utility class for managing output to the Mac system log from your Sketch plugin.
https://github.com/zschuessler/sketch-plugin-log
sketch sketch-app sketch-plugin sketchapp
Last synced: 3 months ago
JSON representation
A utility class for managing output to the Mac system log from your Sketch plugin.
- Host: GitHub
- URL: https://github.com/zschuessler/sketch-plugin-log
- Owner: zschuessler
- Created: 2017-03-07T17:52:36.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-18T19:14:50.000Z (almost 8 years ago)
- Last Synced: 2024-02-22T16:01:12.264Z (11 months ago)
- Topics: sketch, sketch-app, sketch-plugin, sketchapp
- Language: JavaScript
- Size: 7.81 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Sketch Plugin Log
A utility class for managing output to the Mac system log from your Sketch plugin.
## Install
Install it with `npm`, somewhere within your Sketch plugin folder.
```
npm install sketch-plugin-log
```## Usage
Import it into your Sketch plugin. Note the import path is relative to the running script!
##### ~/MyPlugin.sketchplugin/Contents/Sketch/app.cocoascript
```javascript
@import '../node_modules/sketch-plugin-log/index.js';function onRun(context) {
// Instantiate
var logger = new SketchPluginLog();
/**
* Set the Sketch context - required.
* Set the log prefix - optional.
*/
logger
.setContext(context)
.setLogPrefix('MyPluginName');
// Use it. See result in the Console app
logger.log('Hello there!');
// Dump a CocoaScript object. See result in the Console app.
var myCocoaScriptObject = WebView.new();
logger.log(myCocoaScriptObject);
// Dump an object to a debug file.
// Great for when Console app doesn't show all information.
// Set the debug file path with `setDebugLogPath` or defaults to {Your plugin root}/Sketch/debug/debug.log
logger.debugObject(myCocoaScriptObject);
}```
### Viewing Logs
See the tutorial below for becoming familiar with the Console app:
http://www.macworld.com/article/3102847/macs/hands-on-with-macos-sierras-console-now-its-easier-to-get-the-mac-information-you-need.html
Consider saving a custom search for "Message:MyPluginName". The "MyPluginName" is the log prefix set in the example.
Filtering based on this identifier leaves you with a clean look at all system logs, which only pertain to your plugin.## Roadmap / About
This library is a utility part of an upcoming book. Follow this repo for more information on release.
Additional features will be added for debugging in Sketch:
1. More intuitive display of CocoaScript objects with `debugObject`.