]> git.saurik.com Git - apple/syslog.git/blob - libsystem_asl.tproj/man/asl.3
ef93ed9c5a9f156d9cb15110b88414b0f9930090
[apple/syslog.git] / libsystem_asl.tproj / man / asl.3
1 .\" Copyright (c) 2005-2012 Apple Inc.
2 .\" All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of Apple Computer nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"
29 .Dd October 1, 2011
30 .Dt asl 3
31 .Os "Mac OS X"
32 .Sh NAME
33 .Nm asl_add_log_file ,
34 .Nm asl_add_outout_file ,
35 .Nm asl_close ,
36 .Nm asl_close_auxiliary_file ,
37 .Nm asl_create_auxiliary_file ,
38 .Nm asl_free ,
39 .Nm asl_get ,
40 .Nm asl_key ,
41 .Nm asl_log ,
42 .Nm asl_log_auxiliary_location ,
43 .Nm asl_log_descriptor ,
44 .Nm asl_new ,
45 .Nm asl_open ,
46 .Nm asl_open_from_file ,
47 .Nm asl_remove_log_file ,
48 .Nm asl_search ,
49 .Nm asl_send ,
50 .Nm asl_set ,
51 .Nm asl_set_filter ,
52 .Nm asl_set_output_file_filter ,
53 .Nm asl_set_query ,
54 .Nm asl_unset ,
55 .Nm asl_vlog ,
56 .Nm aslresponse_free ,
57 .Nm aslresponse_next
58 .Nd system log message sending and searching functions
59 .Sh SYNOPSIS
60 .Fd #include <asl.h>
61 .\"
62 .Ft int
63 .Fo asl_add_log_file
64 .Fa "aslclient asl"
65 .Fa "int descriptor"
66 .Fc
67 .Ft int
68 .Fo asl_add_output_file
69 .Fa "aslclient asl"
70 .Fa "int descriptor"
71 .Fa "const char *msg_fmt"
72 .Fa "const char *time_fmt"
73 .Fa "int filter"
74 .Fa "int text_encoding"
75 .Fc
76 .Ft void
77 .Fo asl_close
78 .Fa "aslclient asl"
79 .Fc
80 .Ft void
81 .Fo asl_close_auxiliary_file
82 .Fa "int descriptor"
83 .Fc
84 .Ft void
85 .Fo asl_create_auxiliary_file
86 .Fa "aslmsg msg"
87 .Fa "const char *title"
88 .Fa "const char *uti"
89 .Fa "int *out_descriptor"
90 .Fc
91 .Ft void
92 .Fo asl_free
93 .Fa "aslmsg msg"
94 .Fc
95 .Ft const char *
96 .Fo asl_get
97 .Fa "aslmsg msg"
98 .Fa "const char *key"
99 .Fc
100 .Ft const char *
101 .Fo asl_key
102 .Fa "aslmsg msg"
103 .Fa "uint32_t n"
104 .Fc
105 .Ft int
106 .Fo asl_log
107 .Fa "aslclient asl"
108 .Fa "aslmsg msg"
109 .Fa "int level"
110 .Fa "const char *format"
111 .Fa "..."
112 .Fc
113 .Ft void
114 .Fo asl_log_auxiliary_location
115 .Fa "aslmsg msg"
116 .Fa "const char *title"
117 .Fa "const char *uti"
118 .Fa "const char *url"
119 .Fc
120 .Ft int
121 .Fo asl_log_descriptor
122 .Fa "aslclient asl"
123 .Fa "aslmsg msg"
124 .Fa "int level"
125 .Fa "int descriptor"
126 .Fa "uint32_t fd_type"
127 .Fc
128 .Ft aslmsg
129 .Fo asl_new
130 .Fa "uint32_t type"
131 .Fc
132 .Ft aslclient
133 .Fo asl_open
134 .Fa "const char *ident"
135 .Fa "const char *facility"
136 .Fa "uint32_t opts"
137 .Fc
138 .Ft aslclient
139 .Fo asl_open_from_file
140 .Fa "int descriptor"
141 .Fa "const char *ident"
142 .Fa "const char *facility"
143 .Fc
144 .Ft int
145 .Fo asl_remove_log_file
146 .Fa "aslclient asl"
147 .Fa "int descriptor"
148 .Fc
149 .Ft aslresponse
150 .Fo asl_search
151 .Fa "aslclient asl"
152 .Fa "aslmsg msg"
153 .Fc
154 .Ft int
155 .Fo asl_send
156 .Fa "aslclient asl"
157 .Fa "aslmsg msg"
158 .Fc
159 .Ft int
160 .Fo asl_set
161 .Fa "aslmsg msg"
162 .Fa "const char *key"
163 .Fa "const char *value"
164 .Fc
165 .Ft int
166 .Fo asl_set_filter
167 .Fa "aslclient asl"
168 .Fa "int filter"
169 .Fc
170 .Ft int
171 .Fo asl_set_output_file_filter
172 .Fa "aslclient asl"
173 .Fa "int descriptor"
174 .Fa "int filter"
175 .Fc
176 .Ft int
177 .Fo asl_set_query
178 .Fa "aslmsg msg"
179 .Fa "const char *key"
180 .Fa "const char *value"
181 .Fa "uint32_t op"
182 .Fc
183 .Ft int
184 .Fo asl_unset
185 .Fa "aslmsg msg"
186 .Fa "const char *key"
187 .Fc
188 .Ft int
189 .Fo asl_vlog
190 .Fa "aslclient asl"
191 .Fa "aslmsg msg"
192 .Fa "int level"
193 .Fa "const char *format"
194 .Fa "va_list ap"
195 .Fc
196 .Ft void
197 .Fo aslresponse_free
198 .Fa "aslresponse r"
199 .Fc
200 .Ft aslmsg
201 .Fo aslresponse_next
202 .Fa "aslresponse r"
203 .Fc
204 .Sh DESCRIPTION
205 These routines provide an interface to the Apple System Log facility.
206 They are intended to be a replacement for the
207 .Xr syslog 3
208 API, which will continue to be supported for backwards compatibility.
209 The new API allows client applications
210 to create flexible, structured messages and send them to the
211 .Nm syslogd
212 server, where they may undergo additional processing.
213 Messages received by the server are saved in a data store
214 (subject to input filtering constraints).
215 This API permits clients to create queries
216 and search the message data store for matching messages.
217 .Pp
218 An introduction to the concepts underlying this interface follows the interface summary below.
219 .Ss INTERFACE SUMMARY
220 .Fo asl_open
221 .Fa ident
222 .Fa facility
223 .Fa opts
224 .Fc
225 creates and returns a client handle, or NULL if an error occurs in the library.
226 Messages sent using this handle will default to having the string
227 .Ar ident
228 as the value associated with the ASL_KEY_SENDER key, and the value
229 .Ar facility
230 associated with the ASL_KEY_FACILITY key.
231 Several options are available, as described in the
232 .Sx CLIENT HANDLES
233 section.
234 .Pp
235 Each client handle holds state information that is used when a message is logged using that handle.
236 This information includes the
237 .Ar ident
238 and
239 .Ar facility
240 strings and the options from the
241 .Ar opts
242 parameter.
243 Client handles also contain various filter, file descriptor, and control data.
244 .Pp
245 The state information in a client handle is not protected by any locking or thread synchronization mechanism.
246 It is not safe for two or more threads to use a single client handle simultaneously.
247 Multi-threaded applications should generally create one client handle for each thread that logs messages.
248 A client handle may only be safely shared amongst multiple threads if the application uses locks or some
249 synchronization strategy to ensure single-threaded access.
250 .Pp
251 As a special case, the ASL library allows the use of NULL in place of a client handle.
252 In this case, the library uses an internal structure which contains its own lock.
253 Multiple threads may safely use NULL, although there may be contention for the lock.
254 .Pp
255 Applications that use libdispatch may use NULL in place of a client handle,
256 although this may cause undesirable synchronization behavior and degraded performance because of lock contention.
257 A better design is often to use one or more serial dispatch queues specifically for logging.
258 Each such serial queue should use a separate client handle.
259 .Pp
260 .Fo asl_close
261 .Fa asl
262 .Fc
263 closes the client handle
264 .Ar asl
265 and releases its associated resources.
266 .Pp
267 .Fo asl_add_output_file
268 .Fa asl
269 .Fa descriptor
270 .Fa msg_fmt
271 .Fa time_fmt
272 .Fa filter
273 .Fa text_encoding
274 .Fc
275 adds the file descriptor
276 .Ar descriptor
277 to the a set of file descriptors associated with the client handle
278 .Ar asl .
279 Each log message sent by that client handle is also written to these file descriptors
280 (depending on the setting of the
281 .Ar filter
282 argument).
283 The message format is specified by the
284 .Ar msg_fmt
285 argument.
286 The format for timestamps is specified by the
287 .Ar time_fmt
288 argument, although custom format strings may specify more advanced formats for timestamps.
289 Details on custom format strings are below.
290 .Pp
291 Each output file has an associated
292 .Ar filter
293 value.
294 The filter determines which messages are formatted and written to the file based on the message priority level.
295 .Pp
296 Special handling for certain characters is specified by the
297 .Ar text_encoding
298 argument.
299 The supported values and their effect are described below.
300 .Pp
301 The
302 .Ar msg_format
303 argument is a character string that tells the library how to format each message written to the output file.
304 There are several pre-defined message formats, described below.
305 Custom formats are also supported,
306 giving complete control over which ASL message keys should be written
307 and the overall format of each output line.
308 The pre-defined formats are identified by constants in the asl.h header file.
309 .Pp
310 .Bl -tag -width "ASL_MSG_FMT_RAW" -compact
311 .It ASL_MSG_FMT_RAW
312 The contents of the ASL message dictionaries are formatted as a list,
313 with each key-value pair formatted as
314 .Dq [Key Value] .
315 .Pp
316 .It ASL_MSG_FMT_STD
317 Messages are formatted using the standard ASL message format of the form
318 .Pp
319 .Dl Time Host Sender[PID] <Level>: Message
320 .Pp
321 Time formats are described below.
322 .Pp
323 .It ASL_MSG_FMT_BSD
324 The legacy format used for plain-text log files.
325 Similar to the ASL_MSG_FMT_STD format, but the message priority level is excluded.
326 .Pp
327 .It ASL_MSG_FMT_MSG
328 The output line contains only the value of the Message key in each ASL message dictionary.
329 .Pp
330 .It ASL_MSG_FMT_XML
331 Produces multiple lines of output for each ASL message.
332 The message is formatted as an XML dictionary:
333 .Pp
334 .Dl <dict>
335 .Dl \t<key>ASLMessageKey1</key>
336 .Dl \t<string>Key 1 Value</string>
337 .Dl \t<key>ASLMessageKey2</key>
338 .Dl \t<string>Key 2 Value</string>
339 .Dl \t\t...
340 .Dl </dict>
341 .Pp
342 .El
343 .Pp
344 A NULL value for
345 .Ar msg_fmt
346 causes the library to use the
347 .Dq std
348 format.
349 .Pp
350 Custom format strings may contain a mix of characters that are directly copied to the output line
351 and variables, which are a dollar sign
352 .Sq $
353 followed by specific ASL message dictionary keys, whose values will be interpolated into the output.
354 For example, the format string:
355 .Pp
356 .Dl This message from $Sender PID=$PID at $Time *** $Message
357 .Pp
358 would result in lines in the output file like, e.g.:
359 .Pp
360 .Dl This message from login PID=982 at Jul 27 08:41:27 *** USER_PROCESS: 330 ttys000
361 .Dl This message from Mail PID=987 at Jul 27 08:42:16 *** Using V2 Layout
362 .Pp
363 Normally, a space character terminates a variable name.
364 However, the name may be wrapped in parentheses if a space character is not desired in the output.
365 For example:
366 .Pp
367 .Dl $(Sender)[$(PID)]: $Message
368 .Pp
369 A third form for specifying variables may be used for the ASL
370 .Dq Level
371 and
372 .Dq Time
373 message keys.
374 Note that a
375 .Dq Time
376 specification using one of the forms below will override the
377 .Ar time_fmt
378 argument to the function.
379 .Pp
380 The following forms are recognized:
381 .Pp
382 .Bl -tag -width "$((Time)([+|-]HH[:MM]))"
383 .It $((Level)(str))
384 Formats a Level value as a string, for example
385 .Dq Error ,
386 .Dq Alert ,
387 .Dq Warning ,
388 and so on.
389 Note that $(Level) or $Level formats the value as an integer 0 through 7.
390 .It $((Time)(sec))
391 Formats a Time value as the number of seconds since the Epoch.
392 .It $((Time)(raw))
393 Alias for $((Time)(sec)).
394 .It $((Time)(local))
395 Formats a Time value as a string of the form
396 .Dq "Mmm dd hh:mm:ss" ,
397 where Mmm is the abbreviation for the month, dd is the date (1 - 31) and hh:mm:ss is the time.
398 The local timezone is used.
399 .It $((Time)(lcl))
400 Alias for $((Time)(local)).
401 .It $((Time)(utc))
402 Formats a Time value as a string of the form
403 .Dq "yyyy-mm-dd hh:mm:ssZ" ,
404 using Coordinated Universal Time, or the
405 .Dq Zulu
406 time zone.
407 .It $((Time)(zulu))
408 Alias for $((Time)(utc)).
409 .It $((Time)(X))
410 Where X may be any letter in the range A - Z or a - z.
411 Formats the Time using the format
412 .Dq "yyyy-mm-dd hh:mm:ssX" ,
413 using the specified nautical timezone.
414 Z is the same as UTC/Zulu time. Timezones A - M (except J) decrease by one hour to the east of the
415 Zulu time zone.
416 Timezones N - Y increase by one hour to the west of Z.
417 M and Y have the same clock time, but differ by one day.
418 J is used to indicate the local timezone.
419 When printing using $((Time)(J)), the output format is
420 .Dq "yyyy-mm-dd hh:mm:ss" ,
421 without a trailing timezone letter.
422 .It $((Time)(JZ))
423 Specifies the local timezone.
424 The timezone offset from UTC follows the date and time.
425 The time is formatted as
426 .Dq "yyyy-mm-dd hh:mm:ss[+|-]HH[:MM]" .
427 Minutes in the timezone offset are only printed if they are non-zero.
428 .It $((Time)(ISO8601))
429 Specifies the local timezone, formatted as specified by ISO 8601.
430 The timezone offset from UTC follows the date and time.
431 The time is formatted as
432 .Dq "yyyy-mm-ddThh:mm:ss[+|-]HH[:MM]" .
433 Minutes in the timezone offset are only printed if they are non-zero.
434 Note that this differs from
435 .Dq JZ
436 format only in that a
437 .Dq T
438 character separates the date and time.
439 .It $((Time)([+|-]HH[:MM]))
440 Specifies an offset (+ or -) of the indicated number of hours (HH) and optionally minutes (MM) to UTC.
441 The value is formatted as a string of the form
442 .Dq "yyyy-mm-dd hh:mm:ss[+|-]HH[:MM]" .
443 Minutes in the timezone offset are only printed if they are non-zero.
444 .El
445 .Pp
446 Unless a custom message format uses one of the specialized forms for
447 .Dq Time
448 described above, then any timestamps in an output message will be formatted according the the
449 .Ar time_fmt
450 argument.
451 The known formats are identified by constants in the asl.h header file.
452 .Pp
453 .Bl -tag -width "ASL_TIME_FMT_SEC"
454 .It ASL_TIME_FMT_SEC
455 Formats timestamps as the number of seconds since the Epoch.
456 .Pp
457 .It ASL_TIME_FMT_UTC
458 Formats a Time value as a string of the form
459 .Dq "yyyy-mm-dd hh:mm:ssZ" ,
460 using Coordinated Universal Time, or the
461 .Dq Zulu
462 time zone.
463 .It ASL_TIME_FMT_LCL
464 Formats a Time value as a string of the form
465 .Dq "Mmm dd hh:mm:ss" ,
466 where Mmm is the abbreviation for the month, dd is the date (1 - 31) and hh:mm:ss is the time.
467 The local timezone is used.
468 .El
469 .Pp
470 A value of NULL for the
471 .Ar time_fmt
472 argument will cause the default format ASL_TIME_FMT_LCL to be used.
473 .Pp
474 The
475 .Ar encoding
476 parameter specifies how certain characters are to be treated when preparing a message for output.
477 The known encodings are:
478 .Bl -tag -width "ASL_ENCODE_NONE"
479 .It ASL_ENCODE_NONE
480 No special character encode is done.
481 .Pp
482 .It ASL_ENCODE_ASL
483 Newlines and tabs are also encoded as "\\n" and "\\t" respectively.
484 In
485 .Dq ASL_MSG_FMT_RAW
486 format, space characters embedded in log message keys are encoded as "\\s"
487 and embedded brackets are escaped to print as "\\[" and "\\]".
488 .Pp
489 .It ASL_ENCODE_SAFE
490 Encodes backspace characters as ^H.
491 Carriage returns are mapped to newlines.
492 A tab character is appended after newlines so that message text is indented.
493 .Pp
494 .It ASL_ENCODE_XML
495 This encoding should be used when formatting messages using ASL_MSG_FMT_XML.
496 XML format output requires that keys are valid UTF8 strings.
497 Keys which are not valid UTF8 are ignored, and the associated value is not printed.
498 .Pp
499 Values that contain legal UTF8 are printed as strings.
500 Ampersand, less than, greater than, quotation mark, and apostrophe characters are encoded according to XML conventions.
501 Embedded control characters are encoded as
502 .Dq &#xNN;
503 where NN is the character's hexadecimal value.
504 .Pp
505 Values that do not contain legal UTF8 are encoded in base-64 and printed as data objects.
506 .El
507 .Pp
508 .Nm asl_add_output_file
509 Returns 0 on success, non-zero on failure.
510 .Pp
511 .Pp
512 .Fo asl_add_log_file
513 .Fa asl
514 .Fa descriptor
515 .Fc
516 Is equivalent to
517 .Pp
518 .Dl asl_add_output_file(asl, descriptor, ASL_MSG_FMT_STD, ASL_TIME_FMT_LCL, ASL_FILTER_MASK_UPTO(ASL_LEVEL_DEBUG), ASL_ENCODE_SAFE);
519 .Pp
520 Returns 0 on success, non-zero on failure.
521 .Pp
522 .Fo asl_set_output_file_filter
523 .Fa asl
524 .Fa descriptor
525 .Fa filter
526 .Fc
527 replaces the current filter value associated with a file descriptor that has been added to a client handle.
528 Returns the previous filter value.
529 .Pp
530 .Fo asl_remove_log_file
531 .Fa asl
532 .Fa descriptor
533 .Fc
534 removes a file descriptor from the set of file descriptors associated with a client handle.
535 Returns 0 on success, non-zero on failure.
536 .Pp
537 .Fo asl_new
538 .Fa type
539 .Fc
540 allocates and returns an aslmsg structure, or NULL in the case of a failure in the library.
541 The
542 .Ar type
543 argument must be ASL_TYPE_MSG or ASL_TYPE_QUERY.
544 .Pp
545 .Fo asl_free
546 .Fa msg
547 .Fc
548 frees an aslmsg and releases resources associated with the structure.
549 .Pp
550 .Fo asl_set
551 .Fa msg
552 .Fa key
553 .Fa value
554 .Fc
555 creates a new key and value in an aslmsg structure, or replaces the value of an existing key.
556 Returns 0 on success, non-zero on failure.
557 .Pp
558 .Fo asl_set_query
559 .Fa msg
560 .Fa key
561 .Fa op
562 .Fa value
563 .Fc
564 is used to construct searches.
565 It is similar to
566 .Fn asl_set ,
567 except that it takes an additional
568 .Ar op
569 (operation) argument.
570 Creates a new (key, op, value) triple in an aslmsg structure,
571 or replaces the value and operation for an existing key.
572 See the
573 .Sx SEARCHING
574 section for more information.
575 Returns 0 on success, non-zero on failure.
576 .Pp
577 .Fo asl_unset
578 .Fa msg
579 .Fa key
580 .Fc
581 removes a key and its associated value from an aslmsg structure.
582 Returns 0 on success, non-zero on failure.
583 .Pp
584 .Fo asl_key
585 .Fa msg
586 .Fa n
587 .Fc
588 returns the nth key in an aslmsg (beginning at zero),
589 allowing an application to iterate through the keys.
590 Returns NULL if
591 .Ar n
592 indexes beyond the number of keys in
593 .Ar msg .
594 .Pp
595 .Fo asl_get
596 .Fa msg
597 .Fa key
598 .Fc
599 returns the value associated with
600 .Ar key
601 in the aslmsg
602 .Ar msg .
603 Returns NULL if
604 .Ar msg
605 does not contain
606 . Ar key .
607 .Pp
608 .Fo asl_set_filter
609 .Fa asl
610 .Fa f
611 .Fc
612 sets a filter for messages being sent to the server.
613 The filter is a bitmask representing priority levels.
614 Only messages having a priority level with a corresponding bit set in the filter mask are sent to the
615 .Nm syslogd
616 server.
617 The filter does not control writes to additional files associated with the client handle using
618 .Fn asl_add_log_file .
619 Returns the previous filter value.
620 .Pp
621 .Fo asl_log
622 .Fa asl
623 .Fa msg
624 .Fa level
625 .Fa format
626 .Fa args...
627 .Fc
628 sends a log to the server (subject to filtering, see
629 .Fn asl_set_filter
630 above) and to any file descriptors associated with the client handle
631 .Ar asl .
632 The
633 .Ar msg
634 argument may contain any keys and values, which will be formatted as part of the log message.
635 The value for ASL_KEY_LEVEL is supplied by the
636 .Ar level
637 argument.
638 The value for ASL_KEY_MESSAGE is computed from
639 .Ar format
640 and the associated arguments
641 .Ar args... .
642 Normal
643 .Fn printf
644 style argument processing is applied to the format and the arguments.
645 The format may also contain
646 .Dq %m
647 which will be substituted with the string value corresponding to the current
648 .Em errno .
649 .Pp
650 The ASL_PREFILTER_LOG(asl, msg, level, format, ...) macro may be used in
651 place of
652 .Fn asl_log .
653 The macro avoids processing the variable argument list in those cases where
654 the message would be filtered out due to filter settings, would not be
655 written to a log file associated with the aslclient, or would not be
656 written to stderr.
657 The macro may provide a performance benefit for some applications.
658 Details on filter setting, additional log files, and aslclient options
659 are described below in this manual.
660 .Pp
661 .Fo asl_vlog
662 .Fa asl
663 .Fa msg
664 .Fa level
665 .Fa format
666 .Fa ap
667 .Fc
668 is similar to
669 .Fn asl_log
670 except that it takes a va_list argument.
671 .Pp
672 .Fo asl_send
673 .Fa asl
674 .Fa msg
675 .Fc
676 is similar to
677 .Fn asl_log ,
678 except the value for ASL_KEY_MESSAGE is taken from
679 .Ar msg
680 rather than being constructed using a
681 .Fn printf
682 style syntax.
683 .Pp
684 .Fo asl_log_descriptor
685 .Fa asl
686 .Fa msg
687 .Fa level
688 .Fa descriptor
689 .Fa fd_type
690 .Fc
691 provides functionality to use file descriptors to send logging data to ASL.
692 .Ar asl
693 is retained by ASL and must still be closed by the caller by calling
694 .Fn asl_close
695 if the caller loses reference to it.
696 .Ar msg
697 is copied by ASL and similarly must still be freed by the caller by calling
698 .Fn asl_free
699 if the caller loses reference to it. Any changes made to it after calling
700 .Fn asl_log_descriptor()
701 are not applicable to the message used.
702 .Ar descriptor is treated differently based on the value of
703 .Ar fd_type .
704 .Pp
705 If
706 .Ar fd_type
707 is ASL_LOG_DESCRIPTOR_READ, the descriptor must be open for read access. ASL
708 uses
709 .Xr dispatch 2
710 to read from the descriptor as data becomes available. These data are line
711 buffered and passed to
712 .Fn asl_log .
713 When EOF is read, ASL will
714 .Xr close 2
715 .Ar descriptor ..
716 .Pp
717 If
718 .Ar fd_type
719 is ASL_LOG_DESCRIPTOR_WRITE, the descriptor is closed and a new writable
720 descriptor is created with the same fileno. Any data written to this new
721 descriptor are line buffered and passed to
722 .Fn asl_log .
723 When EOF is sent, no further data are read. The caller is responsible for
724 closing the new descriptor. One common use for this API is to redirect writes
725 to stdout or stderr to ASL by passing STDOUT_FILENO or STDERR_FILENO as
726 .Ar descriptor .
727 .Pp
728 .Fo asl_search
729 .Fa asl
730 .Fa msg
731 .Fc
732 searches for messages that match the keys and values in
733 .Ar msg ,
734 subject to matching operations associated with those keys and values.
735 The
736 .Ar msg
737 argument should be constructed using
738 .Fn asl_set_query .
739 See the
740 .Sx SEARCHING
741 section for details on constructing queries.
742 Returns an aslresponse structure that contains matching log messages.
743 NULL is returned in case of error or if there are no matching messages in the ASL database.
744 .Pp
745 .Fo aslresponse_next
746 .Fa r
747 .Fc
748 iterates over an aslresponse structure returned by
749 .Fn asl_search .
750 Each call returns the next aslmsg in the response.
751 Returns NULL when there are no further messages.
752 .Pp
753 .Fo aslresponse_free
754 .Fa r
755 .Fc
756 frees the aslresponse structure
757 .Ar r
758 and all of its associated resources.
759 .Pp
760 .Fo asl_create_auxiliary_file
761 .Fa msg
762 .Fa title
763 .Fa uti
764 .Fa out_descriptor
765 .Fc
766 Creates an auxiliary file that may be used by the client to save arbitrary data.
767 When the file is closed using
768 .Fo asl_close_auxiliary_file
769 .Fc ,
770 .Nm syslogd
771 will log the specified
772 .Fa msg
773 along with the
774 .Fa title
775 and the Uniform Type Identifier provided by
776 .Fa uti .
777 If a NULL value is supplied for
778 .Fa uti
779 the type
780 .Dq public.data
781 will be used.
782 The
783 .Nm Console
784 application will display the message with a link to the file.
785 .Pp
786 Auxiliary files are saved in the ASL data store.
787 They are automatically deleted at the same time that the log message expires.
788 Messages expire in 7 days by default.
789 A value set for the ASLExpireTime key will override the default.
790 Read access for the auxiliary file will be the same as read access for
791 .Fa msg .
792 By default, messages (and auxiliary files) are world-readable.
793 Access may be limited by setting values for the ReadUID and ReadGID keys.
794 .Pp
795 .Fo asl_close_auxiliary_file
796 .Fa descriptor
797 .Fc
798 closes the file descriptor
799 .Ar descriptor
800 previously returned by a call to
801 .Fn asl_create_auxiliary_file .
802 .Pp
803 .Fo asl_log_auxiliary_location
804 .Fa msg
805 .Fa title
806 .Fa uti
807 .Fa url
808 .Fc
809 will log the specified
810 .Fa msg
811 along with the
812 .Fa title ,
813 the Uniform Type Identifier provided by
814 .Fa uti ,
815 and the Uniform Resource Locator provided by
816 .Fa url .
817 The
818 .Nm Console
819 application will display the message with a link to the file.
820 This allows a client to save data in an auxiliary file, but unlike
821 .Fo asl_create_auxiliary_file
822 .Fc ,
823 the life-cycle of this file must be managed by some external system.
824 The file will not be removed when the corresponding log message expired from the ASL data store.
825 .Pp
826 .Fo asl_open_from_file
827 .Fa descriptor
828 .Fa facility
829 .Fa opts
830 .Fc
831 creates a client handle for an open file descriptor
832 .Fa descriptor .
833 This routine may be used in conjunction with
834 .Fo asl_create_auxiliary_file
835 .Fc
836 or
837 .Fo asl_log_auxiliary_location
838 .Fc
839 to save ASL format log messages in an auxiliary file.
840 The UTI type
841 .Dq com.apple.asl-file
842 should be used for ASL format auxiliary files.
843 .Pp
844 Files with this format may be read from the command line using
845 .Nm syslog Fl f Ar file ,
846 or from the
847 .Nm Console
848 utility.
849 .Pp
850 The file must be open for read and write access.
851 The file will be truncated and its existing contents will be lost.
852 .Fo asl_close
853 .Fc
854 must be called to close the client handle when logging to this file is complete.
855 The file should be closed using
856 .Fo asl_close_auxiliary_file
857 .Fc
858 if it was returned by
859 .Fo asl_create_auxiliary_file
860 .Fc ,
861 or
862 .Fo close
863 .Fc
864 otherwise.
865 .Pp
866 The client handle returned by
867 .Fn asl_open_from_file
868 contains an internal lock, and may be used safely by multiple threads or from independent dispatch queues.
869 Note that callers will contend for the internal lock when saving log messages to a file.
870 .Pp
871 Note that messages with ReadUID or ReadGID values will simply be saved to the file,
872 and will not effect read access to either the message or the file itself.
873 Similarly, messages with ASLExpireTime values will be saved, but will not effect the
874 life-cycle of either the individual messages or the file.
875 .Ss MESSAGES
876 At the core of this API is the aslmsg structure.
877 Although the structure is opaque and may not be directly manipulated,
878 it contains a list of key/value pairs.
879 All keys and values are NUL-character terminated C language strings.
880 UTF-8 encoding may be used for non-ASCII characters.
881 .Pp
882 Message structures are generally used to send log messages,
883 and are created thusly:
884 .Pp
885 aslmsg m = asl_new(ASL_TYPE_MSG);
886 .Pp
887 Another message type, ASL_TYPE_QUERY,
888 is used to create queries when searching the data store.
889 Query type messages and searching are described in detail in the
890 .Sx SEARCHING
891 section.
892 For the remainder of this section,
893 the messages described will be of the ASL_TYPE_MSG variety.
894 .Pp
895 Each aslmsg contains a default set of keys
896 and values that are associated with them.
897 These keys are listed in the asl.h header file.
898 They are:
899 .Pp
900 #define ASL_KEY_TIME "Time"
901 #define ASL_KEY_HOST "Host"
902 #define ASL_KEY_SENDER "Sender"
903 #define ASL_KEY_FACILITY "Facility"
904 #define ASL_KEY_PID "PID"
905 #define ASL_KEY_UID "UID"
906 #define ASL_KEY_GID "GID"
907 #define ASL_KEY_LEVEL "Level"
908 #define ASL_KEY_MSG "Message"
909 .Pp
910 Many of these correspond to equivalent parts of messages described in the
911 .Xr syslog 3
912 API.
913 Values associated with these message keys are assigned appropriate defaults.
914 The value for ASL_KEY_HOST is the local host name,
915 the value associated with ASL_KEY_SENDER is the process name,
916 the ASL_KEY_PID is the client's process ID number, and so on.
917 .Pp
918 Note the addition of the UID and GID keys.
919 The values for UID and GID are set in library code by the message sender.
920 The server will attempt to confirm the values,
921 but no claim is made that these values cannot be maliciously overridden
922 in an attempt to deceive a log message reader
923 as to the identity of the sender of a message.
924 The contents of log messages must be regarded as insecure.
925 .Pp
926 The
927 .Xr asl 3
928 API does not require a process to choose a facility name.
929 The
930 .Nm syslogd
931 server will use a default value of
932 .Dq user
933 if a facility is not set.
934 However, a client may set a facility name as an argument in the
935 .Nm asl_open
936 call, or by setting a specific value for the ASL_KEY_FACILITY in a message:
937 .Pp
938 asl_set(m, ASL_KEY_FACILITY, "com.somename.greatservice");
939 .Pp
940 An application may choose any facility name at will.
941 Different facility names may be attached to different messages, perhaps to distinguish different subsystems in log messages.
942 Developers are encouraged to adopt a
943 .Dq Reverse ICANN
944 naming convention to avoid conflicting facility names.
945 .Pp
946 Default values are set in the message for each of the keys listed above,
947 except for ASL_KEY_MSG,
948 which may be explicitly set at any time using the
949 .Nm asl_set
950 routine, or implicitly set at the time the message is sent using the
951 .Nm asl_log
952 or
953 .Nm asl_vlog
954 routines.
955 These two routines also have an integer-level parameter
956 for specifying the log priority.
957 The ASL_KEY_LEVEL value is set accordingly.
958 Finally, the value associated with ASL_KEY_TIME
959 is set in the sending routine.
960 .Pp
961 Although it may appear that there is significant overhead required
962 to send a log message using this API,
963 the opposite is actually true.
964 A simple
965 .Dq Hello World
966 program requires only:
967 .Pp
968 #include <asl.h>
969 ...
970 asl_log(NULL, NULL, ASL_LEVEL_INFO, "Hello World!");
971 .Pp
972 Both
973 .Nm asl_log
974 and
975 .Nm asl_vlog
976 will provide the appropriate default values
977 when passed a NULL aslmsg argument.
978 .Pp
979 .Pp
980 In this example, the aslclient argument is NULL.
981 This is sufficient for a single-threaded application,
982 or for an application which only sends log messages from a single thread.
983 When logging from multiple threads,
984 each thread
985 .Em should
986 open a separate client handle using
987 .Nm asl_open .
988 The client handle may then be closed when it is no longer required using
989 .Nm asl_close .
990 Multiple threads may log messages safely using a NULL aslclient argument,
991 but the library will use an internal lock, so that in fact only one thread
992 will log at a time.
993 .Pp
994 When an application requires additional keys and values
995 to be associated with each log message,
996 a single message structure may be allocated and set up as
997 .Dq template
998 message of sorts:
999 .Pp
1000 aslmsg m = asl_new(ASL_TYPE_MSG);
1001 asl_set(m, ASL_KEY_FACILITY, "com.secrets.r.us");
1002 asl_set(m, "Clearance", "Top Secret");
1003 ...
1004 asl_log(NULL, m, ASL_LEVEL_NOTICE, "Message One");
1005 ...
1006 asl_log(NULL, m, ASL_LEVEL_ERR, "Message Two");
1007 .Pp
1008 The message structure will carry the values set for the
1009 .Dq Facility
1010 and
1011 .Dq Clearance
1012 keys so that they are used in each call to
1013 .Nm asl_log ,
1014 while the log level and the message text
1015 are taken from the calling parameters.
1016 .Pp
1017 The
1018 .Ar format
1019 argument to
1020 .Nm asl_log
1021 and
1022 .Nm asl_vlog
1023 is identical to
1024 .Xr printf 3 ,
1025 and may include
1026 .Ql %m ,
1027 which is replaced by the current error message
1028 (as denoted by the global variable
1029 .Va errno ;
1030 see
1031 .Xr strerror 3 . )
1032 .Pp
1033 Key/value pairs may be removed from a message structure with
1034 .Nm asl_unset .
1035 A message may be freed using
1036 .Nm asl_free .
1037 .Pp
1038 The
1039 .Nm asl_send
1040 routine is used by
1041 .Nm asl_log
1042 and
1043 .Nm asl_vlog
1044 to transmit a message to the server.
1045 This routine sets the value associated with ASL_KEY_TIME
1046 and sends the message.
1047 It may be called directly if all of a message's key/value pairs
1048 have been created using
1049 .Nm asl_set .
1050 .Ss SECURITY
1051 Messages that are sent to the
1052 .Nm syslogd
1053 server may be saved in a message store.
1054 The store may be searched using
1055 .Nm asl_search ,
1056 as described below.
1057 By default, all messages are readable by any user.
1058 However, some applications may wish to restrict read access
1059 for some messages.
1060 To accommodate this,
1061 a client may set a value for the "ReadUID" and "ReadGID" keys.
1062 These keys may be associated with a value
1063 containing an ASCII representation of a numeric UID or GID.
1064 Only the root user (UID 0),
1065 the user with the given UID,
1066 or a member of the group with the given GID
1067 may fetch access-controlled messages from the database.
1068 .Pp
1069 Although the ASL system does not require a "Facility" key in a message,
1070 many processes specify a "Facility" value similar
1071 to the common usage of the BSD
1072 .Nm syslog
1073 API, although developers are encouraged to adopt facility names that make sense for their application.
1074 A
1075 .Dq Reverse ICANN
1076 naming convention (e.g. "com.apple.system.syslog") should be adopted to avoid conflicting names.
1077 The ASL system generally allows any string to be used as a facility value,
1078 with one exception.
1079 The value "com.apple.system",
1080 or any string that has "com.apple.system" as a prefix,
1081 may only be used by processes running with the UID 0.
1082 This allows system processes to log messages that can not be "spoofed" by user processes.
1083 Non-UID 0 client processes that specify "com.apple.system" as a facility, will be assigned the value "user"
1084 by the
1085 .Nm syslogd
1086 server.
1087 .Ss CLIENT HANDLES
1088 A client handle contains various parameters and control settings that are used when a message is logged.
1089 This includes an identification string, a facility name, filtering controls, additional file descriptors, and other data.
1090 Client handles are not thread-safe.
1091 Applications that log from multiple threads should create a client handle for each thread.
1092 .Pp
1093 Applications that use libdispatch must also avoid using a single client handle from multiple dispatch queues if those queues may run concurrently.
1094 A good approach is to create one or more serial dispatch queues specifically for logging.
1095 Each such queue should use its own ASL client handle.
1096 .Pp
1097 If a single handle must be accessed by multiple dispatch queues,
1098 then the application must use locks, semaphores, or some other mechanism to prevent concurrent access to a client handle.
1099 .Pp
1100 A NULL value may be used in any of the routines
1101 that require an aslclient argument.
1102 In this case, the library will use an internal client handle.
1103 This internal handle contains its own lock, allowing multiple threads to safely use the NULL client handle.
1104 Note, however, that contention for the lock may cause undesirable synchronization behavior or reduced performance.
1105 .Pp
1106 The
1107 .Nm asl_open
1108 routine may be given an ident argument,
1109 which becomes the default value for the ASL_KEY_SENDER key,
1110 and a facility argument,
1111 which becomes the value associated with the ASL_KEY_FACILITY key.
1112 If NULL is passed as the value for
1113 .Ar ident ,
1114 the name of the currently running program will be used.
1115 If NULL is passed as the value for
1116 .Ar facility ,
1117 the value
1118 .Dq user
1119 will be used for non UID 0 processes, and
1120 .Dq
1121 daemon
1122 will be used for UID 0 processes.
1123 .Pp
1124 Several options are available when creating a client handle.
1125 They are:
1126 .Pp
1127 .Bl -tag -width "ASL_OPT_NO_REMOTE" -compact
1128 .It ASL_OPT_STDERR
1129 adds stderr as an output file descriptor
1130 .It ASL_OPT_NO_DELAY
1131 connects to the server immediately
1132 .It ASL_OPT_NO_REMOTE
1133 disables remote-control filter adjustment
1134 .El
1135 .Pp
1136 ASL_OPT_NO_DELAY makes the client library connect to the
1137 .Nm syslogd
1138 server at the time that
1139 .Nm asl_open
1140 is called, rather than waiting for the first message to be sent.
1141 Opening the connection is quite fast, but some applications may want to avoid any unnecessary delays when calling
1142 .Nm asl_log ,
1143 .Nm asl_vlog ,
1144 or
1145 .Nm asl_send .
1146 .Pp
1147 See the FILTERING section below, and the
1148 .Xr syslog 1
1149 for additional details on filter controls.
1150 .Pp
1151 A client handle is closed and its resources released using
1152 .Nm asl_close .
1153 Note that if additional file descriptors were added to the handle,
1154 either using the ASL_OPT_STDERR option
1155 or afterwards with the
1156 .Nm asl_add_log_file
1157 routine, those file descriptors are not closed by
1158 .Nm asl_close .
1159 .Ss LOGGING TO ADDITIONAL FILES
1160 If a client handle is opened with the ASL_OPT_STDERR option to
1161 .Nm asl_open ,
1162 a copy of each log message will be sent to stderr.
1163 Additional output streams may be include using
1164 .Nm asl_add_log_file .
1165 .Pp
1166 Messages sent to stderr or other files are printed in the "standard" message format
1167 also used as a default format by the
1168 .Xr syslog 1
1169 command line utility.
1170 Non-ASCII characters in a message are encoded using the
1171 .Dq safe
1172 encoding style used by
1173 .Xr syslog 1
1174 with the
1175 .Fl E Ar safe
1176 option.
1177 Backspace characters are printed as ^H.
1178 Carriage returns are mapped to newlines.
1179 A tab character is appended after newlines so that message text is indented.
1180 .Pp
1181 File descriptors may be removed from the list of outputs associated
1182 with a client handle with
1183 .Nm asl_remove_log_file .
1184 This routine simply removes the file descriptor from the output list.
1185 The file is not closed as a result.
1186 .Pp
1187 The ASL_OPT_STDERR option may not be unset
1188 after a client handle has been opened.
1189 .Ss SEARCHING
1190 The
1191 .Nm syslogd
1192 server archives received messages in a data store
1193 that may be searched using the
1194 .Nm asl_search ,
1195 .Nm aslresponse_next ,
1196 and
1197 .Nm aslresponse_free
1198 routines.
1199 A query message is created using:
1200 .Pp
1201 aslmsg q = asl_new(ASL_TYPE_QUERY);
1202 .Pp
1203 Search settings are made in the query using
1204 .Nm asl_set_query .
1205 A search is performed on the data store with
1206 .Nm asl_search .
1207 It returns an
1208 .Ft aslresponse
1209 structure.
1210 The caller may then call
1211 .Nm aslresponse_next
1212 to iterate through matching messages.
1213 The
1214 .Ft aslresponse
1215 structure may be freed with
1216 .Nm aslresponse_free .
1217 .Pp
1218 Like other messages, ASL_TYPE_QUERY messages contain keys and values.
1219 They also associate an operation with each key and value.
1220 The operation is used to decide if a message matches the query.
1221 The simplest operation is ASL_QUERY_OP_EQUAL, which tests for equality.
1222 For example, the following code snippet searches for messages
1223 with a Sender value equal to
1224 .Dq MyApp .
1225 .Pp
1226 aslmsg m;
1227 aslresponse r;
1228 q = asl_new(ASL_TYPE_QUERY);
1229 asl_set_query(q, ASL_KEY_SENDER, "MyApp", ASL_QUERY_OP_EQUAL);
1230 r = asl_search(NULL, q);
1231 .Pp
1232 More complex searches may be performed using other query operations.
1233 .Pp
1234 .Bl -tag -width "ASL_QUERY_OP_GREATER_EQUAL" -compact
1235 .It ASL_QUERY_OP_EQUAL
1236 value equality
1237 .It ASL_QUERY_OP_GREATER
1238 value greater than
1239 .It ASL_QUERY_OP_GREATER_EQUAL
1240 value greater than or equal to
1241 .It ASL_QUERY_OP_LESS
1242 value less than
1243 .It ASL_QUERY_OP_LESS_EQUAL
1244 value less than or equal to
1245 .It ASL_QUERY_OP_NOT_EQUAL
1246 value not equal
1247 .It ASL_QUERY_OP_REGEX
1248 regular expression search
1249 .It ASL_QUERY_OP_TRUE
1250 always true - use to test for the existence of a key
1251 .El
1252 .Pp
1253 Regular expression search uses
1254 .Xr regex 3
1255 library.
1256 Patterns are compiled using the REG_EXTENDED and REG_NOSUB options.
1257 .Pp
1258 Modifiers that change the behavior of these operations
1259 may also be specified by ORing the modifier value with the operation.
1260 The modifiers are:
1261 .Pp
1262 .Bl -tag -width "ASL_QUERY_OP_SUBSTRING" -compact
1263 .It ASL_QUERY_OP_CASEFOLD
1264 string comparisons are case-folded
1265 .It ASL_QUERY_OP_PREFIX
1266 match a leading substring
1267 .It ASL_QUERY_OP_SUFFIX
1268 match a trailing substring
1269 .It ASL_QUERY_OP_SUBSTRING
1270 match any substring
1271 .It ASL_QUERY_OP_NUMERIC
1272 values are converted to integer using
1273 .Nm atoi
1274 .El
1275 .Pp
1276 The only modifier that is checked
1277 for ASL_QUERY_OP_REGEX search is ASL_QUERY_OP_CASEFOLD.
1278 This causes the regular expression to be compiled
1279 with the REG_ICASE option.
1280 .Pp
1281 If a query message contains more than one set of key/value/operation triples,
1282 the result will be a logical AND. For example, to find messages from
1283 .Dq MyApp
1284 with a priority level less than or equal to
1285 .Dq 3 :
1286 .Pp
1287 aslmsg q;
1288 aslresponse r;
1289 q = asl_new(ASL_TYPE_QUERY);
1290 asl_set_query(q, ASL_KEY_SENDER, "MyApp", ASL_QUERY_OP_EQUAL);
1291 asl_set_query(q, ASL_KEY_LEVEL, "3",
1292 ASL_QUERY_OP_LESS_EQUAL | ASL_QUERY_OP_NUMERIC);
1293 r = asl_search(NULL, q);
1294 .Pp
1295 After calling
1296 .Nm asl_search
1297 to get an
1298 .Ft aslresponse
1299 structure, use
1300 .Nm aslresponse_next
1301 to iterate through all matching messages.
1302 To iterate through the keys and values in a message, use
1303 .Nm asl_key
1304 to iterate through the keys, then call
1305 .Nm asl_get
1306 to get the value associated with each key.
1307 .Pp
1308 aslmsg q, m;
1309 int i;
1310 const char *key, *val;
1311 .Pp
1312 ...
1313 r = asl_search(NULL, q);
1314 while (NULL != (m = aslresponse_next(r)))
1315 {
1316 for (i = 0; (NULL != (key = asl_key(m, i))); i++)
1317 {
1318 val = asl_get(m, key);
1319 ...
1320 }
1321 }
1322 aslresponse_free(r);
1323 .Pp
1324 .Ss FILTERING AND REMOTE CONTROL
1325 Clients may set a filter mask value with
1326 .Nm asl_set_filter .
1327 The mask specifies which messages should be sent to the
1328 .Nm syslogd
1329 daemon by specifying a yes/no setting for each priority level.
1330 Clients typically set a filter mask
1331 to avoid sending relatively unimportant messages.
1332 For example, Debug or Info priority level messages
1333 are generally only useful for debugging operations.
1334 By setting a filter mask, a process can improve performance
1335 by avoiding sending messages that are in most cases unnecessary.
1336 .Pp
1337 .Nm asl_set_filter returns the previous value of the filter, i.e. the value of the filter before the routine was called.
1338 .Pp
1339 As a convenience, the macros ASL_FILTER_MASK(level) and ASL_FILTER_MASK_UPTO(level)
1340 may be used to construct a bit mask corresponding to a given priority level,
1341 or corresponding to a bit mask for all priority levels
1342 from ASL_LEVEL_EMERG to a given input level.
1343 .Pp
1344 The default filter mask is ASL_FILTER_MASK_UPTO(ASL_LEVEL_NOTICE).
1345 This means that by default,
1346 and in the absence of remote-control changes (described below),
1347 ASL_LEVEL_DEBUG and ASL_LEVEL_INFO priority level messages
1348 are not sent to the
1349 .Mn syslogd
1350 server.
1351 .Pp
1352 Three different filters exist for each application.
1353 The first is the filter mask set using
1354 .Nm asl_set_filter
1355 as described above.
1356 The Apple System Log facility also manages a
1357 .Dq master
1358 filter mask.
1359 The master filter mask usually has a value
1360 that indicates to the library that it is
1361 .Dq off ,
1362 and thus it has no effect.
1363 However, the mask filter mask may be enabled
1364 by giving it a value using the
1365 .Nm syslog
1366 command, using the
1367 .Fl c
1368 0 option.
1369 When the master filter mask has been set,
1370 it takes precedence over the client's filter mask.
1371 The client's mask is unmodified,
1372 and will become active again if remote-control filtering is disabled.
1373 .Pp
1374 In addition to the master filter mask,
1375 The Apple System Log facility
1376 also manages a per-client remote-control filter mask.
1377 Like the master filter mask, the per-client mask is usually
1378 .Dq off ,
1379 having no effect on a client.
1380 If a per-client filter mask is set using the
1381 .Nm syslog
1382 command, using the
1383 .Fl c Ar process
1384 option, then it takes precedence
1385 over both the client's filter mask and the master filter mask.
1386 As is the case with the master filter mask,
1387 a per-client mask ceases having any effect when if is disabled.
1388 .Pp
1389 The ASL_OPT_NO_REMOTE option to
1390 .Nm asl_open
1391 causes both the master and per-client remote-control masks
1392 to be ignored in the library.
1393 In that case, only the client's own filter mask
1394 is used to determine which messages are sent to the server.
1395 This may be useful for Applications that produce log messages
1396 that should never be filtered, due to security considerations.
1397 Note that root (administrator) access is required
1398 to set or change the master filter mask,
1399 and that only root may change a per-client remote-control filter mask
1400 for a root (UID 0) process.
1401 .Pp
1402 The per-process remote control filter value is kept as a state value
1403 associated with a key managed by
1404 .Nm notifyd .
1405 The key is protected by an access control mechanism that only permits the
1406 filter value to be accessed and modified by the same effective UID as the
1407 ASL client at the time that the first ASL connection was created.
1408 Remote filter control using
1409 .Nm syslog Fl c
1410 will fail for processes that change effective UID after starting an ASL connection.
1411 Those processes should close all ASL client handles and then re-open ASL connections
1412 if remote filter control support is desired.
1413 .Sh HISTORY
1414 These functions first appeared in
1415 Mac OS X 10.4.
1416 .Sh SEE ALSO
1417 .Xr syslog 1 ,
1418 .Xr strvis 3 ,
1419 .Xr syslogd 8