001/* 002 * Copyright 2009-2019 Ping Identity Corporation 003 * All Rights Reserved. 004 */ 005/* 006 * Copyright (C) 2015-2019 Ping Identity Corporation 007 * 008 * This program is free software; you can redistribute it and/or modify 009 * it under the terms of the GNU General Public License (GPLv2 only) 010 * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) 011 * as published by the Free Software Foundation. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 016 * GNU General Public License for more details. 017 * 018 * You should have received a copy of the GNU General Public License 019 * along with this program; if not, see <http://www.gnu.org/licenses>. 020 */ 021package com.unboundid.ldap.sdk.unboundidds.logs; 022 023 024 025import com.unboundid.util.Debug; 026import com.unboundid.util.NotMutable; 027import com.unboundid.util.ThreadSafety; 028import com.unboundid.util.ThreadSafetyLevel; 029 030 031 032/** 033 * This class provides a data structure that holds information about a log 034 * message that may appear in the Directory Server error log. 035 * <BR> 036 * <BLOCKQUOTE> 037 * <B>NOTE:</B> This class, and other classes within the 038 * {@code com.unboundid.ldap.sdk.unboundidds} package structure, are only 039 * supported for use against Ping Identity, UnboundID, and 040 * Nokia/Alcatel-Lucent 8661 server products. These classes provide support 041 * for proprietary functionality or for external specifications that are not 042 * considered stable or mature enough to be guaranteed to work in an 043 * interoperable way with other types of LDAP servers. 044 * </BLOCKQUOTE> 045 */ 046@NotMutable() 047@ThreadSafety(level=ThreadSafetyLevel.COMPLETELY_THREADSAFE) 048public final class ErrorLogMessage 049 extends LogMessage 050{ 051 /** 052 * The serial version UID for this serializable class. 053 */ 054 private static final long serialVersionUID = 1743586990943392442L; 055 056 057 058 // The name of the category for this error log message. 059 private final ErrorLogCategory category; 060 061 // The name of the severity for this error log message. 062 private final ErrorLogSeverity severity; 063 064 // The message ID for this error log message. 065 private final Long messageID; 066 067 // The connection ID for the operation currently being processed by the thread 068 // that generated this error log message. 069 private final Long triggeredByConnectionID; 070 071 // The operation ID for the operation currently being processed by the thread 072 // that generated this error log message. 073 private final Long triggeredByOperationID; 074 075 // The Directory Server instance name for this error log message. 076 private final String instanceName; 077 078 // The message string for this error log message. 079 private final String message; 080 081 // The product name for this error log message. 082 private final String productName; 083 084 // The startup ID for this error log message; 085 private final String startupID; 086 087 088 089 /** 090 * Creates a new error log message from the provided message string. 091 * 092 * @param s The string to be parsed as an error log message. 093 * 094 * @throws LogException If the provided string cannot be parsed as a valid 095 * log message. 096 */ 097 public ErrorLogMessage(final String s) 098 throws LogException 099 { 100 this(new LogMessage(s)); 101 } 102 103 104 105 /** 106 * Creates a new error log message from the provided message string. 107 * 108 * @param m The log message to be parsed as an error log message. 109 */ 110 public ErrorLogMessage(final LogMessage m) 111 { 112 super(m); 113 114 productName = getNamedValue("product"); 115 instanceName = getNamedValue("instanceName"); 116 startupID = getNamedValue("startupID"); 117 messageID = getNamedValueAsLong("msgID"); 118 message = getNamedValue("msg"); 119 triggeredByConnectionID = getNamedValueAsLong("triggeredByConn"); 120 triggeredByOperationID = getNamedValueAsLong("triggeredByOp"); 121 122 ErrorLogCategory cat = null; 123 try 124 { 125 cat = ErrorLogCategory.valueOf(getNamedValue("category")); 126 } 127 catch (final Exception e) 128 { 129 Debug.debugException(e); 130 } 131 category = cat; 132 133 ErrorLogSeverity sev = null; 134 try 135 { 136 sev = ErrorLogSeverity.valueOf(getNamedValue("severity")); 137 } 138 catch (final Exception e) 139 { 140 Debug.debugException(e); 141 } 142 severity = sev; 143 } 144 145 146 147 /** 148 * Retrieves the server product name for this error log message. 149 * 150 * @return The server product name for this error log message, or 151 * {@code null} if it is not included in the log message. 152 */ 153 public String getProductName() 154 { 155 return productName; 156 } 157 158 159 160 /** 161 * Retrieves the Directory Server instance name for this error log message. 162 * 163 * @return The Directory Server instance name for this error log message, or 164 * {@code null} if it is not included in the log message. 165 */ 166 public String getInstanceName() 167 { 168 return instanceName; 169 } 170 171 172 173 /** 174 * Retrieves the Directory Server startup ID for this error log message. 175 * 176 * @return The Directory Server startup ID for this error log message, or 177 * {@code null} if it is not included in the log message. 178 */ 179 public String getStartupID() 180 { 181 return startupID; 182 } 183 184 185 186 /** 187 * Retrieves the category for this error log message. 188 * 189 * @return The category for this error log message, or {@code null} if it is 190 * not included in the log message. 191 */ 192 public ErrorLogCategory getCategory() 193 { 194 return category; 195 } 196 197 198 199 /** 200 * Retrieves the severity for this error log message. 201 * 202 * @return The severity for this error log message, or {@code null} if it is 203 * not included in the log message. 204 */ 205 public ErrorLogSeverity getSeverity() 206 { 207 return severity; 208 } 209 210 211 212 /** 213 * Retrieves the numeric identifier for this error log message. 214 * 215 * @return The numeric identifier for this error log message, or {@code null} 216 * if it is not included in the log message. 217 */ 218 public Long getMessageID() 219 { 220 return messageID; 221 } 222 223 224 225 /** 226 * Retrieves the connection ID for the operation currently being processed by 227 * the thread that generated this error log message. 228 * 229 * @return The connection ID for the operation currently being processed by 230 * the thread that generated this error log message, or {@code null} 231 * if it is not included in the log message. 232 */ 233 public Long getTriggeredByConnectionID() 234 { 235 return triggeredByConnectionID; 236 } 237 238 239 240 /** 241 * Retrieves the operation ID for the operation currently being processed by 242 * the thread that generated this error log message. 243 * 244 * @return The operation ID for the operation currently being processed by 245 * the thread that generated this error log message, or {@code null} 246 * if it is not included in the log message. 247 */ 248 public Long getTriggeredByOperationID() 249 { 250 return triggeredByOperationID; 251 } 252 253 254 255 /** 256 * Retrieves the message text for this error log message. 257 * 258 * @return The message text for this error log message, or {@code null} if it 259 * is not included in the log message. 260 */ 261 public String getMessage() 262 { 263 return message; 264 } 265}