001/*
002 * Copyright 2009-2024 Ping Identity Corporation
003 * All Rights Reserved.
004 */
005/*
006 * Copyright 2009-2024 Ping Identity Corporation
007 *
008 * Licensed under the Apache License, Version 2.0 (the "License");
009 * you may not use this file except in compliance with the License.
010 * You may obtain a copy of the License at
011 *
012 *    http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing, software
015 * distributed under the License is distributed on an "AS IS" BASIS,
016 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017 * See the License for the specific language governing permissions and
018 * limitations under the License.
019 */
020/*
021 * Copyright (C) 2009-2024 Ping Identity Corporation
022 *
023 * This program is free software; you can redistribute it and/or modify
024 * it under the terms of the GNU General Public License (GPLv2 only)
025 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only)
026 * as published by the Free Software Foundation.
027 *
028 * This program is distributed in the hope that it will be useful,
029 * but WITHOUT ANY WARRANTY; without even the implied warranty of
030 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
031 * GNU General Public License for more details.
032 *
033 * You should have received a copy of the GNU General Public License
034 * along with this program; if not, see <http://www.gnu.org/licenses>.
035 */
036package com.unboundid.ldap.sdk.unboundidds.logs;
037
038
039
040import com.unboundid.util.NotNull;
041import com.unboundid.util.Nullable;
042import com.unboundid.util.StaticUtils;
043import com.unboundid.util.ThreadSafety;
044import com.unboundid.util.ThreadSafetyLevel;
045
046
047
048/**
049 * This enum contains the set of error log severities defined in the Directory
050 * Server.
051 * <BR>
052 * <BLOCKQUOTE>
053 *   <B>NOTE:</B>  This class, and other classes within the
054 *   {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only
055 *   supported for use against Ping Identity, UnboundID, and
056 *   Nokia/Alcatel-Lucent 8661 server products.  These classes provide support
057 *   for proprietary functionality or for external specifications that are not
058 *   considered stable or mature enough to be guaranteed to work in an
059 *   interoperable way with other types of LDAP servers.
060 * </BLOCKQUOTE>
061 */
062@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE)
063public enum ErrorLogSeverity
064{
065  /**
066   * The severity that will be used for messages providing debugging
067   * information.
068   */
069  DEBUG,
070
071
072
073  /**
074   * The severity that will be used for fatal error messages, which indicate
075   * that the server can no longer continue functioning normally.
076   */
077  FATAL_ERROR,
078
079
080  /**
081   * The severity that will be used for informational messages which may be
082   * useful but generally do not need to be written to log files.
083   */
084  INFORMATION,
085
086
087
088  /**
089   * The severity that will be used for messages about errors that are small in
090   * scope and do not generally impact the operation of the server.
091   */
092  MILD_ERROR,
093
094
095
096  /**
097   * The severity that will be used for warnings about conditions that do not
098   * generally impact the operation of the server.
099   */
100  MILD_WARNING,
101
102
103  /**
104   * The severity that will be used for significant informational messages that
105   * should generally be visible to administrators.
106   */
107  NOTICE,
108
109
110  /**
111   * The severity that will be used for messages about errors that may impact
112   * the operation of the server or one of its components.
113   */
114  SEVERE_ERROR,
115
116
117  /**
118   * The severity that will be used for warning messages about conditions that
119   * may impact the operation of the server or one of its components.
120   */
121  SEVERE_WARNING;
122
123
124
125  /**
126   * Retrieves the error log severity with the specified name.
127   *
128   * @param  name  The name of the error log severity to retrieve.  It must not
129   *               be {@code null}.
130   *
131   * @return  The requested error log severity, or {@code null} if no such
132   *          severity is defined.
133   */
134  @Nullable()
135  public static ErrorLogSeverity forName(@NotNull final String name)
136  {
137    switch (StaticUtils.toLowerCase(name))
138    {
139      case "debug":
140        return DEBUG;
141      case "fatalerror":
142      case "fatal-error":
143      case "fatal_error":
144        return FATAL_ERROR;
145      case "information":
146        return INFORMATION;
147      case "milderror":
148      case "mild-error":
149      case "mild_error":
150        return MILD_ERROR;
151      case "mildwarning":
152      case "mild-warning":
153      case "mild_warning":
154        return MILD_WARNING;
155      case "notice":
156        return NOTICE;
157      case "severeerror":
158      case "severe-error":
159      case "severe_error":
160        return SEVERE_ERROR;
161      case "severewarning":
162      case "severe-warning":
163      case "severe_warning":
164        return SEVERE_WARNING;
165      default:
166        return null;
167    }
168  }
169}