xref: /illumos-gate/usr/src/cmd/pools/poold/com/sun/solaris/service/logging/Facility.java (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /* ident	"%Z%%M%	%I%	%E% SMI" */
28 
29 package com.sun.solaris.service.logging;
30 
31 /**
32  * <code>syslog(3C)</code> facility levels defined in
33  * <code>sys/syslog.h</code>.
34  */
35 public class Facility {
36 	/**
37 	 * LOG_KERN from <code>sys/syslog.h</code>
38 	 */
39 	private static final int LOG_KERN = 0 << 3;
40 
41 	/**
42 	 * LOG_USER from <code>sys/syslog.h</code>
43 	 */
44 	private static final int LOG_USER = 1 << 3;
45 
46 	/**
47 	 * LOG_MAIL from <code>sys/syslog.h</code>
48 	 */
49 	private static final int LOG_MAIL = 2 << 3;
50 
51 	/**
52 	 * LOG_DAEMON from <code>sys/syslog.h</code>
53 	 */
54 	private static final int LOG_DAEMON = 3 << 3;
55 
56 	/**
57 	 * LOG_AUTH from <code>sys/syslog.h</code>
58 	 */
59 	private static final int LOG_AUTH = 4 << 3;
60 
61 	/**
62 	 * LOG_SYSLOG from <code>sys/syslog.h</code>
63 	 */
64 	private static final int LOG_SYSLOG = 5 << 3;
65 
66 	/**
67 	 * LOG_LPR from <code>sys/syslog.h</code>
68 	 */
69 	private static final int LOG_LPR = 6 << 3;
70 
71 	/**
72 	 * LOG_NEWS from <code>sys/syslog.h</code>
73 	 */
74 	private static final int LOG_NEWS = 7 << 3;
75 
76 	/**
77 	 * LOG_UUCP from <code>sys/syslog.h</code>
78 	 */
79 	private static final int LOG_UUCP = 8 << 3;
80 
81 	/**
82 	 * LOG_CRON from <code>sys/syslog.h</code>
83 	 */
84 	private static final int LOG_CRON = 15 << 3;
85 
86 	/**
87 	 * LOG_LOCAL0 from <code>sys/syslog.h</code>
88 	 */
89 	private static final int LOG_LOCAL0 = 16 << 3;
90 
91 	/**
92 	 * LOG_LOCAL1 from <code>sys/syslog.h</code>
93 	 */
94 	private static final int LOG_LOCAL1 = 17 << 3;
95 
96 	/**
97 	 * LOG_LOCAL2 from <code>sys/syslog.h</code>
98 	 */
99 	private static final int LOG_LOCAL2 = 18 << 3;
100 
101 	/**
102 	 * LOG_LOCAL3 from <code>sys/syslog.h</code>
103 	 */
104 	private static final int LOG_LOCAL3 = 19 << 3;
105 
106 	/**
107 	 * LOG_LOCAL4 from <code>sys/syslog.h</code>
108 	 */
109 	private static final int LOG_LOCAL4 = 20 << 3;
110 
111 	/**
112 	 * LOG_LOCAL5 from <code>sys/syslog.h</code>
113 	 */
114 	private static final int LOG_LOCAL5 = 21 << 3;
115 
116 	/**
117 	 * LOG_LOCAL6 from <code>sys/syslog.h</code>
118 	 */
119 	private static final int LOG_LOCAL6 = 22 << 3;
120 
121 	/**
122 	 * LOG_LOCAL7 from <code>sys/syslog.h</code>
123 	 */
124 	private static final int LOG_LOCAL7 = 23 << 3;
125 
126 	/**
127 	 * LOG_KERN <code>syslog(3C)</code> facility
128 	 */
129 	public static final Facility KERN = new Facility(LOG_KERN, "KERN");
130 
131 	/**
132 	 * LOG_USER <code>syslog(3C)</code> facility
133 	 */
134 	public static final Facility USER = new Facility(LOG_USER, "USER");
135 
136 	/**
137 	 * LOG_MAIL <code>syslog(3C)</code> facility
138 	 */
139 	public static final Facility MAIL = new Facility(LOG_MAIL, "MAIL");
140 
141 	/**
142 	 * LOG_DAEMON <code>syslog(3C)</code> facility
143 	 */
144 	public static final Facility DAEMON = new Facility(LOG_DAEMON,
145 	    "DAEMON");
146 
147 	/**
148 	 * LOG_AUTH <code>syslog(3C)</code> facility
149 	 */
150 	public static final Facility AUTH = new Facility(LOG_AUTH, "AUTH");
151 
152 	/**
153 	 * LOG_SYSLOG <code>syslog(3C)</code> facility
154 	 */
155 	public static final Facility SYSLOG = new Facility(LOG_SYSLOG,
156 	    "SYSLOG");
157 
158 	/**
159 	 * LOG_LPR <code>syslog(3C)</code> facility
160 	 */
161 	public static final Facility LPR = new Facility(LOG_LPR, "LPR");
162 
163 	/**
164 	 * LOG_NEWS <code>syslog(3C)</code> facility
165 	 */
166 	public static final Facility NEWS = new Facility(LOG_NEWS, "NEWS");
167 
168 	/**
169 	 * LOG_UUCP <code>syslog(3C)</code> facility
170 	 */
171 	public static final Facility UUCP = new Facility(LOG_UUCP, "UUCP");
172 
173 	/**
174 	 * LOG_CRON <code>syslog(3C)</code> facility
175 	 */
176 	public static final Facility CRON = new Facility(LOG_CRON, "CRON");
177 
178 	/**
179 	 * LOG_LOCAL0 <code>syslog(3C)</code> facility
180 	 */
181 	public static final Facility LOCAL0 = new Facility(LOG_LOCAL0,
182 	    "LOCAL0");
183 
184 	/**
185 	 * LOG_LOCAL1 <code>syslog(3C)</code> facility
186 	 */
187 	public static final Facility LOCAL1 = new Facility(LOG_LOCAL1,
188 	    "LOCAL1");
189 
190 	/**
191 	 * LOG_LOCAL2 <code>syslog(3C)</code> facility
192 	 */
193 	public static final Facility LOCAL2 = new Facility(LOG_LOCAL2,
194 	    "LOCAL2");
195 
196 	/**
197 	 * LOG_LOCAL3 <code>syslog(3C)</code> facility
198 	 */
199 	public static final Facility LOCAL3 = new Facility(LOG_LOCAL3,
200 	    "LOCAL3");
201 
202 	/**
203 	 * LOG_LOCAL4 <code>syslog(3C)</code> facility
204 	 */
205 	public static final Facility LOCAL4 = new Facility(LOG_LOCAL4,
206 	    "LOCAL4");
207 
208 	/**
209 	 * LOG_LOCAL5 <code>syslog(3C)</code> facility
210 	 */
211 	public static final Facility LOCAL5 = new Facility(LOG_LOCAL5,
212 	    "LOCAL5");
213 
214 	/**
215 	 * LOG_LOCAL6 <code>syslog(3C)</code> facility
216 	 */
217 	public static final Facility LOCAL6 = new Facility(LOG_LOCAL6,
218 	    "LOCAL6");
219 
220 	/**
221 	 * LOG_LOCAL7 <code>syslog(3C)</code> facility
222 	 */
223 	public static final Facility LOCAL7 = new Facility(LOG_LOCAL7,
224 	    "LOCAL7");
225 
226 	/**
227 	 * Native facility of this instance.
228 	 */
229 	private int facility;
230 
231 	/**
232 	 * Name of this facility.
233 	 */
234 	private String string;
235 
Facility(int facility, String string)236 	private Facility(int facility, String string)
237 	{
238 		this.facility = facility;
239 		this.string = string;
240 	}
241 
242 	/**
243 	 * Returns the native <code>syslog(3C)</code> facility.
244 	 */
getNative()245 	public int getNative()
246 	{
247 		return (facility);
248 	}
249 
equals(Object o)250 	public boolean equals(Object o)
251 	{
252 		Facility f = (Facility)o;
253 
254 		return (getNative() == f.getNative());
255 	}
256 
toString()257 	public String toString()
258 	{
259 		return (string);
260 	}
261 }
262