001/** 002 * Copyright (c) 2004-2011 QOS.ch 003 * All rights reserved. 004 * 005 * Permission is hereby granted, free of charge, to any person obtaining 006 * a copy of this software and associated documentation files (the 007 * "Software"), to deal in the Software without restriction, including 008 * without limitation the rights to use, copy, modify, merge, publish, 009 * distribute, sublicense, and/or sell copies of the Software, and to 010 * permit persons to whom the Software is furnished to do so, subject to 011 * the following conditions: 012 * 013 * The above copyright notice and this permission notice shall be 014 * included in all copies or substantial portions of the Software. 015 * 016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 017 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 018 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 019 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 020 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 021 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 022 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 023 * 024 */ 025package org.slf4j.helpers; 026 027import org.slf4j.Logger; 028import org.slf4j.Marker; 029 030/** 031 * A direct NOP (no operation) implementation of {@link Logger}. 032 * 033 * @author Ceki Gülcü 034 */ 035public class NOPLogger extends NamedLoggerBase implements Logger { 036 037 private static final long serialVersionUID = -517220405410904473L; 038 039 /** 040 * The unique instance of NOPLogger. 041 */ 042 public static final NOPLogger NOP_LOGGER = new NOPLogger(); 043 044 /** 045 * There is no point in creating multiple instances of NOPLogger. 046 * 047 * The present constructor should be "private" but we are leaving it as "protected" for compatibility. 048 */ 049 protected NOPLogger() { 050 } 051 052 /** 053 * Always returns the string value "NOP". 054 */ 055 @Override 056 public String getName() { 057 return "NOP"; 058 } 059 060 /** 061 * Always returns false. 062 * @return always false 063 */ 064 @Override 065 final public boolean isTraceEnabled() { 066 return false; 067 } 068 069 /** A NOP implementation. */ 070 @Override 071 final public void trace(String msg) { 072 // NOP 073 } 074 075 /** A NOP implementation. */ 076 @Override 077 final public void trace(String format, Object arg) { 078 // NOP 079 } 080 081 /** A NOP implementation. */ 082 @Override 083 public final void trace(String format, Object arg1, Object arg2) { 084 // NOP 085 } 086 087 /** A NOP implementation. */ 088 @Override 089 public final void trace(String format, Object... argArray) { 090 // NOP 091 } 092 093 /** A NOP implementation. */ 094 @Override 095 final public void trace(String msg, Throwable t) { 096 // NOP 097 } 098 099 /** 100 * Always returns false. 101 * @return always false 102 */ 103 final public boolean isDebugEnabled() { 104 return false; 105 } 106 107 /** A NOP implementation. */ 108 final public void debug(String msg) { 109 // NOP 110 } 111 112 /** A NOP implementation. */ 113 final public void debug(String format, Object arg) { 114 // NOP 115 } 116 117 /** A NOP implementation. */ 118 final public void debug(String format, Object arg1, Object arg2) { 119 // NOP 120 } 121 122 /** A NOP implementation. */ 123 final public void debug(String format, Object... argArray) { 124 // NOP 125 } 126 127 /** A NOP implementation. */ 128 final public void debug(String msg, Throwable t) { 129 // NOP 130 } 131 132 /** 133 * Always returns false. 134 * @return always false 135 */ 136 final public boolean isInfoEnabled() { 137 // NOP 138 return false; 139 } 140 141 /** A NOP implementation. */ 142 final public void info(String msg) { 143 // NOP 144 } 145 146 /** A NOP implementation. */ 147 final public void info(String format, Object arg1) { 148 // NOP 149 } 150 151 /** A NOP implementation. */ 152 final public void info(String format, Object arg1, Object arg2) { 153 // NOP 154 } 155 156 /** A NOP implementation. */ 157 final public void info(String format, Object... argArray) { 158 // NOP 159 } 160 161 /** A NOP implementation. */ 162 final public void info(String msg, Throwable t) { 163 // NOP 164 } 165 166 /** 167 * Always returns false. 168 * @return always false 169 */ 170 final public boolean isWarnEnabled() { 171 return false; 172 } 173 174 /** A NOP implementation. */ 175 final public void warn(String msg) { 176 // NOP 177 } 178 179 /** A NOP implementation. */ 180 final public void warn(String format, Object arg1) { 181 // NOP 182 } 183 184 /** A NOP implementation. */ 185 final public void warn(String format, Object arg1, Object arg2) { 186 // NOP 187 } 188 189 /** A NOP implementation. */ 190 final public void warn(String format, Object... argArray) { 191 // NOP 192 } 193 194 /** A NOP implementation. */ 195 final public void warn(String msg, Throwable t) { 196 // NOP 197 } 198 199 /** A NOP implementation. */ 200 final public boolean isErrorEnabled() { 201 return false; 202 } 203 204 /** A NOP implementation. */ 205 final public void error(String msg) { 206 // NOP 207 } 208 209 /** A NOP implementation. */ 210 final public void error(String format, Object arg1) { 211 // NOP 212 } 213 214 /** A NOP implementation. */ 215 final public void error(String format, Object arg1, Object arg2) { 216 // NOP 217 } 218 219 /** A NOP implementation. */ 220 final public void error(String format, Object... argArray) { 221 // NOP 222 } 223 224 /** A NOP implementation. */ 225 final public void error(String msg, Throwable t) { 226 // NOP 227 } 228 229 // ============================================================ 230 // Added NOP methods since MarkerIgnoringBase is now deprecated 231 // ============================================================ 232 /** 233 * Always returns false. 234 * @return always false 235 */ 236 final public boolean isTraceEnabled(Marker marker) { 237 // NOP 238 return false; 239 } 240 241 /** A NOP implementation. */ 242 @Override 243 final public void trace(Marker marker, String msg) { 244 // NOP 245 } 246 247 /** A NOP implementation. */ 248 @Override 249 final public void trace(Marker marker, String format, Object arg) { 250 // NOP 251 } 252 253 /** A NOP implementation. */ 254 @Override 255 final public void trace(Marker marker, String format, Object arg1, Object arg2) { 256 // NOP 257 } 258 259 /** A NOP implementation. */ 260 @Override 261 final public void trace(Marker marker, String format, Object... argArray) { 262 // NOP 263 } 264 265 /** A NOP implementation. */ 266 @Override 267 final public void trace(Marker marker, String msg, Throwable t) { 268 // NOP 269 } 270 271 /** 272 * Always returns false. 273 * @return always false 274 */ 275 final public boolean isDebugEnabled(Marker marker) { 276 return false; 277 } 278 279 /** A NOP implementation. */ 280 @Override 281 final public void debug(Marker marker, String msg) { 282 // NOP 283 } 284 285 /** A NOP implementation. */ 286 @Override 287 final public void debug(Marker marker, String format, Object arg) { 288 // NOP 289 } 290 291 /** A NOP implementation. */ 292 @Override 293 final public void debug(Marker marker, String format, Object arg1, Object arg2) { 294 // NOP 295 } 296 297 @Override 298 final public void debug(Marker marker, String format, Object... arguments) { 299 // NOP 300 } 301 302 @Override 303 final public void debug(Marker marker, String msg, Throwable t) { 304 // NOP 305 } 306 307 /** 308 * Always returns false. 309 * @return always false 310 */ 311 @Override 312 public boolean isInfoEnabled(Marker marker) { 313 return false; 314 } 315 316 /** A NOP implementation. */ 317 @Override 318 final public void info(Marker marker, String msg) { 319 // NOP 320 } 321 322 /** A NOP implementation. */ 323 @Override 324 final public void info(Marker marker, String format, Object arg) { 325 // NOP 326 } 327 328 /** A NOP implementation. */ 329 @Override 330 final public void info(Marker marker, String format, Object arg1, Object arg2) { 331 // NOP 332 } 333 334 /** A NOP implementation. */ 335 @Override 336 final public void info(Marker marker, String format, Object... arguments) { 337 // NOP 338 } 339 340 /** A NOP implementation. */ 341 @Override 342 final public void info(Marker marker, String msg, Throwable t) { 343 // NOP 344 } 345 346 /** 347 * Always returns false. 348 * @return always false 349 */ 350 @Override 351 final public boolean isWarnEnabled(Marker marker) { 352 return false; 353 } 354 355 /** A NOP implementation. */ 356 @Override 357 final public void warn(Marker marker, String msg) { 358 // NOP 359 } 360 361 /** A NOP implementation. */ 362 @Override 363 final public void warn(Marker marker, String format, Object arg) { 364 // NOP 365 } 366 367 /** A NOP implementation. */ 368 @Override 369 final public void warn(Marker marker, String format, Object arg1, Object arg2) { 370 // NOP 371 } 372 373 /** A NOP implementation. */ 374 @Override 375 final public void warn(Marker marker, String format, Object... arguments) { 376 // NOP 377 } 378 379 /** A NOP implementation. */ 380 @Override 381 final public void warn(Marker marker, String msg, Throwable t) { 382 // NOP 383 } 384 385 /** 386 * Always returns false. 387 * @return always false 388 */ 389 @Override 390 final public boolean isErrorEnabled(Marker marker) { 391 return false; 392 } 393 394 /** A NOP implementation. */ 395 @Override 396 final public void error(Marker marker, String msg) { 397 // NOP 398 } 399 400 /** A NOP implementation. */ 401 @Override 402 final public void error(Marker marker, String format, Object arg) { 403 // NOP 404 } 405 406 /** A NOP implementation. */ 407 @Override 408 final public void error(Marker marker, String format, Object arg1, Object arg2) { 409 // NOP 410 } 411 412 /** A NOP implementation. */ 413 @Override 414 final public void error(Marker marker, String format, Object... arguments) { 415 // NOP 416 } 417 418 /** A NOP implementation. */ 419 @Override 420 final public void error(Marker marker, String msg, Throwable t) { 421 // NOP 422 } 423 // =================================================================== 424 // End of added NOP methods since MarkerIgnoringBase is now deprecated 425 // =================================================================== 426 427}