001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache license, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the license for the specific language governing permissions and 015 * limitations under the license. 016 */ 017 package org.apache.logging.log4j.core.net; 018 019 import org.apache.logging.log4j.util.EnglishEnums; 020 021 /** 022 * The facility codes used by the Syslog system. 023 * 024 * Numerical Facility<br> 025 * Code<br> 026 * 027 * 0 kernel messages<br> 028 * 1 user-level messages<br> 029 * 2 mail system<br> 030 * 3 system daemons<br> 031 * 4 security/authorization messages<br> 032 * 5 messages generated internally by syslogd<br> 033 * 6 line printer subsystem<br> 034 * 7 network news subsystem<br> 035 * 8 UUCP subsystem<br> 036 * 9 clock daemon<br> 037 * 10 security/authorization messages<br> 038 * 11 FTP daemon<br> 039 * 12 NTP subsystem<br> 040 * 13 log audit<br> 041 * 14 log alert<br> 042 * 15 clock daemon (note 2)<br> 043 * 16 local use 0 (local0)<br> 044 * 17 local use 1 (local1)<br> 045 * 18 local use 2 (local2)<br> 046 * 19 local use 3 (local3)<br> 047 * 20 local use 4 (local4)<br> 048 * 21 local use 5 (local5)<br> 049 * 22 local use 6 (local6)<br> 050 * 23 local use 7 (local7)<br> 051 */ 052 public enum Facility { 053 /** Kernel messages. */ 054 KERN(0), 055 /** User level messages. */ 056 USER(1), 057 /** Mail system. */ 058 MAIL(2), 059 /** System daemons. */ 060 DAEMON(3), 061 /** Security/Authorization messages. */ 062 AUTH(4), 063 /** Messages generated by syslogd. */ 064 SYSLOG(5), 065 /** Line printer subsystem. */ 066 LPR(6), 067 /** Network news subsystem. */ 068 NEWS(7), 069 /** UUCP subsystem. */ 070 UUCP(8), 071 /** Clock daemon. */ 072 CRON(9), 073 /** Security/Authorization messages. */ 074 AUTHPRIV(10), 075 /** FTP daemon. */ 076 FTP(11), 077 /** NTP subsystem. */ 078 NTP(12), 079 /** Log audit. */ 080 LOG_AUDIT(13), 081 /** Log alert. */ 082 LOG_ALERT(14), 083 /** Clock daemon. */ 084 CLOCK(15), 085 /** Local use 0. */ 086 LOCAL0(16), 087 /** Local use 1. */ 088 LOCAL1(17), 089 /** Local use 2. */ 090 LOCAL2(18), 091 /** Local use 3. */ 092 LOCAL3(19), 093 /** Local use 4. */ 094 LOCAL4(20), 095 /** Local use 5. */ 096 LOCAL5(21), 097 /** Local use 6. */ 098 LOCAL6(22), 099 /** Local use 7. */ 100 LOCAL7(23); 101 102 private final int code; 103 104 private Facility(final int code) { 105 this.code = code; 106 } 107 108 /** 109 * Returns the Facility for the given string. 110 * 111 * @param name The Facility enum name, case-insensitive. If null, returns, null 112 * @return a Facility enum value or null if name is null 113 */ 114 public static Facility toFacility(final String name) { 115 return toFacility(name, null); 116 } 117 118 /** 119 * Returns the Facility for the given string. 120 * 121 * @param name The Facility enum name, case-insensitive. If null, returns, defaultFacility 122 * @param defaultFacility the Facility to return if name is null 123 * @return a Facility enum value or null if name is null 124 */ 125 public static Facility toFacility(final String name, final Facility defaultFacility) { 126 return EnglishEnums.valueOf(Facility.class, name, defaultFacility); 127 } 128 129 /** 130 * Retrieve the value of the enumeration. 131 * @return The value associated with the enumeration. 132 */ 133 public int getCode() { 134 return this.code; 135 } 136 137 /** 138 * Determine if this enumeration matches the specified name (ignoring case). 139 * @param name The name to check. 140 * @return true if the name matches this enumeration, ignoring case. 141 */ 142 public boolean isEqual(final String name) { 143 return this.name().equalsIgnoreCase(name); 144 } 145 146 }