-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxcodecolors.html
382 lines (358 loc) · 20.7 KB
/
xcodecolors.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
<!DOCTYPE html>
<html lang="en">
<head>
<title>XcodeColors Reference</title>
<link rel="stylesheet" type="text/css" href="css/jazzy.css" />
<link rel="stylesheet" type="text/css" href="css/highlight.css" />
<meta charset='utf-8'>
<script src="js/jquery.min.js" defer></script>
<script src="js/jazzy.js" defer></script>
<script src="js/lunr.min.js" defer></script>
<script src="js/typeahead.jquery.js" defer></script>
<script src="js/jazzy.search.js" defer></script>
</head>
<body>
<a title="XcodeColors Reference"></a>
<header>
<div class="content-wrapper">
<p><a href="index.html">CocoaLumberjack 3.7.0 Docs</a> (64% documented)</p>
<p class="header-right"><a href="https://github.com/CocoaLumberjack/CocoaLumberjack"><img src="img/gh.png"/>View on GitHub</a></p>
<p class="header-right">
<form role="search" action="search.json">
<input type="text" placeholder="Search documentation" data-typeahead>
</form>
</p>
</div>
</header>
<div class="content-wrapper">
<p id="breadcrumbs">
<a href="index.html">CocoaLumberjack Reference</a>
<img id="carat" src="img/carat.png" />
XcodeColors Reference
</p>
</div>
<div class="content-wrapper">
<nav class="sidebar">
<ul class="nav-groups">
<li class="nav-group-name">
<a href="Guides.html">Guides</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="arc.html">ARC</a>
</li>
<li class="nav-group-task">
<a href="appcode-support.html">AppCode-support</a>
</li>
<li class="nav-group-task">
<a href="architecture.html">Architecture</a>
</li>
<li class="nav-group-task">
<a href="combineloggers.html">CombineLoggers</a>
</li>
<li class="nav-group-task">
<a href="customcontext.html">CustomContext</a>
</li>
<li class="nav-group-task">
<a href="customformatters.html">CustomFormatters</a>
</li>
<li class="nav-group-task">
<a href="customloglevels.html">CustomLogLevels</a>
</li>
<li class="nav-group-task">
<a href="customloggers.html">CustomLoggers</a>
</li>
<li class="nav-group-task">
<a href="dynamicloglevels.html">DynamicLogLevels</a>
</li>
<li class="nav-group-task">
<a href="faq.html">FAQ</a>
</li>
<li class="nav-group-task">
<a href="finegrainedlogging.html">FineGrainedLogging</a>
</li>
<li class="nav-group-task">
<a href="gettingstarted.html">GettingStarted</a>
</li>
<li class="nav-group-task">
<a href="logfilemanagement.html">LogFileManagement</a>
</li>
<li class="nav-group-task">
<a href="perloggerloglevels.html">PerLoggerLogLevels</a>
</li>
<li class="nav-group-task">
<a href="peruserloglevels.html">PerUserLogLevels</a>
</li>
<li class="nav-group-task">
<a href="performance.html">Performance</a>
</li>
<li class="nav-group-task">
<a href="problemsolution.html">ProblemSolution</a>
</li>
<li class="nav-group-task">
<a href="readme.html">README</a>
</li>
<li class="nav-group-task">
<a href="xcodecolors.html">XcodeColors</a>
</li>
<li class="nav-group-task">
<a href="xcodetricks.html">XcodeTricks</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Classes.html">Classes</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Classes/CLIColor.html">CLIColor</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDASLLogCapture.html">DDASLLogCapture</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDASLLogger.html">DDASLLogger</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDAbstractDatabaseLogger.html">DDAbstractDatabaseLogger</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDAbstractLogger.html">DDAbstractLogger</a>
</li>
<li class="nav-group-task">
<a href="Classes.html#/c:objc(cs)DDAtomicCounter">DDAtomicCounter</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDContextBlacklistFilterLogFormatter.html">DDContextBlacklistFilterLogFormatter</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDContextWhitelistFilterLogFormatter.html">DDContextWhitelistFilterLogFormatter</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDDispatchQueueLogFormatter.html">DDDispatchQueueLogFormatter</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDFileLogger.html">DDFileLogger</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDLog.html">DDLog</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDLogFileFormatterDefault.html">DDLogFileFormatterDefault</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDLogFileInfo.html">DDLogFileInfo</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDLogFileManagerDefault.html">DDLogFileManagerDefault</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDLogMessage.html">DDLogMessage</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDLoggerInformation.html">DDLoggerInformation</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDMultiFormatter.html">DDMultiFormatter</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDOSLogger.html">DDOSLogger</a>
</li>
<li class="nav-group-task">
<a href="Classes/DDTTYLogger.html">DDTTYLogger</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Constants.html">Constants</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Constants.html#/c:@CocoaLumberjackVersionNumber">CocoaLumberjackVersionNumber</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@CocoaLumberjackVersionString">CocoaLumberjackVersionString</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@DDLoggerNameASL">DDLoggerNameASL</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@DDLoggerNameFile">DDLoggerNameFile</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@DDLoggerNameOS">DDLoggerNameOS</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@DDLoggerNameTTY">DDLoggerNameTTY</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@DDQualityOfServiceBackground">DDQualityOfServiceBackground</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@DDQualityOfServiceDefault">DDQualityOfServiceDefault</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@DDQualityOfServiceUnspecified">DDQualityOfServiceUnspecified</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@DDQualityOfServiceUserInitiated">DDQualityOfServiceUserInitiated</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@DDQualityOfServiceUserInteractive">DDQualityOfServiceUserInteractive</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@DDQualityOfServiceUtility">DDQualityOfServiceUtility</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@kDDASLDDLogValue">kDDASLDDLogValue</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@kDDASLKeyDDLog">kDDASLKeyDDLog</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@kDDDefaultLogFilesDiskQuota">kDDDefaultLogFilesDiskQuota</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@kDDDefaultLogMaxFileSize">kDDDefaultLogMaxFileSize</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@kDDDefaultLogMaxNumLogFiles">kDDDefaultLogMaxNumLogFiles</a>
</li>
<li class="nav-group-task">
<a href="Constants.html#/c:@kDDDefaultLogRollingFrequency">kDDDefaultLogRollingFrequency</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Enums.html">Enumerations</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Enums/DDDispatchQueueLogFormatterMode.html">DDDispatchQueueLogFormatterMode</a>
</li>
<li class="nav-group-task">
<a href="Enums/DDLogFlag.html">DDLogFlag</a>
</li>
<li class="nav-group-task">
<a href="Enums/DDLogLevel.html">DDLogLevel</a>
</li>
<li class="nav-group-task">
<a href="Enums/DDLogMessageOptions.html">DDLogMessageOptions</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Protocols.html">Protocols</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Protocols/DDAtomicCountable.html">DDAtomicCountable</a>
</li>
<li class="nav-group-task">
<a href="Protocols/DDLogFileManager.html">DDLogFileManager</a>
</li>
<li class="nav-group-task">
<a href="Protocols/DDLogFormatter.html">DDLogFormatter</a>
</li>
<li class="nav-group-task">
<a href="Protocols/DDLogger.html">DDLogger</a>
</li>
<li class="nav-group-task">
<a href="Protocols/DDRegisteredDynamicLogging.html">DDRegisteredDynamicLogging</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Type%20Definitions.html">Type Definitions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Type%20Definitions.html#/c:DDTTYLogger.h@T@DDColor">DDColor</a>
</li>
<li class="nav-group-task">
<a href="Type%20Definitions.html#/c:DDLoggerNames.h@T@DDLoggerName">DDLoggerName</a>
</li>
<li class="nav-group-task">
<a href="Type%20Definitions.html#/c:DDDispatchQueueLogFormatter.h@T@DDQualityOfServiceName">DDQualityOfServiceName</a>
</li>
</ul>
</li>
<li class="nav-group-name">
<a href="Functions.html">Functions</a>
<ul class="nav-group-tasks">
<li class="nav-group-task">
<a href="Functions.html#/c:@F@DDExtractFileNameWithoutExtension">DDExtractFileNameWithoutExtension</a>
</li>
<li class="nav-group-task">
<a href="Functions.html#/c:DDTTYLogger.h@F@DDMakeColor">DDMakeColor</a>
</li>
</ul>
</li>
</ul>
</nav>
<article class="main-content">
<section>
<section class="section">
<p>It’s sometimes helpful to color-coordinate your log messages. For example, you may want your error messages to print in red so they stick out.<br>
This is possible with <code><a href="Classes/DDTTYLogger.html">DDTTYLogger</a></code> and <strong>XcodeColors</strong>.</p>
<p><a href="http://www.flickr.com/photos/100714763@N06/9576120087/" title="Screen Shot 2013-08-23 at 10.30.09 AM by robbiehanson, on Flickr"><img src="http://farm4.staticflickr.com/3755/9576120087_bf2a3cae91_c.jpg" width="800" height="568" alt="Screen Shot 2013-08-23 at 10.30.09 AM"></a></p>
<h2 id='install-xcodecolors' class='heading'>Install XcodeColors</h2>
<p><strong>XcodeColors</strong> is a simple plugin for Xcode.<br>
It allows you to use colors in the Xcode debugging console.</p>
<p>Full installation instructions can be found on the XcodeColors project page:<br>
<a href="https://github.com/robbiehanson/XcodeColors">https://github.com/robbiehanson/XcodeColors</a></p>
<p>But here’s a summary:</p>
<ul>
<li>Download the plugin</li>
<li>Slap it into the Xcode Plug-ins directory</li>
<li>Restart Xcode</li>
</ul>
<h2 id='enable-colors' class='heading'>Enable Colors</h2>
<p>All it takes is one extra line of code to enable colors in Lumberjack:</p>
<pre class="highlight objective_c"><code><span class="c1">// Standard lumberjack initialization
</span><span class="p">[</span><span class="n">DDLog</span> <span class="nf">addLogger</span><span class="p">:[</span><span class="n">DDTTYLogger</span> <span class="nf">sharedInstance</span><span class="p">]];</span>
<span class="c1">// And we also enable colors
</span><span class="p">[[</span><span class="n">DDTTYLogger</span> <span class="nf">sharedInstance</span><span class="p">]</span> <span class="nf">setColorsEnabled</span><span class="p">:</span><span class="nb">YES</span><span class="p">];</span>
</code></pre>
<p>The <strong>default color scheme</strong> (if you don’t customize it) is:</p>
<ul>
<li><code>DDLogError</code> : Prints in red</li>
<li><code>DDLogWarn</code> : Prints in orange</li>
</ul>
<p>However, <strong>you can fully customize the color schemes</strong> however you like!<br>
In fact, you can customize the foreground and/or background colors.<br>
And you can specify any RGB value you’d like.</p>
<pre class="highlight objective_c"><code><span class="c1">// Let's customize our colors.
// DDLogInfo : Pink
</span>
<span class="cp">#if TARGET_OS_IPHONE
</span><span class="n">UIColor</span> <span class="o">*</span><span class="n">pink</span> <span class="o">=</span> <span class="p">[</span><span class="n">UIColor</span> <span class="nf">colorWithRed</span><span class="p">:(</span><span class="mi">255</span><span class="o">/</span><span class="mi">255</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span> <span class="nf">green</span><span class="p">:(</span><span class="mi">58</span><span class="o">/</span><span class="mi">255</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span> <span class="n">blue</span><span class="o">:</span><span class="p">(</span><span class="mi">159</span><span class="o">/</span><span class="mi">255</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span> <span class="n">alpha</span><span class="o">:</span><span class="mi">1</span><span class="p">.</span><span class="mi">0</span><span class="p">];</span>
<span class="cp">#else
</span><span class="n">NSColor</span> <span class="o">*</span><span class="n">pink</span> <span class="o">=</span> <span class="p">[</span><span class="n">NSColor</span> <span class="nf">colorWithCalibratedRed</span><span class="p">:(</span><span class="mi">255</span><span class="o">/</span><span class="mi">255</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span> <span class="nf">green</span><span class="p">:(</span><span class="mi">58</span><span class="o">/</span><span class="mi">255</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span> <span class="n">blue</span><span class="o">:</span><span class="p">(</span><span class="mi">159</span><span class="o">/</span><span class="mi">255</span><span class="p">.</span><span class="mi">0</span><span class="p">)</span> <span class="n">alpha</span><span class="o">:</span><span class="mi">1</span><span class="p">.</span><span class="mi">0</span><span class="p">];</span>
<span class="cp">#endif
</span>
<span class="p">[[</span><span class="n">DDTTYLogger</span> <span class="nf">sharedInstance</span><span class="p">]</span> <span class="nf">setForegroundColor</span><span class="p">:</span><span class="n">pink</span> <span class="nf">backgroundColor</span><span class="p">:</span><span class="nb">nil</span> <span class="n">forFlag</span><span class="o">:</span><span class="n">DDLogFlagInfo</span><span class="p">];</span>
<span class="n">DDLogInfo</span><span class="p">(</span><span class="s">@"Warming up printer"</span><span class="p">);</span> <span class="c1">// Prints in Pink !
</span></code></pre>
<h2 id='xcodecolors-and-ios' class='heading'>XcodeColors and iOS</h2>
<p>You may occasionally notice that colors don’t work when you’re debugging your app in the simulator. And you may also notice that your colors never work when debugging on the actual device. How do I fix it so it works everywhere, all the time?</p>
<p>You can fix it in a few seconds. Here’s how.</p>
<ul>
<li>In Xcode bring up the Scheme Editor (Product -> Edit Scheme…)</li>
<li>Select “Run” (on the left), and then the “Arguments” tab</li>
<li>Add a new Environment Variable named “XcodeColors”, with a value of “YES”</li>
</ul>
<p><a href="http://www.flickr.com/photos/100714763@N06/9578924278/" title="Screen Shot 2013-08-23 at 10.32.59 AM by robbiehanson, on Flickr"><img src="http://farm6.staticflickr.com/5330/9578924278_1aa7431003_c.jpg" width="800" height="530" alt="Screen Shot 2013-08-23 at 10.32.59 AM"></a></p>
<p>Your colors should now work on the simulator and on the device, every single time.</p>
<h3 id='more-information' class='heading'>More information:</h3>
<p>The XcodeColors plugin is automatically loaded by Xcode when Xcode launches. When XcodeColors runs, it sets the environment variable “XcodeColors” to “YES”. Thus the Xcode application itself has this environment variable set. </p>
<p>It is this environment variable that Lumberjack uses to detect whether XcodeColors is installed or not. Because if Lumberjack injects color information when XcodeColors isn’t installed, then your log statements have a bunch of garbage characters in them. </p>
<p>Now any application that Xcode launches inherits the environment variables from Xcode. So if you hit build-and-go, and Xcode launches the simulator for you automatically, then the colors will work. But if you manually launch the simulator, then it doesn’t inherit environment variables from Xcode (because Xcode isn’t the process’ parent in this case). It’s a similar problem when debugging on the actual device.</p>
<h2 id='colors-in-the-terminal' class='heading'>Colors in the Terminal</h2>
<p>If you ever do any debugging in the Terminal, then you’re in luck! <strong>DDTTYLogger supports color in terminals as well.</strong></p>
<p>If your shell supports color, the DDTTYLogger will automatically map your requested colors to the closest supported color by your shell. In most cases your terminal will be “xterm-256color”, so your terminal will support 256 different colors, and you’ll get a close match for whatever RGB values you configure.</p>
</section>
</section>
<section id="footer">
<p>© 2020 <a class="link" href="https://github.com/CocoaLumberjack/CocoaLumberjack" target="_blank" rel="external">CocoaLumberjack</a>. All rights reserved. (Last updated: 2020-11-21)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.6</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
</div>
</body>
</div>
</html>