Skip to content

Commit

Permalink
Merge pull request #3 from SwiftMN/codesnippets
Browse files Browse the repository at this point in the history
Add code snippets and update documentation
  • Loading branch information
vlaminck authored Mar 11, 2020
2 parents 9f73830 + 8a71c85 commit c217821
Show file tree
Hide file tree
Showing 8 changed files with 220 additions and 1 deletion.
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,32 @@ and of course add `"EmojiLogHandler"` to your list target dependencies
.target(name: "SweetProjectName", dependencies: ["EmojiLogHandler"]),
```

### Using Xcode

File > Swift Packages > Add Package Dependency...

Paste the url for this project when prompted
```
https://github.com/SwiftMN/EmojiLogHandler
```

## Setup

In your AppDelegate or SceneDelegate, bootstrap an instance of `EmojiLogHandler`.

```swift
LoggingSystem.bootstrap { label in
EmojiLogHandler(label)
}
// make sure you bootstrap all handlers before setting logLevel
// logger.logLevel just forwards to the handlers that have been bootstrapped
logger.logLevel = .debug
```

Make sure you import the package, too
```swift
import EmojiLogHandler
```

## Usage

Expand All @@ -38,9 +64,20 @@ and of course add `"EmojiLogHandler"` to your list target dependencies
💩💩[ERROR] [FileName:50] This is an error level message
‼️‼️[CRITICAL] [FileName:51] This is a critical level message

### Finding the right emojis

1. clone this repo or just download the code snippets in [etc/CodeSnippets](etc/CodeSnippets)
1. run
```
cp etc/codeSnippets/* ~/Library/Developer/Xcode/UserData/CodeSnippets/
```
1. reopen Xcode and use the handy autocomplete code snippets. They match the log levels so just start typing `debug` and it will autofill for you. Super nice.
### Finding them the hard way
You can easily find these emojis by hitting `ctrl+cmd+space`. Once you use these they will be at the top of your list automatically. To find them the first time, hit `ctrl+cmd+space` and type "clipboard" to find 📋, "bug" to find "🐛", type "speak" to find "🗣", type "crash" to find "💥", and type "poop" to find "💩". I know what you're thinking... Why use the "crash" emoji for warn? Because the poop emoji is funnier. As in "Ahh shit! an error!"
### Customization
## Customization
You can easily make custom logging functions which makes your logging more expressive and allows you to easily filter your logs for your own debugging purposes.
Expand Down
26 changes: 26 additions & 0 deletions etc/CodeSnippets/EmojiLogHandler-critical.codesnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>critical</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
<key>IDECodeSnippetContents</key>
<string>!("&lt;#message#&gt;")</string>
<key>IDECodeSnippetIdentifier</key>
<string>DF6659FA-507D-4B80-8A21-B0DD540A9C56</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetSummary</key>
<string>critical log message</string>
<key>IDECodeSnippetTitle</key>
<string>!("&lt;#message#&gt;")</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>0</integer>
</dict>
</plist>
26 changes: 26 additions & 0 deletions etc/CodeSnippets/EmojiLogHandler-debug.codesnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>debug</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
<key>IDECodeSnippetContents</key>
<string>🐛("&lt;#message#&gt;")</string>
<key>IDECodeSnippetIdentifier</key>
<string>AD2BACE3-BF94-4A2B-908E-0FD8E9072FC5</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetSummary</key>
<string>debug log message</string>
<key>IDECodeSnippetTitle</key>
<string>🐛("&lt;#message#&gt;")</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>0</integer>
</dict>
</plist>
26 changes: 26 additions & 0 deletions etc/CodeSnippets/EmojiLogHandler-error.codesnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>error</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
<key>IDECodeSnippetContents</key>
<string>💩("&lt;#message#&gt;")</string>
<key>IDECodeSnippetIdentifier</key>
<string>92398206-A507-4E0A-A55E-BA48E8ED7915</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetSummary</key>
<string>error log message</string>
<key>IDECodeSnippetTitle</key>
<string>💩("&lt;#message#&gt;")</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>0</integer>
</dict>
</plist>
26 changes: 26 additions & 0 deletions etc/CodeSnippets/EmojiLogHandler-info.codesnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>info</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
<key>IDECodeSnippetContents</key>
<string>🗣("&lt;#message#&gt;")</string>
<key>IDECodeSnippetIdentifier</key>
<string>CB8676FF-3BA8-42BA-A19F-D681D48744F2</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetSummary</key>
<string>info log</string>
<key>IDECodeSnippetTitle</key>
<string>🗣("&lt;#message#&gt;")</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>0</integer>
</dict>
</plist>
26 changes: 26 additions & 0 deletions etc/CodeSnippets/EmojiLogHandler-notice.codesnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>notice</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
<key>IDECodeSnippetContents</key>
<string>👀("&lt;#message#&gt;")</string>
<key>IDECodeSnippetIdentifier</key>
<string>3A15EDE7-2FC7-4F1E-8AB6-E35A7839E9E9</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetSummary</key>
<string>notice log message</string>
<key>IDECodeSnippetTitle</key>
<string>👀("&lt;#message#&gt;")</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>0</integer>
</dict>
</plist>
26 changes: 26 additions & 0 deletions etc/CodeSnippets/EmojiLogHandler-trace.codesnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>trace</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
<key>IDECodeSnippetContents</key>
<string>📋("&lt;#message#&gt;")</string>
<key>IDECodeSnippetIdentifier</key>
<string>5101C76E-B50F-46FF-8D7A-8FA1F493E078</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetSummary</key>
<string>trace log message</string>
<key>IDECodeSnippetTitle</key>
<string>📋("&lt;#message#&gt;")</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>0</integer>
</dict>
</plist>
26 changes: 26 additions & 0 deletions etc/CodeSnippets/EmojiLogHandler-warning.codesnippet
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDECodeSnippetCompletionPrefix</key>
<string>warn</string>
<key>IDECodeSnippetCompletionScopes</key>
<array>
<string>All</string>
</array>
<key>IDECodeSnippetContents</key>
<string>💥("&lt;#message#&gt;")</string>
<key>IDECodeSnippetIdentifier</key>
<string>363137D8-4CD0-4866-9411-ACDE14EC951E</string>
<key>IDECodeSnippetLanguage</key>
<string>Xcode.SourceCodeLanguage.Swift</string>
<key>IDECodeSnippetSummary</key>
<string>warning log message</string>
<key>IDECodeSnippetTitle</key>
<string>💥("&lt;#message#&gt;")</string>
<key>IDECodeSnippetUserSnippet</key>
<true/>
<key>IDECodeSnippetVersion</key>
<integer>0</integer>
</dict>
</plist>

0 comments on commit c217821

Please sign in to comment.