1 55 56 package org.apache.commons.el; 57 58 import java.io.PrintStream ; 59 import java.text.MessageFormat ; 60 import javax.servlet.jsp.el.ELException ; 61 62 76 77 public class Logger 78 { 79 83 PrintStream mOut; 84 85 92 public Logger (PrintStream pOut) 93 { 94 mOut = pOut; 95 } 96 97 103 public boolean isLoggingWarning () 104 { 105 return false; 106 } 107 108 113 public void logWarning (String pMessage, 114 Throwable pRootCause) 115 throws ELException 116 { 117 if (isLoggingWarning ()) { 118 if (pMessage == null) { 119 System.out.println (pRootCause); 120 } 121 else if (pRootCause == null) { 122 System.out.println (pMessage); 123 } 124 else { 125 System.out.println (pMessage + ": " + pRootCause); 126 } 127 } 128 } 129 130 135 public void logWarning (String pTemplate) 136 throws ELException 137 { 138 if (isLoggingWarning ()) { 139 logWarning (pTemplate, null); 140 } 141 } 142 143 148 public void logWarning (Throwable pRootCause) 149 throws ELException 150 { 151 if (isLoggingWarning ()) { 152 logWarning (null, pRootCause); 153 } 154 } 155 156 161 public void logWarning (String pTemplate, 162 Object pArg0) 163 throws ELException 164 { 165 if (isLoggingWarning ()) { 166 logWarning 167 (MessageFormat.format 168 (pTemplate, 169 new Object [] { 170 "" + pArg0, 171 })); 172 } 173 } 174 175 180 public void logWarning (String pTemplate, 181 Throwable pRootCause, 182 Object pArg0) 183 throws ELException 184 { 185 if (isLoggingWarning ()) { 186 logWarning 187 (MessageFormat.format 188 (pTemplate, 189 new Object [] { 190 "" + pArg0, 191 }), 192 pRootCause); 193 } 194 } 195 196 201 public void logWarning (String pTemplate, 202 Object pArg0, 203 Object pArg1) 204 throws ELException 205 { 206 if (isLoggingWarning ()) { 207 logWarning 208 (MessageFormat.format 209 (pTemplate, 210 new Object [] { 211 "" + pArg0, 212 "" + pArg1, 213 })); 214 } 215 } 216 217 222 public void logWarning (String pTemplate, 223 Throwable pRootCause, 224 Object pArg0, 225 Object pArg1) 226 throws ELException 227 { 228 if (isLoggingWarning ()) { 229 logWarning 230 (MessageFormat.format 231 (pTemplate, 232 new Object [] { 233 "" + pArg0, 234 "" + pArg1, 235 }), 236 pRootCause); 237 } 238 } 239 240 245 public void logWarning (String pTemplate, 246 Object pArg0, 247 Object pArg1, 248 Object pArg2) 249 throws ELException 250 { 251 if (isLoggingWarning ()) { 252 logWarning 253 (MessageFormat.format 254 (pTemplate, 255 new Object [] { 256 "" + pArg0, 257 "" + pArg1, 258 "" + pArg2, 259 })); 260 } 261 } 262 263 268 public void logWarning (String pTemplate, 269 Throwable pRootCause, 270 Object pArg0, 271 Object pArg1, 272 Object pArg2) 273 throws ELException 274 { 275 if (isLoggingWarning ()) { 276 logWarning 277 (MessageFormat.format 278 (pTemplate, 279 new Object [] { 280 "" + pArg0, 281 "" + pArg1, 282 "" + pArg2, 283 }), 284 pRootCause); 285 } 286 } 287 288 293 public void logWarning (String pTemplate, 294 Object pArg0, 295 Object pArg1, 296 Object pArg2, 297 Object pArg3) 298 throws ELException 299 { 300 if (isLoggingWarning ()) { 301 logWarning 302 (MessageFormat.format 303 (pTemplate, 304 new Object [] { 305 "" + pArg0, 306 "" + pArg1, 307 "" + pArg2, 308 "" + pArg3, 309 })); 310 } 311 } 312 313 318 public void logWarning (String pTemplate, 319 Throwable pRootCause, 320 Object pArg0, 321 Object pArg1, 322 Object pArg2, 323 Object pArg3) 324 throws ELException 325 { 326 if (isLoggingWarning ()) { 327 logWarning 328 (MessageFormat.format 329 (pTemplate, 330 new Object [] { 331 "" + pArg0, 332 "" + pArg1, 333 "" + pArg2, 334 "" + pArg3, 335 }), 336 pRootCause); 337 } 338 } 339 340 345 public void logWarning (String pTemplate, 346 Object pArg0, 347 Object pArg1, 348 Object pArg2, 349 Object pArg3, 350 Object pArg4) 351 throws ELException 352 { 353 if (isLoggingWarning ()) { 354 logWarning 355 (MessageFormat.format 356 (pTemplate, 357 new Object [] { 358 "" + pArg0, 359 "" + pArg1, 360 "" + pArg2, 361 "" + pArg3, 362 "" + pArg4, 363 })); 364 } 365 } 366 367 372 public void logWarning (String pTemplate, 373 Throwable pRootCause, 374 Object pArg0, 375 Object pArg1, 376 Object pArg2, 377 Object pArg3, 378 Object pArg4) 379 throws ELException 380 { 381 if (isLoggingWarning ()) { 382 logWarning 383 (MessageFormat.format 384 (pTemplate, 385 new Object [] { 386 "" + pArg0, 387 "" + pArg1, 388 "" + pArg2, 389 "" + pArg3, 390 "" + pArg4, 391 }), 392 pRootCause); 393 } 394 } 395 396 401 public void logWarning (String pTemplate, 402 Object pArg0, 403 Object pArg1, 404 Object pArg2, 405 Object pArg3, 406 Object pArg4, 407 Object pArg5) 408 throws ELException 409 { 410 if (isLoggingWarning ()) { 411 logWarning 412 (MessageFormat.format 413 (pTemplate, 414 new Object [] { 415 "" + pArg0, 416 "" + pArg1, 417 "" + pArg2, 418 "" + pArg3, 419 "" + pArg4, 420 "" + pArg5, 421 })); 422 } 423 } 424 425 430 public void logWarning (String pTemplate, 431 Throwable pRootCause, 432 Object pArg0, 433 Object pArg1, 434 Object pArg2, 435 Object pArg3, 436 Object pArg4, 437 Object pArg5) 438 throws ELException 439 { 440 if (isLoggingWarning ()) { 441 logWarning 442 (MessageFormat.format 443 (pTemplate, 444 new Object [] { 445 "" + pArg0, 446 "" + pArg1, 447 "" + pArg2, 448 "" + pArg3, 449 "" + pArg4, 450 "" + pArg5, 451 }), 452 pRootCause); 453 } 454 } 455 456 462 public boolean isLoggingError () 463 { 464 return true; 465 } 466 467 472 public void logError (String pMessage, 473 Throwable pRootCause) 474 throws ELException 475 { 476 if (isLoggingError ()) { 477 if (pMessage == null) { 478 throw new ELException (pRootCause); 479 } 480 else if (pRootCause == null) { 481 throw new ELException (pMessage); 482 } 483 else { 484 throw new ELException (pMessage, pRootCause); 485 } 486 } 487 } 488 489 494 public void logError (String pTemplate) 495 throws ELException 496 { 497 if (isLoggingError ()) { 498 logError (pTemplate, null); 499 } 500 } 501 502 507 public void logError (Throwable pRootCause) 508 throws ELException 509 { 510 if (isLoggingError ()) { 511 logError (null, pRootCause); 512 } 513 } 514 515 520 public void logError (String pTemplate, 521 Object pArg0) 522 throws ELException 523 { 524 if (isLoggingError ()) { 525 logError 526 (MessageFormat.format 527 (pTemplate, 528 new Object [] { 529 "" + pArg0, 530 })); 531 } 532 } 533 534 539 public void logError (String pTemplate, 540 Throwable pRootCause, 541 Object pArg0) 542 throws ELException 543 { 544 if (isLoggingError ()) { 545 logError 546 (MessageFormat.format 547 (pTemplate, 548 new Object [] { 549 "" + pArg0, 550 }), 551 pRootCause); 552 } 553 } 554 555 560 public void logError (String pTemplate, 561 Object pArg0, 562 Object pArg1) 563 throws ELException 564 { 565 if (isLoggingError ()) { 566 logError 567 (MessageFormat.format 568 (pTemplate, 569 new Object [] { 570 "" + pArg0, 571 "" + pArg1, 572 })); 573 } 574 } 575 576 581 public void logError (String pTemplate, 582 Throwable pRootCause, 583 Object pArg0, 584 Object pArg1) 585 throws ELException 586 { 587 if (isLoggingError ()) { 588 logError 589 (MessageFormat.format 590 (pTemplate, 591 new Object [] { 592 "" + pArg0, 593 "" + pArg1, 594 }), 595 pRootCause); 596 } 597 } 598 599 604 public void logError (String pTemplate, 605 Object pArg0, 606 Object pArg1, 607 Object pArg2) 608 throws ELException 609 { 610 if (isLoggingError ()) { 611 logError 612 (MessageFormat.format 613 (pTemplate, 614 new Object [] { 615 "" + pArg0, 616 "" + pArg1, 617 "" + pArg2, 618 })); 619 } 620 } 621 622 627 public void logError (String pTemplate, 628 Throwable pRootCause, 629 Object pArg0, 630 Object pArg1, 631 Object pArg2) 632 throws ELException 633 { 634 if (isLoggingError ()) { 635 logError 636 (MessageFormat.format 637 (pTemplate, 638 new Object [] { 639 "" + pArg0, 640 "" + pArg1, 641 "" + pArg2, 642 }), 643 pRootCause); 644 } 645 } 646 647 652 public void logError (String pTemplate, 653 Object pArg0, 654 Object pArg1, 655 Object pArg2, 656 Object pArg3) 657 throws ELException 658 { 659 if (isLoggingError ()) { 660 logError 661 (MessageFormat.format 662 (pTemplate, 663 new Object [] { 664 "" + pArg0, 665 "" + pArg1, 666 "" + pArg2, 667 "" + pArg3, 668 })); 669 } 670 } 671 672 677 public void logError (String pTemplate, 678 Throwable pRootCause, 679 Object pArg0, 680 Object pArg1, 681 Object pArg2, 682 Object pArg3) 683 throws ELException 684 { 685 if (isLoggingError ()) { 686 logError 687 (MessageFormat.format 688 (pTemplate, 689 new Object [] { 690 "" + pArg0, 691 "" + pArg1, 692 "" + pArg2, 693 "" + pArg3, 694 }), 695 pRootCause); 696 } 697 } 698 699 704 public void logError (String pTemplate, 705 Object pArg0, 706 Object pArg1, 707 Object pArg2, 708 Object pArg3, 709 Object pArg4) 710 throws ELException 711 { 712 if (isLoggingError ()) { 713 logError 714 (MessageFormat.format 715 (pTemplate, 716 new Object [] { 717 "" + pArg0, 718 "" + pArg1, 719 "" + pArg2, 720 "" + pArg3, 721 "" + pArg4, 722 })); 723 } 724 } 725 726 731 public void logError (String pTemplate, 732 Throwable pRootCause, 733 Object pArg0, 734 Object pArg1, 735 Object pArg2, 736 Object pArg3, 737 Object pArg4) 738 throws ELException 739 { 740 if (isLoggingError ()) { 741 logError 742 (MessageFormat.format 743 (pTemplate, 744 new Object [] { 745 "" + pArg0, 746 "" + pArg1, 747 "" + pArg2, 748 "" + pArg3, 749 "" + pArg4, 750 }), 751 pRootCause); 752 } 753 } 754 755 760 public void logError (String pTemplate, 761 Object pArg0, 762 Object pArg1, 763 Object pArg2, 764 Object pArg3, 765 Object pArg4, 766 Object pArg5) 767 throws ELException 768 { 769 if (isLoggingError ()) { 770 logError 771 (MessageFormat.format 772 (pTemplate, 773 new Object [] { 774 "" + pArg0, 775 "" + pArg1, 776 "" + pArg2, 777 "" + pArg3, 778 "" + pArg4, 779 "" + pArg5, 780 })); 781 } 782 } 783 784 789 public void logError (String pTemplate, 790 Throwable pRootCause, 791 Object pArg0, 792 Object pArg1, 793 Object pArg2, 794 Object pArg3, 795 Object pArg4, 796 Object pArg5) 797 throws ELException 798 { 799 if (isLoggingError ()) { 800 logError 801 (MessageFormat.format 802 (pTemplate, 803 new Object [] { 804 "" + pArg0, 805 "" + pArg1, 806 "" + pArg2, 807 "" + pArg3, 808 "" + pArg4, 809 "" + pArg5, 810 }), 811 pRootCause); 812 } 813 } 814 815 } 817 | Popular Tags |