mirror of https://github.com/qos-ch/slf4j
setting autocrlf = true on windows - no logical changes
This commit is contained in:
parent
efaead1e06
commit
88c4c45676
|
|
@ -1,7 +1,7 @@
|
|||
.settings
|
||||
target
|
||||
.classpath
|
||||
.project
|
||||
*~
|
||||
integration/bundle/
|
||||
.settings
|
||||
target
|
||||
.classpath
|
||||
.project
|
||||
*~
|
||||
integration/bundle/
|
||||
integration/felix-cache/
|
||||
48
LICENSE.txt
48
LICENSE.txt
|
|
@ -1,24 +1,24 @@
|
|||
Copyright (c) 2004-2008 QOS.ch
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
Copyright (c) 2004-2008 QOS.ch
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,42 +1,42 @@
|
|||
|
||||
if ($#ARGV < 1) {
|
||||
print "Usage: binderVersion.pl VER FILE {FILE, FILE}\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$V= $ARGV[0];
|
||||
# Trim -SNAPSHOT
|
||||
$V =~ s/-SNAPSHOT//;
|
||||
|
||||
print "VER:${V}\r\n";
|
||||
shift(@ARGV);
|
||||
|
||||
sub replace () {
|
||||
my $filename = $_[0];
|
||||
|
||||
if(-s $filename) {
|
||||
print "Processing [" . $filename . "]\r\n";
|
||||
|
||||
my $original = "$filename.original";
|
||||
|
||||
rename($filename, $original);
|
||||
open(OUT, ">$filename");
|
||||
open(IN, "$original");
|
||||
|
||||
while(<IN>) {
|
||||
if(/VERSION\s+=\s+".*";/) {
|
||||
s/VERSION\s+=\s+".*";/VERSION = "${V}";/;
|
||||
}
|
||||
print OUT;
|
||||
}
|
||||
close(IN);
|
||||
close(OUT);
|
||||
unlink($original);
|
||||
} else {
|
||||
print "File [" . $filename . "] does not exist\r\n"
|
||||
}
|
||||
}
|
||||
|
||||
foreach $ARG (@ARGV) {
|
||||
do replace($ARG);
|
||||
}
|
||||
|
||||
if ($#ARGV < 1) {
|
||||
print "Usage: binderVersion.pl VER FILE {FILE, FILE}\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$V= $ARGV[0];
|
||||
# Trim -SNAPSHOT
|
||||
$V =~ s/-SNAPSHOT//;
|
||||
|
||||
print "VER:${V}\r\n";
|
||||
shift(@ARGV);
|
||||
|
||||
sub replace () {
|
||||
my $filename = $_[0];
|
||||
|
||||
if(-s $filename) {
|
||||
print "Processing [" . $filename . "]\r\n";
|
||||
|
||||
my $original = "$filename.original";
|
||||
|
||||
rename($filename, $original);
|
||||
open(OUT, ">$filename");
|
||||
open(IN, "$original");
|
||||
|
||||
while(<IN>) {
|
||||
if(/VERSION\s+=\s+".*";/) {
|
||||
s/VERSION\s+=\s+".*";/VERSION = "${V}";/;
|
||||
}
|
||||
print OUT;
|
||||
}
|
||||
close(IN);
|
||||
close(OUT);
|
||||
unlink($original);
|
||||
} else {
|
||||
print "File [" . $filename . "] does not exist\r\n"
|
||||
}
|
||||
}
|
||||
|
||||
foreach $ARG (@ARGV) {
|
||||
do replace($ARG);
|
||||
}
|
||||
|
|
|
|||
502
codeStyle.xml
502
codeStyle.xml
|
|
@ -1,251 +1,251 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<profiles version="10">
|
||||
<profile name="slf4jCodeStyle" version="10">
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="8"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
||||
</profile>
|
||||
</profiles>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<profiles version="10">
|
||||
<profile name="slf4jCodeStyle" version="10">
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_binary_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="end_of_line"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="8"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_binary_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_binary_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
|
|
|||
|
|
@ -1,95 +1,95 @@
|
|||
<project name="integration" default="testAll" basedir=".">
|
||||
|
||||
<!--
|
||||
This build file is usually run indirectly via Maven.
|
||||
|
||||
When running this build file through Ant directly, you must
|
||||
define the currentVersion property on the command line, e.g.:
|
||||
|
||||
ant -DcurrentVersion=1.5.4-SNAPSHOT
|
||||
-->
|
||||
|
||||
<echo message="compile classpath: ${compile_classpath}" />
|
||||
<echo message="runtime classpath: ${runtime_classpath}" />
|
||||
<echo message="test classpath: ${test_classpath}" />
|
||||
<echo message="plugin classpath: ${plugin_classpath}" />
|
||||
|
||||
<path id="path150">
|
||||
<pathelement location="xtarget/classes/" />
|
||||
<pathelement location="target/test-classes/" />
|
||||
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
|
||||
<pathelement location="./lib/slf4j-simple-1.5.0.jar" />
|
||||
</path >
|
||||
|
||||
<path id="pathIncompatible">
|
||||
<pathelement location="xtarget/classes/" />
|
||||
<pathelement location="target/test-classes/" />
|
||||
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
|
||||
<pathelement location="./lib/slf4j-simple-INCOMPATIBLE.jar" />
|
||||
</path >
|
||||
|
||||
<path id="pathCurrent">
|
||||
<pathelement location="xtarget/classes/" />
|
||||
<pathelement location="target/test-classes/" />
|
||||
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
|
||||
<pathelement location="../slf4j-simple/target/slf4j-simple-${currentVersion}.jar" />
|
||||
</path >
|
||||
|
||||
|
||||
<path id="multiBinding">
|
||||
<pathelement location="xtarget/classes/" />
|
||||
<pathelement location="target/test-classes/" />
|
||||
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
|
||||
<pathelement location="./lib/slf4j-simple-1.5.0.jar" />
|
||||
<pathelement location="./lib/slf4j-nop-1.5.6.jar" />
|
||||
</path >
|
||||
|
||||
<!-- this is really very ugly, but it's the only way to circumvent
|
||||
http://jira.codehaus.org/browse/MANTRUN-95
|
||||
-->
|
||||
<taskdef name="junit" classpath="${plugin_classpath};${compile_classpath}"
|
||||
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="target/unit-reports" />
|
||||
</target>
|
||||
|
||||
<target name="testAll" depends="init,
|
||||
testMismatch,
|
||||
testPre155,
|
||||
testMatch,
|
||||
testMultiBinding">
|
||||
</target>
|
||||
|
||||
<target name="testMismatch">
|
||||
<junit printsummary="yes" fork="no" haltonfailure="yes">
|
||||
<classpath refid="pathIncompatible" />
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.VersionMismatchTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="testPre155">
|
||||
<junit printsummary="yes" fork="no" haltonfailure="yes">
|
||||
<classpath refid="path150" />
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.Pre155VersionTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="testMatch">
|
||||
<junit printsummary="yes" fork="no" haltonfailure="yes">
|
||||
<classpath refid="pathCurrent" />
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.VersionMatchTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="testMultiBinding">
|
||||
<junit printsummary="yes" fork="no" haltonfailure="yes">
|
||||
<classpath refid="multiBinding" />
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.MultiBindingTest" />
|
||||
</junit>
|
||||
</target>
|
||||
<project name="integration" default="testAll" basedir=".">
|
||||
|
||||
<!--
|
||||
This build file is usually run indirectly via Maven.
|
||||
|
||||
When running this build file through Ant directly, you must
|
||||
define the currentVersion property on the command line, e.g.:
|
||||
|
||||
ant -DcurrentVersion=1.5.4-SNAPSHOT
|
||||
-->
|
||||
|
||||
<echo message="compile classpath: ${compile_classpath}" />
|
||||
<echo message="runtime classpath: ${runtime_classpath}" />
|
||||
<echo message="test classpath: ${test_classpath}" />
|
||||
<echo message="plugin classpath: ${plugin_classpath}" />
|
||||
|
||||
<path id="path150">
|
||||
<pathelement location="xtarget/classes/" />
|
||||
<pathelement location="target/test-classes/" />
|
||||
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
|
||||
<pathelement location="./lib/slf4j-simple-1.5.0.jar" />
|
||||
</path >
|
||||
|
||||
<path id="pathIncompatible">
|
||||
<pathelement location="xtarget/classes/" />
|
||||
<pathelement location="target/test-classes/" />
|
||||
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
|
||||
<pathelement location="./lib/slf4j-simple-INCOMPATIBLE.jar" />
|
||||
</path >
|
||||
|
||||
<path id="pathCurrent">
|
||||
<pathelement location="xtarget/classes/" />
|
||||
<pathelement location="target/test-classes/" />
|
||||
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
|
||||
<pathelement location="../slf4j-simple/target/slf4j-simple-${currentVersion}.jar" />
|
||||
</path >
|
||||
|
||||
|
||||
<path id="multiBinding">
|
||||
<pathelement location="xtarget/classes/" />
|
||||
<pathelement location="target/test-classes/" />
|
||||
<pathelement location="../slf4j-api/target/slf4j-api-${currentVersion}.jar" />
|
||||
<pathelement location="./lib/slf4j-simple-1.5.0.jar" />
|
||||
<pathelement location="./lib/slf4j-nop-1.5.6.jar" />
|
||||
</path >
|
||||
|
||||
<!-- this is really very ugly, but it's the only way to circumvent
|
||||
http://jira.codehaus.org/browse/MANTRUN-95
|
||||
-->
|
||||
<taskdef name="junit" classpath="${plugin_classpath};${compile_classpath}"
|
||||
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="target/unit-reports" />
|
||||
</target>
|
||||
|
||||
<target name="testAll" depends="init,
|
||||
testMismatch,
|
||||
testPre155,
|
||||
testMatch,
|
||||
testMultiBinding">
|
||||
</target>
|
||||
|
||||
<target name="testMismatch">
|
||||
<junit printsummary="yes" fork="no" haltonfailure="yes">
|
||||
<classpath refid="pathIncompatible" />
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.VersionMismatchTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="testPre155">
|
||||
<junit printsummary="yes" fork="no" haltonfailure="yes">
|
||||
<classpath refid="path150" />
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.Pre155VersionTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="testMatch">
|
||||
<junit printsummary="yes" fork="no" haltonfailure="yes">
|
||||
<classpath refid="pathCurrent" />
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.VersionMatchTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="testMultiBinding">
|
||||
<junit printsummary="yes" fork="no" haltonfailure="yes">
|
||||
<classpath refid="multiBinding" />
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.MultiBindingTest" />
|
||||
</junit>
|
||||
</target>
|
||||
</project>
|
||||
|
|
@ -1,92 +1,92 @@
|
|||
<project name="osgi-test" default="testAll">
|
||||
|
||||
<!--
|
||||
This build file is usually run indirectly via Maven.
|
||||
|
||||
When running this build file through Ant directly, you must
|
||||
define the currentVersion property on the command line, e.g.:
|
||||
|
||||
ant -DcurrentVersion=1.5.4-SNAPSHOT
|
||||
-->
|
||||
|
||||
<echo message="compile classpath: ${currentVersion}" />
|
||||
<echo message="test classpath: ${test_classpath}" />
|
||||
<echo message="basedir: ${basedir}" />
|
||||
|
||||
<property name="iBundleJar" value="target/iBundle.jar"/>
|
||||
<property name="bundlesDir" value="bundle"/>
|
||||
|
||||
|
||||
<!-- this is really very ugly, but it's the only way to circumvent
|
||||
http://jira.codehaus.org/browse/MANTRUN-95
|
||||
-->
|
||||
<taskdef name="junit" classpath="${test_classpath}"
|
||||
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />
|
||||
|
||||
<path id="minimal">
|
||||
<pathelement location="target/test-classes/" />
|
||||
</path >
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="target/unit-reports" />
|
||||
</target>
|
||||
|
||||
<target name="createIBundle">
|
||||
<mkdir dir="${bundlesDir}"/>
|
||||
<jar destFile="${iBundleJar}"
|
||||
manifest="src/IBUNDLE-META-INF/MANIFEST.MF"
|
||||
basedir="target/test-classes/"
|
||||
includes="integrator/**.class"/>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="testAll" depends="init, createIBundle, nop, simple, jdk14">
|
||||
</target>
|
||||
|
||||
|
||||
<macrodef name="prepareOSGiHarness">
|
||||
<attribute name="binding"/>
|
||||
<sequential>
|
||||
<delete>
|
||||
<fileset dir="${bundlesDir}" includes="*.jar"/>
|
||||
</delete>
|
||||
<copy file="${iBundleJar}" todir="${bundlesDir}"/>
|
||||
<copy file="../slf4j-api/target/slf4j-api-${currentVersion}.jar" todir="${bundlesDir}"/>
|
||||
<copy file="../slf4j-@{binding}/target/slf4j-@{binding}-${currentVersion}.jar" todir="${bundlesDir}"/>
|
||||
<echo>value of t = @{t}</echo>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- for some reason if mvn is invoked from the parent directory, junit gets
|
||||
invoked from the parent dir, which messes up theses tests. Hence, the
|
||||
fork="yes" dir="${basedir}" -->
|
||||
|
||||
<target name="nop">
|
||||
<prepareOSGiHarness binding="nop"/>
|
||||
<junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
|
||||
<classpath path="${test_classpath}"/>
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.test_osgi.BundleTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="simple">
|
||||
<prepareOSGiHarness binding="simple"/>
|
||||
<junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
|
||||
<classpath path="${test_classpath}"/>
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.test_osgi.BundleTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="jdk14">
|
||||
<prepareOSGiHarness binding="jdk14"/>
|
||||
<junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
|
||||
<classpath path="${test_classpath}"/>
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.test_osgi.BundleTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<project name="osgi-test" default="testAll">
|
||||
|
||||
<!--
|
||||
This build file is usually run indirectly via Maven.
|
||||
|
||||
When running this build file through Ant directly, you must
|
||||
define the currentVersion property on the command line, e.g.:
|
||||
|
||||
ant -DcurrentVersion=1.5.4-SNAPSHOT
|
||||
-->
|
||||
|
||||
<echo message="compile classpath: ${currentVersion}" />
|
||||
<echo message="test classpath: ${test_classpath}" />
|
||||
<echo message="basedir: ${basedir}" />
|
||||
|
||||
<property name="iBundleJar" value="target/iBundle.jar"/>
|
||||
<property name="bundlesDir" value="bundle"/>
|
||||
|
||||
|
||||
<!-- this is really very ugly, but it's the only way to circumvent
|
||||
http://jira.codehaus.org/browse/MANTRUN-95
|
||||
-->
|
||||
<taskdef name="junit" classpath="${test_classpath}"
|
||||
classname="org.apache.tools.ant.taskdefs.optional.junit.JUnitTask" />
|
||||
|
||||
<path id="minimal">
|
||||
<pathelement location="target/test-classes/" />
|
||||
</path >
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="target/unit-reports" />
|
||||
</target>
|
||||
|
||||
<target name="createIBundle">
|
||||
<mkdir dir="${bundlesDir}"/>
|
||||
<jar destFile="${iBundleJar}"
|
||||
manifest="src/IBUNDLE-META-INF/MANIFEST.MF"
|
||||
basedir="target/test-classes/"
|
||||
includes="integrator/**.class"/>
|
||||
|
||||
</target>
|
||||
|
||||
<target name="testAll" depends="init, createIBundle, nop, simple, jdk14">
|
||||
</target>
|
||||
|
||||
|
||||
<macrodef name="prepareOSGiHarness">
|
||||
<attribute name="binding"/>
|
||||
<sequential>
|
||||
<delete>
|
||||
<fileset dir="${bundlesDir}" includes="*.jar"/>
|
||||
</delete>
|
||||
<copy file="${iBundleJar}" todir="${bundlesDir}"/>
|
||||
<copy file="../slf4j-api/target/slf4j-api-${currentVersion}.jar" todir="${bundlesDir}"/>
|
||||
<copy file="../slf4j-@{binding}/target/slf4j-@{binding}-${currentVersion}.jar" todir="${bundlesDir}"/>
|
||||
<echo>value of t = @{t}</echo>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
|
||||
<!-- for some reason if mvn is invoked from the parent directory, junit gets
|
||||
invoked from the parent dir, which messes up theses tests. Hence, the
|
||||
fork="yes" dir="${basedir}" -->
|
||||
|
||||
<target name="nop">
|
||||
<prepareOSGiHarness binding="nop"/>
|
||||
<junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
|
||||
<classpath path="${test_classpath}"/>
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.test_osgi.BundleTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="simple">
|
||||
<prepareOSGiHarness binding="simple"/>
|
||||
<junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
|
||||
<classpath path="${test_classpath}"/>
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.test_osgi.BundleTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="jdk14">
|
||||
<prepareOSGiHarness binding="jdk14"/>
|
||||
<junit printsummary="yes" fork="yes" dir="${basedir}" haltonfailure="yes">
|
||||
<classpath path="${test_classpath}"/>
|
||||
<formatter type="plain" />
|
||||
<test fork="yes" todir="target/unit-reports" name="org.slf4j.test_osgi.BundleTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,121 +1,121 @@
|
|||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>integration</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>SLF4J Integration tests</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
<description>SLF4J integration tests</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- declaration to cimcumvent http://jira.codehaus.org/browse/MANTRUN-95 -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
<!-- declaration to cimcumvent http://jira.codehaus.org/browse/MANTRUN-95 -->
|
||||
<dependency>
|
||||
<groupId>ant</groupId>
|
||||
<artifactId>ant-junit</artifactId>
|
||||
<version>1.6.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- some test run Felix in hosted mode -->
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.main</artifactId>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.2</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ant</groupId>
|
||||
<artifactId>ant-junit</artifactId>
|
||||
<version>1.6.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>ant-test</id>
|
||||
<phase>package</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<property name="currentVersion" value="${version}" />
|
||||
<property name="compile_classpath" refid="maven.compile.classpath"/>
|
||||
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
|
||||
<property name="test_classpath" refid="maven.test.classpath"/>
|
||||
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
|
||||
<ant antfile="${basedir}/build.xml"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>ant-osgi-test</id>
|
||||
<phase>package</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<property name="currentVersion" value="${version}" />
|
||||
<property name="test_classpath" refid="maven.test.classpath"/>
|
||||
<property name="basedir" value="${basedir}"/>
|
||||
<ant antfile="${basedir}/osgi-build.xml"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<forkMode>once</forkMode>
|
||||
<reportFormat>plain</reportFormat>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
<excludes>
|
||||
<exclude>**/*Test.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
|
||||
</build>
|
||||
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>integration</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>SLF4J Integration tests</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
<description>SLF4J integration tests</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- declaration to cimcumvent http://jira.codehaus.org/browse/MANTRUN-95 -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
<!-- declaration to cimcumvent http://jira.codehaus.org/browse/MANTRUN-95 -->
|
||||
<dependency>
|
||||
<groupId>ant</groupId>
|
||||
<artifactId>ant-junit</artifactId>
|
||||
<version>1.6.5</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- some test run Felix in hosted mode -->
|
||||
<dependency>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>org.apache.felix.main</artifactId>
|
||||
<version>2.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<version>1.2</version>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ant</groupId>
|
||||
<artifactId>ant-junit</artifactId>
|
||||
<version>1.6.5</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>ant-test</id>
|
||||
<phase>package</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<property name="currentVersion" value="${version}" />
|
||||
<property name="compile_classpath" refid="maven.compile.classpath"/>
|
||||
<property name="runtime_classpath" refid="maven.runtime.classpath"/>
|
||||
<property name="test_classpath" refid="maven.test.classpath"/>
|
||||
<property name="plugin_classpath" refid="maven.plugin.classpath"/>
|
||||
<ant antfile="${basedir}/build.xml"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>ant-osgi-test</id>
|
||||
<phase>package</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<property name="currentVersion" value="${version}" />
|
||||
<property name="test_classpath" refid="maven.test.classpath"/>
|
||||
<property name="basedir" value="${basedir}"/>
|
||||
<ant antfile="${basedir}/osgi-build.xml"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<forkMode>once</forkMode>
|
||||
<reportFormat>plain</reportFormat>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
<excludes>
|
||||
<exclude>**/*Test.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,15 +1,15 @@
|
|||
Manifest-Version: 1.0
|
||||
Archiver-Version: Plexus Archiver
|
||||
Created-By: Apache Maven
|
||||
Built-By: ceki
|
||||
Build-Jdk: 1.6.0_16
|
||||
Bundle-Description: iBundle
|
||||
Bundle-Version: 0.1
|
||||
Bundle-Activator: integrator.Activator
|
||||
Implementation-Title: iBundle
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-SymbolicName: iBundle
|
||||
Bundle-Name: abundle
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.3
|
||||
Export-Package: apack
|
||||
Manifest-Version: 1.0
|
||||
Archiver-Version: Plexus Archiver
|
||||
Created-By: Apache Maven
|
||||
Built-By: ceki
|
||||
Build-Jdk: 1.6.0_16
|
||||
Bundle-Description: iBundle
|
||||
Bundle-Version: 0.1
|
||||
Bundle-Activator: integrator.Activator
|
||||
Implementation-Title: iBundle
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-SymbolicName: iBundle
|
||||
Bundle-Name: abundle
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.3
|
||||
Export-Package: apack
|
||||
Import-Package: org.osgi.framework, org.slf4j;version=1.5
|
||||
|
|
@ -1,57 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package integrator;
|
||||
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A BundleActivator which invokes slf4j loggers
|
||||
* @author Ceki Gülcü
|
||||
*
|
||||
*/
|
||||
public class Activator implements BundleActivator {
|
||||
|
||||
private BundleContext m_context = null;
|
||||
|
||||
public void start(BundleContext context) {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
logger.info("Activator.start()");
|
||||
m_context = context;
|
||||
}
|
||||
|
||||
public void stop(BundleContext context) {
|
||||
m_context = null;
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
logger.info("Activator.stop");
|
||||
}
|
||||
|
||||
public Bundle[] getBundles() {
|
||||
if (m_context != null) {
|
||||
return m_context.getBundles();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package integrator;
|
||||
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* A BundleActivator which invokes slf4j loggers
|
||||
* @author Ceki Gülcü
|
||||
*
|
||||
*/
|
||||
public class Activator implements BundleActivator {
|
||||
|
||||
private BundleContext m_context = null;
|
||||
|
||||
public void start(BundleContext context) {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
logger.info("Activator.start()");
|
||||
m_context = context;
|
||||
}
|
||||
|
||||
public void stop(BundleContext context) {
|
||||
m_context = null;
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
logger.info("Activator.stop");
|
||||
}
|
||||
|
||||
public Bundle[] getBundles() {
|
||||
if (m_context != null) {
|
||||
return m_context.getBundles();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,62 +1,62 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Random;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class MultiBindingTest extends TestCase {
|
||||
|
||||
StringPrintStream sps = new StringPrintStream(System.err);
|
||||
PrintStream old = System.err;
|
||||
int diff = 1024 + new Random().nextInt(10000);
|
||||
|
||||
public MultiBindingTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
System.setErr(sps);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
System.setErr(old);
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
String msg = "hello world " + diff;
|
||||
logger.info(msg);
|
||||
assertTrue("number of lines should be greater than 4", sps.stringList
|
||||
.size() > 4);
|
||||
String s0 = (String) sps.stringList.get(0);
|
||||
assertTrue(s0
|
||||
.contains("SLF4J: Class path contains multiple SLF4J bindings."));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Random;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class MultiBindingTest extends TestCase {
|
||||
|
||||
StringPrintStream sps = new StringPrintStream(System.err);
|
||||
PrintStream old = System.err;
|
||||
int diff = 1024 + new Random().nextInt(10000);
|
||||
|
||||
public MultiBindingTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
System.setErr(sps);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
System.setErr(old);
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
String msg = "hello world " + diff;
|
||||
logger.info(msg);
|
||||
assertTrue("number of lines should be greater than 4", sps.stringList
|
||||
.size() > 4);
|
||||
String s0 = (String) sps.stringList.get(0);
|
||||
assertTrue(s0
|
||||
.contains("SLF4J: Class path contains multiple SLF4J bindings."));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,59 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Random;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class Pre155VersionTest extends TestCase {
|
||||
|
||||
StringPrintStream sps = new StringPrintStream(System.err);
|
||||
PrintStream old = System.err;
|
||||
int diff = 1024 + new Random().nextInt(10000);
|
||||
|
||||
public Pre155VersionTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
System.setErr(sps);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
System.setErr(old);
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
String msg = "hello world " + diff;
|
||||
logger.info(msg);
|
||||
String s0 = (String) sps.stringList.get(0);
|
||||
assertTrue(s0.contains(msg));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Random;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class Pre155VersionTest extends TestCase {
|
||||
|
||||
StringPrintStream sps = new StringPrintStream(System.err);
|
||||
PrintStream old = System.err;
|
||||
int diff = 1024 + new Random().nextInt(10000);
|
||||
|
||||
public Pre155VersionTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
System.setErr(sps);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
System.setErr(old);
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
String msg = "hello world " + diff;
|
||||
logger.info(msg);
|
||||
String s0 = (String) sps.stringList.get(0);
|
||||
assertTrue(s0.contains(msg));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,34 +1,34 @@
|
|||
package org.slf4j;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StringPrintStream extends PrintStream {
|
||||
|
||||
public static final String LINE_SEP = System.getProperty("line.separator");
|
||||
PrintStream other;
|
||||
List stringList = new ArrayList();
|
||||
|
||||
public StringPrintStream(PrintStream ps) {
|
||||
super(ps);
|
||||
other = ps;
|
||||
}
|
||||
|
||||
public void print(String s) {
|
||||
other.print(s);
|
||||
stringList.add(s);
|
||||
}
|
||||
|
||||
public void println(String s) {
|
||||
other.println(s);
|
||||
stringList.add(s);
|
||||
|
||||
}
|
||||
|
||||
public void println(Object o) {
|
||||
other.println(o);
|
||||
stringList.add(o);
|
||||
}
|
||||
}
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class StringPrintStream extends PrintStream {
|
||||
|
||||
public static final String LINE_SEP = System.getProperty("line.separator");
|
||||
PrintStream other;
|
||||
List stringList = new ArrayList();
|
||||
|
||||
public StringPrintStream(PrintStream ps) {
|
||||
super(ps);
|
||||
other = ps;
|
||||
}
|
||||
|
||||
public void print(String s) {
|
||||
other.print(s);
|
||||
stringList.add(s);
|
||||
}
|
||||
|
||||
public void println(String s) {
|
||||
other.println(s);
|
||||
stringList.add(s);
|
||||
|
||||
}
|
||||
|
||||
public void println(Object o) {
|
||||
other.println(o);
|
||||
stringList.add(o);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,39 +1,39 @@
|
|||
|
||||
package org.slf4j;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Random;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class VersionMatchTest extends TestCase {
|
||||
|
||||
|
||||
StringPrintStream sps = new StringPrintStream(System.err);
|
||||
PrintStream old = System.err;
|
||||
int diff = 1024 + new Random().nextInt(10000);
|
||||
|
||||
public VersionMatchTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
System.setErr(sps);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
System.setErr(old);
|
||||
}
|
||||
|
||||
|
||||
public void test() throws Exception {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
String msg = "hello world "+diff;
|
||||
logger.info(msg);
|
||||
assertEquals(1, sps.stringList.size());
|
||||
String s0 = (String) sps.stringList.get(0);
|
||||
assertTrue(s0.contains(msg));
|
||||
}
|
||||
}
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Random;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class VersionMatchTest extends TestCase {
|
||||
|
||||
|
||||
StringPrintStream sps = new StringPrintStream(System.err);
|
||||
PrintStream old = System.err;
|
||||
int diff = 1024 + new Random().nextInt(10000);
|
||||
|
||||
public VersionMatchTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
System.setErr(sps);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
System.setErr(old);
|
||||
}
|
||||
|
||||
|
||||
public void test() throws Exception {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
String msg = "hello world "+diff;
|
||||
logger.info(msg);
|
||||
assertEquals(1, sps.stringList.size());
|
||||
String s0 = (String) sps.stringList.get(0);
|
||||
assertTrue(s0.contains(msg));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +1,43 @@
|
|||
package org.slf4j;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Random;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class VersionMismatchTest extends TestCase {
|
||||
|
||||
StringPrintStream sps = new StringPrintStream(System.err);
|
||||
PrintStream old = System.err;
|
||||
int diff = 1024 + new Random().nextInt(10000);
|
||||
|
||||
public VersionMismatchTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
System.setErr(sps);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
System.setErr(old);
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
String msg = "hello world " + diff;
|
||||
logger.info(msg);
|
||||
|
||||
String s0 = (String) sps.stringList.get(0);
|
||||
assertTrue(s0.matches("SLF4J: The requested version .* by your slf4j binding is not compatible with.*"));
|
||||
|
||||
String s1 = (String) sps.stringList.get(1);
|
||||
assertTrue(s1.contains(LoggerFactory.VERSION_MISMATCH));
|
||||
|
||||
String s2 = (String) sps.stringList.get(2);
|
||||
assertTrue(s2.contains(msg));
|
||||
|
||||
}
|
||||
}
|
||||
package org.slf4j;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Random;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class VersionMismatchTest extends TestCase {
|
||||
|
||||
StringPrintStream sps = new StringPrintStream(System.err);
|
||||
PrintStream old = System.err;
|
||||
int diff = 1024 + new Random().nextInt(10000);
|
||||
|
||||
public VersionMismatchTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
System.setErr(sps);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
System.setErr(old);
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
String msg = "hello world " + diff;
|
||||
logger.info(msg);
|
||||
|
||||
String s0 = (String) sps.stringList.get(0);
|
||||
assertTrue(s0.matches("SLF4J: The requested version .* by your slf4j binding is not compatible with.*"));
|
||||
|
||||
String s1 = (String) sps.stringList.get(1);
|
||||
assertTrue(s1.contains(LoggerFactory.VERSION_MISMATCH));
|
||||
|
||||
String s2 = (String) sps.stringList.get(2);
|
||||
assertTrue(s2.contains(msg));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
package org.slf4j.test_osgi;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class BundleTest extends TestCase {
|
||||
|
||||
FrameworkErrorListener fel = new FrameworkErrorListener();
|
||||
CheckingBundleListener mbl = new CheckingBundleListener();
|
||||
|
||||
FelixHost felixHost = new FelixHost(fel, mbl);
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
felixHost.doLaunch();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
felixHost.stop();
|
||||
}
|
||||
|
||||
public void testSmoke() {
|
||||
System.out.println("==========="+new File(".").getAbsolutePath());
|
||||
mbl.dumpAll();
|
||||
// check that the bundle was installed
|
||||
assertTrue(mbl.exists("iBundle"));
|
||||
if(fel.errorList.size() != 0) {
|
||||
fel.dumpAll();
|
||||
}
|
||||
// check that no errors occured
|
||||
assertEquals(0, fel.errorList.size());
|
||||
}
|
||||
}
|
||||
package org.slf4j.test_osgi;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class BundleTest extends TestCase {
|
||||
|
||||
FrameworkErrorListener fel = new FrameworkErrorListener();
|
||||
CheckingBundleListener mbl = new CheckingBundleListener();
|
||||
|
||||
FelixHost felixHost = new FelixHost(fel, mbl);
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
felixHost.doLaunch();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
felixHost.stop();
|
||||
}
|
||||
|
||||
public void testSmoke() {
|
||||
System.out.println("==========="+new File(".").getAbsolutePath());
|
||||
mbl.dumpAll();
|
||||
// check that the bundle was installed
|
||||
assertTrue(mbl.exists("iBundle"));
|
||||
if(fel.errorList.size() != 0) {
|
||||
fel.dumpAll();
|
||||
}
|
||||
// check that no errors occured
|
||||
assertEquals(0, fel.errorList.size());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,43 +1,43 @@
|
|||
package org.slf4j.test_osgi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleEvent;
|
||||
import org.osgi.framework.BundleListener;
|
||||
|
||||
public class CheckingBundleListener implements BundleListener {
|
||||
|
||||
List eventList = new ArrayList();
|
||||
|
||||
public void bundleChanged(BundleEvent be) {
|
||||
eventList.add(be);
|
||||
}
|
||||
|
||||
private void dump(BundleEvent be) {
|
||||
System.out.println("BE:" + ", source " + be.getSource() + ", bundle="
|
||||
+ be.getBundle() + ", type=" + be.getType());
|
||||
|
||||
}
|
||||
|
||||
public void dumpAll() {
|
||||
for (int i = 0; i < eventList.size(); i++) {
|
||||
BundleEvent fe = (BundleEvent) eventList.get(i);
|
||||
dump(fe);
|
||||
}
|
||||
}
|
||||
|
||||
boolean exists(String bundleName) {
|
||||
for (int i = 0; i < eventList.size(); i++) {
|
||||
BundleEvent fe = (BundleEvent) eventList.get(i);
|
||||
Bundle b = fe.getBundle();
|
||||
System.out.println("===["+b+"]");
|
||||
if (bundleName.equals(b.getSymbolicName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
package org.slf4j.test_osgi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleEvent;
|
||||
import org.osgi.framework.BundleListener;
|
||||
|
||||
public class CheckingBundleListener implements BundleListener {
|
||||
|
||||
List eventList = new ArrayList();
|
||||
|
||||
public void bundleChanged(BundleEvent be) {
|
||||
eventList.add(be);
|
||||
}
|
||||
|
||||
private void dump(BundleEvent be) {
|
||||
System.out.println("BE:" + ", source " + be.getSource() + ", bundle="
|
||||
+ be.getBundle() + ", type=" + be.getType());
|
||||
|
||||
}
|
||||
|
||||
public void dumpAll() {
|
||||
for (int i = 0; i < eventList.size(); i++) {
|
||||
BundleEvent fe = (BundleEvent) eventList.get(i);
|
||||
dump(fe);
|
||||
}
|
||||
}
|
||||
|
||||
boolean exists(String bundleName) {
|
||||
for (int i = 0; i < eventList.size(); i++) {
|
||||
BundleEvent fe = (BundleEvent) eventList.get(i);
|
||||
Bundle b = fe.getBundle();
|
||||
System.out.println("===["+b+"]");
|
||||
if (bundleName.equals(b.getSymbolicName())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,126 +1,126 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package org.slf4j.test_osgi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.felix.framework.Felix;
|
||||
import org.apache.felix.framework.util.FelixConstants;
|
||||
import org.apache.felix.framework.util.StringMap;
|
||||
import org.apache.felix.main.AutoProcessor;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.BundleException;
|
||||
import org.osgi.framework.Constants;
|
||||
|
||||
/**
|
||||
* Runs a hosted version of Felix for testing purposes. Any bundle errors are
|
||||
* reported via the FrameworkListener passed to the constructor.
|
||||
*
|
||||
* @author Ceki Gücü
|
||||
*/
|
||||
public class FelixHost {
|
||||
|
||||
private Felix felix = null;
|
||||
|
||||
Properties otherProps = new Properties();
|
||||
|
||||
final FrameworkErrorListener frameworkErrorListener;
|
||||
final CheckingBundleListener myBundleListener;
|
||||
|
||||
public FelixHost(FrameworkErrorListener frameworkErrorListener,
|
||||
CheckingBundleListener myBundleListener) {
|
||||
this.frameworkErrorListener = frameworkErrorListener;
|
||||
this.myBundleListener = myBundleListener;
|
||||
}
|
||||
|
||||
public void doLaunch() {
|
||||
// Create a case-insensitive configuration property map.
|
||||
Map configMap = new StringMap(false);
|
||||
// Configure the Felix instance to be embedded.
|
||||
// configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true");
|
||||
// Add core OSGi packages to be exported from the class path
|
||||
// via the system bundle.
|
||||
configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
|
||||
"org.osgi.framework; version=1.3.0,"
|
||||
+ "org.osgi.service.packageadmin; version=1.2.0,"
|
||||
+ "org.osgi.service.startlevel; version=1.0.0,"
|
||||
+ "org.osgi.service.url; version=1.0.0");
|
||||
|
||||
configMap.put(Constants.FRAMEWORK_STORAGE_CLEAN,
|
||||
Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
|
||||
|
||||
// Explicitly specify the directory to use for caching bundles.
|
||||
// configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, "cache");
|
||||
|
||||
try {
|
||||
// Create host activator;
|
||||
|
||||
List list = new ArrayList();
|
||||
|
||||
// list.add(new HostActivator());
|
||||
configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
|
||||
"org.xml.sax, org.xml.sax.helpers, javax.xml.parsers, javax.naming");
|
||||
configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
|
||||
configMap.put("felix.log.level", "4");
|
||||
|
||||
// Now create an instance of the framework with
|
||||
// our configuration properties and activator.
|
||||
felix = new Felix(configMap);
|
||||
felix.init();
|
||||
|
||||
// otherProps.put(Constants.FRAMEWORK_STORAGE, "bundles");
|
||||
|
||||
otherProps.put(AutoProcessor.AUTO_DEPLOY_DIR_PROPERY,
|
||||
AutoProcessor.AUTO_DEPLOY_DIR_VALUE);
|
||||
otherProps.put(AutoProcessor.AUTO_DEPLOY_ACTION_PROPERY,
|
||||
AutoProcessor.AUTO_DEPLOY_START_VALUE + ","
|
||||
+ AutoProcessor.AUTO_DEPLOY_INSTALL_VALUE);
|
||||
|
||||
BundleContext felixBudleContext = felix.getBundleContext();
|
||||
|
||||
AutoProcessor.process(otherProps, felixBudleContext);
|
||||
// listen to errors
|
||||
felixBudleContext.addFrameworkListener(frameworkErrorListener);
|
||||
felixBudleContext.addBundleListener(myBundleListener);
|
||||
// Now start Felix instance.
|
||||
felix.start();
|
||||
System.out.println("felix started");
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() throws BundleException {
|
||||
felix.stop();
|
||||
}
|
||||
|
||||
public Bundle[] getInstalledBundles() {
|
||||
// Use the system bundle activator to gain external
|
||||
// access to the set of installed bundles.
|
||||
return null;// m_activator.getBundles();
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package org.slf4j.test_osgi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.felix.framework.Felix;
|
||||
import org.apache.felix.framework.util.FelixConstants;
|
||||
import org.apache.felix.framework.util.StringMap;
|
||||
import org.apache.felix.main.AutoProcessor;
|
||||
import org.osgi.framework.Bundle;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.BundleException;
|
||||
import org.osgi.framework.Constants;
|
||||
|
||||
/**
|
||||
* Runs a hosted version of Felix for testing purposes. Any bundle errors are
|
||||
* reported via the FrameworkListener passed to the constructor.
|
||||
*
|
||||
* @author Ceki Gücü
|
||||
*/
|
||||
public class FelixHost {
|
||||
|
||||
private Felix felix = null;
|
||||
|
||||
Properties otherProps = new Properties();
|
||||
|
||||
final FrameworkErrorListener frameworkErrorListener;
|
||||
final CheckingBundleListener myBundleListener;
|
||||
|
||||
public FelixHost(FrameworkErrorListener frameworkErrorListener,
|
||||
CheckingBundleListener myBundleListener) {
|
||||
this.frameworkErrorListener = frameworkErrorListener;
|
||||
this.myBundleListener = myBundleListener;
|
||||
}
|
||||
|
||||
public void doLaunch() {
|
||||
// Create a case-insensitive configuration property map.
|
||||
Map configMap = new StringMap(false);
|
||||
// Configure the Felix instance to be embedded.
|
||||
// configMap.put(FelixConstants.EMBEDDED_EXECUTION_PROP, "true");
|
||||
// Add core OSGi packages to be exported from the class path
|
||||
// via the system bundle.
|
||||
configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES,
|
||||
"org.osgi.framework; version=1.3.0,"
|
||||
+ "org.osgi.service.packageadmin; version=1.2.0,"
|
||||
+ "org.osgi.service.startlevel; version=1.0.0,"
|
||||
+ "org.osgi.service.url; version=1.0.0");
|
||||
|
||||
configMap.put(Constants.FRAMEWORK_STORAGE_CLEAN,
|
||||
Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
|
||||
|
||||
// Explicitly specify the directory to use for caching bundles.
|
||||
// configMap.put(BundleCache.CACHE_PROFILE_DIR_PROP, "cache");
|
||||
|
||||
try {
|
||||
// Create host activator;
|
||||
|
||||
List list = new ArrayList();
|
||||
|
||||
// list.add(new HostActivator());
|
||||
configMap.put(Constants.FRAMEWORK_SYSTEMPACKAGES_EXTRA,
|
||||
"org.xml.sax, org.xml.sax.helpers, javax.xml.parsers, javax.naming");
|
||||
configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
|
||||
configMap.put("felix.log.level", "4");
|
||||
|
||||
// Now create an instance of the framework with
|
||||
// our configuration properties and activator.
|
||||
felix = new Felix(configMap);
|
||||
felix.init();
|
||||
|
||||
// otherProps.put(Constants.FRAMEWORK_STORAGE, "bundles");
|
||||
|
||||
otherProps.put(AutoProcessor.AUTO_DEPLOY_DIR_PROPERY,
|
||||
AutoProcessor.AUTO_DEPLOY_DIR_VALUE);
|
||||
otherProps.put(AutoProcessor.AUTO_DEPLOY_ACTION_PROPERY,
|
||||
AutoProcessor.AUTO_DEPLOY_START_VALUE + ","
|
||||
+ AutoProcessor.AUTO_DEPLOY_INSTALL_VALUE);
|
||||
|
||||
BundleContext felixBudleContext = felix.getBundleContext();
|
||||
|
||||
AutoProcessor.process(otherProps, felixBudleContext);
|
||||
// listen to errors
|
||||
felixBudleContext.addFrameworkListener(frameworkErrorListener);
|
||||
felixBudleContext.addBundleListener(myBundleListener);
|
||||
// Now start Felix instance.
|
||||
felix.start();
|
||||
System.out.println("felix started");
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() throws BundleException {
|
||||
felix.stop();
|
||||
}
|
||||
|
||||
public Bundle[] getInstalledBundles() {
|
||||
// Use the system bundle activator to gain external
|
||||
// access to the set of installed bundles.
|
||||
return null;// m_activator.getBundles();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,60 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package org.slf4j.test_osgi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.osgi.framework.FrameworkEvent;
|
||||
import org.osgi.framework.FrameworkListener;
|
||||
|
||||
public class FrameworkErrorListener implements FrameworkListener {
|
||||
|
||||
public List errorList = new ArrayList();
|
||||
|
||||
public void frameworkEvent(FrameworkEvent fe) {
|
||||
if (fe.getType() == FrameworkEvent.ERROR) {
|
||||
errorList.add(fe);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void dump(FrameworkEvent fe) {
|
||||
Throwable t = fe.getThrowable();
|
||||
String tString = null;
|
||||
if (t != null) {
|
||||
tString = t.toString();
|
||||
}
|
||||
System.out.println("Framework ERROR:" + ", source " + fe.getSource()
|
||||
+ ", bundle=" + fe.getBundle() + ", ex=" + tString);
|
||||
if(t != null) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void dumpAll() {
|
||||
for(int i = 0; i < errorList.size(); i++) {
|
||||
FrameworkEvent fe = (FrameworkEvent) errorList.get(i);
|
||||
dump(fe);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package org.slf4j.test_osgi;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.osgi.framework.FrameworkEvent;
|
||||
import org.osgi.framework.FrameworkListener;
|
||||
|
||||
public class FrameworkErrorListener implements FrameworkListener {
|
||||
|
||||
public List errorList = new ArrayList();
|
||||
|
||||
public void frameworkEvent(FrameworkEvent fe) {
|
||||
if (fe.getType() == FrameworkEvent.ERROR) {
|
||||
errorList.add(fe);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void dump(FrameworkEvent fe) {
|
||||
Throwable t = fe.getThrowable();
|
||||
String tString = null;
|
||||
if (t != null) {
|
||||
tString = t.toString();
|
||||
}
|
||||
System.out.println("Framework ERROR:" + ", source " + fe.getSource()
|
||||
+ ", bundle=" + fe.getBundle() + ", ex=" + tString);
|
||||
if(t != null) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void dumpAll() {
|
||||
for(int i = 0; i < errorList.size(); i++) {
|
||||
FrameworkEvent fe = (FrameworkEvent) errorList.get(i);
|
||||
dump(fe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,176 +1,176 @@
|
|||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
|
@ -1,83 +1,83 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>JCL 1.1.1 implemented over SLF4J</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
<description>
|
||||
JCL 1.1.1 implementation over SLF4J
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-nop</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
|
||||
<Bundle-Description>${project.description}</Bundle-Description>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
</manifestEntries>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<!-- Check whether we comply with the interfaces of JCL 1.1.1
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>clirr-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<comparisonArtifacts>
|
||||
<comparisonArtifact>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</comparisonArtifact>
|
||||
</comparisonArtifacts>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>JCL 1.1.1 implemented over SLF4J</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
<description>
|
||||
JCL 1.1.1 implementation over SLF4J
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-nop</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
|
||||
<Bundle-Description>${project.description}</Bundle-Description>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
</manifestEntries>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<!-- Check whether we comply with the interfaces of JCL 1.1.1
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>clirr-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<comparisonArtifacts>
|
||||
<comparisonArtifact>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</comparisonArtifact>
|
||||
</comparisonArtifacts>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
-->
|
||||
|
||||
</project>
|
||||
|
|
@ -1,266 +1,266 @@
|
|||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.logging.impl;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.spi.LocationAwareLogger;
|
||||
|
||||
/**
|
||||
* Implementation of {@link Log org.apache.commons.logging.Log} interface which
|
||||
* delegates all processing to a wrapped {@link Logger org.slf4j.Logger}
|
||||
* instance.
|
||||
*
|
||||
* <p>
|
||||
* JCL's FATAL level is mapped to ERROR. All other levels map one to one.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class SLF4JLocationAwareLog implements Log, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2379157579039314822L;
|
||||
|
||||
//used to store this logger's name to recreate it after serialization
|
||||
protected String name;
|
||||
|
||||
// in both Log4jLogger and Jdk14Logger classes in the original JCL, the
|
||||
// logger instance is transient
|
||||
private transient LocationAwareLogger logger;
|
||||
|
||||
private static final String FQCN = SLF4JLocationAwareLog.class.getName();
|
||||
|
||||
SLF4JLocationAwareLog(LocationAwareLogger logger) {
|
||||
this.logger = logger;
|
||||
this.name = logger.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to the <code>isTraceEnabled<code> method of the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isTraceEnabled() {
|
||||
return logger.isTraceEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isDebugEnabled() {
|
||||
return logger.isDebugEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isInfoEnabled() {
|
||||
return logger.isInfoEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isWarnEnabled() {
|
||||
return logger.isWarnEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isErrorEnabled() {
|
||||
return logger.isErrorEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to the <code>isErrorEnabled<code> method of the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isFatalEnabled() {
|
||||
return logger.isErrorEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the debug
|
||||
* method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void trace(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String
|
||||
.valueOf(message), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to the
|
||||
* debug method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
* @param t
|
||||
* the exception to log
|
||||
*/
|
||||
public void trace(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String
|
||||
.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void debug(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String
|
||||
.valueOf(message), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to the
|
||||
* wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
* @param t
|
||||
* the exception to log
|
||||
*/
|
||||
public void debug(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String
|
||||
.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void info(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.INFO_INT, String
|
||||
.valueOf(message), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to the
|
||||
* wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
* @param t
|
||||
* the exception to log
|
||||
*/
|
||||
public void info(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.INFO_INT, String
|
||||
.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void warn(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.WARN_INT, String
|
||||
.valueOf(message), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to the
|
||||
* wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
* @param t
|
||||
* the exception to log
|
||||
*/
|
||||
public void warn(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.WARN_INT, String
|
||||
.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void error(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String
|
||||
.valueOf(message), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to the
|
||||
* wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
* @param t
|
||||
* the exception to log
|
||||
*/
|
||||
public void error(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String
|
||||
.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the error
|
||||
* method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void fatal(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String
|
||||
.valueOf(message), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to the
|
||||
* error method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
* @param t
|
||||
* the exception to log
|
||||
*/
|
||||
public void fatal(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String
|
||||
.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace this instance with a homonymous (same name) logger returned by
|
||||
* LoggerFactory. Note that this method is only called during deserialization.
|
||||
*
|
||||
* @return logger with same name as returned by LoggerFactory
|
||||
* @throws ObjectStreamException
|
||||
*/
|
||||
protected Object readResolve() throws ObjectStreamException {
|
||||
Logger logger = LoggerFactory.getLogger(this.name);
|
||||
return new SLF4JLocationAwareLog((LocationAwareLogger) logger);
|
||||
}
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.logging.impl;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.spi.LocationAwareLogger;
|
||||
|
||||
/**
|
||||
* Implementation of {@link Log org.apache.commons.logging.Log} interface which
|
||||
* delegates all processing to a wrapped {@link Logger org.slf4j.Logger}
|
||||
* instance.
|
||||
*
|
||||
* <p>
|
||||
* JCL's FATAL level is mapped to ERROR. All other levels map one to one.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class SLF4JLocationAwareLog implements Log, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2379157579039314822L;
|
||||
|
||||
//used to store this logger's name to recreate it after serialization
|
||||
protected String name;
|
||||
|
||||
// in both Log4jLogger and Jdk14Logger classes in the original JCL, the
|
||||
// logger instance is transient
|
||||
private transient LocationAwareLogger logger;
|
||||
|
||||
private static final String FQCN = SLF4JLocationAwareLog.class.getName();
|
||||
|
||||
SLF4JLocationAwareLog(LocationAwareLogger logger) {
|
||||
this.logger = logger;
|
||||
this.name = logger.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to the <code>isTraceEnabled<code> method of the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isTraceEnabled() {
|
||||
return logger.isTraceEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isDebugEnabled() {
|
||||
return logger.isDebugEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isInfoEnabled() {
|
||||
return logger.isInfoEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isWarnEnabled() {
|
||||
return logger.isWarnEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isErrorEnabled() {
|
||||
return logger.isErrorEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to the <code>isErrorEnabled<code> method of the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isFatalEnabled() {
|
||||
return logger.isErrorEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the debug
|
||||
* method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void trace(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String
|
||||
.valueOf(message), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to the
|
||||
* debug method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
* @param t
|
||||
* the exception to log
|
||||
*/
|
||||
public void trace(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.TRACE_INT, String
|
||||
.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void debug(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String
|
||||
.valueOf(message), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to the
|
||||
* wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
* @param t
|
||||
* the exception to log
|
||||
*/
|
||||
public void debug(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.DEBUG_INT, String
|
||||
.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void info(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.INFO_INT, String
|
||||
.valueOf(message), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to the
|
||||
* wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
* @param t
|
||||
* the exception to log
|
||||
*/
|
||||
public void info(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.INFO_INT, String
|
||||
.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void warn(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.WARN_INT, String
|
||||
.valueOf(message), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to the
|
||||
* wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
* @param t
|
||||
* the exception to log
|
||||
*/
|
||||
public void warn(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.WARN_INT, String
|
||||
.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void error(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String
|
||||
.valueOf(message), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to the
|
||||
* wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
* @param t
|
||||
* the exception to log
|
||||
*/
|
||||
public void error(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String
|
||||
.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the error
|
||||
* method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void fatal(Object message) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String
|
||||
.valueOf(message), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to the
|
||||
* error method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message
|
||||
* the message to log. Converted to {@link String}
|
||||
* @param t
|
||||
* the exception to log
|
||||
*/
|
||||
public void fatal(Object message, Throwable t) {
|
||||
logger.log(null, FQCN, LocationAwareLogger.ERROR_INT, String
|
||||
.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace this instance with a homonymous (same name) logger returned by
|
||||
* LoggerFactory. Note that this method is only called during deserialization.
|
||||
*
|
||||
* @return logger with same name as returned by LoggerFactory
|
||||
* @throws ObjectStreamException
|
||||
*/
|
||||
protected Object readResolve() throws ObjectStreamException {
|
||||
Logger logger = LoggerFactory.getLogger(this.name);
|
||||
return new SLF4JLocationAwareLog((LocationAwareLogger) logger);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,234 +1,234 @@
|
|||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.logging.impl;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Implementation of {@link Log org.apache.commons.logging.Log} interface which
|
||||
* delegates all processing to a wrapped {@link Logger org.slf4j.Logger} instance.
|
||||
*
|
||||
* <p>JCL's FATAL and TRACE levels are mapped to ERROR and DEBUG respectively. All
|
||||
* other levels map one to one.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class SLF4JLog implements Log, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 680728617011167209L;
|
||||
|
||||
//used to store this logger's name to recreate it after serialization
|
||||
protected String name;
|
||||
|
||||
// in both Log4jLogger and Jdk14Logger classes in the original JCL, the
|
||||
// logger instance is transient
|
||||
private transient Logger logger;
|
||||
|
||||
SLF4JLog(Logger logger) {
|
||||
this.logger = logger;
|
||||
this.name = logger.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isDebugEnabled() {
|
||||
return logger.isDebugEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isErrorEnabled() {
|
||||
return logger.isErrorEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to the <code>isErrorEnabled<code> method of the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isFatalEnabled() {
|
||||
return logger.isErrorEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isInfoEnabled() {
|
||||
return logger.isInfoEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to the <code>isDebugEnabled<code> method of the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isTraceEnabled() {
|
||||
return logger.isTraceEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isWarnEnabled() {
|
||||
return logger.isWarnEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to
|
||||
* the debug method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void trace(Object message) {
|
||||
logger.trace(String.valueOf(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to
|
||||
* the debug method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
* @param t the exception to log
|
||||
*/
|
||||
public void trace(Object message, Throwable t) {
|
||||
logger.trace(String.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void debug(Object message) {
|
||||
logger.debug(String.valueOf(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to
|
||||
* the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
* @param t the exception to log
|
||||
*/
|
||||
public void debug(Object message, Throwable t) {
|
||||
logger.debug(String.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void info(Object message) {
|
||||
logger.info(String.valueOf(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to
|
||||
* the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
* @param t the exception to log
|
||||
*/
|
||||
public void info(Object message, Throwable t) {
|
||||
logger.info(String.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void warn(Object message) {
|
||||
logger.warn(String.valueOf(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to
|
||||
* the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
* @param t the exception to log
|
||||
*/
|
||||
public void warn(Object message, Throwable t) {
|
||||
logger.warn(String.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void error(Object message) {
|
||||
logger.error(String.valueOf(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to
|
||||
* the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
* @param t the exception to log
|
||||
*/
|
||||
public void error(Object message, Throwable t) {
|
||||
logger.error(String.valueOf(message), t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to
|
||||
* the error method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void fatal(Object message) {
|
||||
logger.error(String.valueOf(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to
|
||||
* the error method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
* @param t the exception to log
|
||||
*/
|
||||
public void fatal(Object message, Throwable t) {
|
||||
logger.error(String.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace this instance with a homonymous (same name) logger returned by
|
||||
* LoggerFactory. Note that this method is only called during deserialization.
|
||||
*
|
||||
* @return logger with same name as returned by LoggerFactory
|
||||
* @throws ObjectStreamException
|
||||
*/
|
||||
protected Object readResolve() throws ObjectStreamException {
|
||||
Logger logger = LoggerFactory.getLogger(this.name);
|
||||
return new SLF4JLog(logger);
|
||||
}
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.commons.logging.impl;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Implementation of {@link Log org.apache.commons.logging.Log} interface which
|
||||
* delegates all processing to a wrapped {@link Logger org.slf4j.Logger} instance.
|
||||
*
|
||||
* <p>JCL's FATAL and TRACE levels are mapped to ERROR and DEBUG respectively. All
|
||||
* other levels map one to one.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class SLF4JLog implements Log, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 680728617011167209L;
|
||||
|
||||
//used to store this logger's name to recreate it after serialization
|
||||
protected String name;
|
||||
|
||||
// in both Log4jLogger and Jdk14Logger classes in the original JCL, the
|
||||
// logger instance is transient
|
||||
private transient Logger logger;
|
||||
|
||||
SLF4JLog(Logger logger) {
|
||||
this.logger = logger;
|
||||
this.name = logger.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isDebugEnabled() {
|
||||
return logger.isDebugEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isErrorEnabled() {
|
||||
return logger.isErrorEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to the <code>isErrorEnabled<code> method of the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isFatalEnabled() {
|
||||
return logger.isErrorEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isInfoEnabled() {
|
||||
return logger.isInfoEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to the <code>isDebugEnabled<code> method of the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isTraceEnabled() {
|
||||
return logger.isTraceEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly delegates to the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*/
|
||||
public boolean isWarnEnabled() {
|
||||
return logger.isWarnEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to
|
||||
* the debug method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void trace(Object message) {
|
||||
logger.trace(String.valueOf(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to
|
||||
* the debug method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
* @param t the exception to log
|
||||
*/
|
||||
public void trace(Object message, Throwable t) {
|
||||
logger.trace(String.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void debug(Object message) {
|
||||
logger.debug(String.valueOf(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to
|
||||
* the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
* @param t the exception to log
|
||||
*/
|
||||
public void debug(Object message, Throwable t) {
|
||||
logger.debug(String.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void info(Object message) {
|
||||
logger.info(String.valueOf(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to
|
||||
* the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
* @param t the exception to log
|
||||
*/
|
||||
public void info(Object message, Throwable t) {
|
||||
logger.info(String.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void warn(Object message) {
|
||||
logger.warn(String.valueOf(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to
|
||||
* the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
* @param t the exception to log
|
||||
*/
|
||||
public void warn(Object message, Throwable t) {
|
||||
logger.warn(String.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to the wrapped
|
||||
* <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void error(Object message) {
|
||||
logger.error(String.valueOf(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to
|
||||
* the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
* @param t the exception to log
|
||||
*/
|
||||
public void error(Object message, Throwable t) {
|
||||
logger.error(String.valueOf(message), t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Converts the input parameter to String and then delegates to
|
||||
* the error method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
*/
|
||||
public void fatal(Object message) {
|
||||
logger.error(String.valueOf(message));
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the first input parameter to String and then delegates to
|
||||
* the error method of the wrapped <code>org.slf4j.Logger</code> instance.
|
||||
*
|
||||
* @param message the message to log. Converted to {@link String}
|
||||
* @param t the exception to log
|
||||
*/
|
||||
public void fatal(Object message, Throwable t) {
|
||||
logger.error(String.valueOf(message), t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace this instance with a homonymous (same name) logger returned by
|
||||
* LoggerFactory. Note that this method is only called during deserialization.
|
||||
*
|
||||
* @return logger with same name as returned by LoggerFactory
|
||||
* @throws ObjectStreamException
|
||||
*/
|
||||
protected Object readResolve() throws ObjectStreamException {
|
||||
Logger logger = LoggerFactory.getLogger(this.name);
|
||||
return new SLF4JLog(logger);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<body>
|
||||
|
||||
<p>SLF4J based implementation of commons-logging wrapper APIs.</p>
|
||||
|
||||
</body>
|
||||
<body>
|
||||
|
||||
<p>SLF4J based implementation of commons-logging wrapper APIs.</p>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1,169 +1,169 @@
|
|||
<!--
|
||||
|
||||
Copyright 2001-2004 The Apache Software Foundation.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
<body>
|
||||
<p>Jakarta Commons Logging implemented over SLF4J.</p>
|
||||
|
||||
|
||||
<h3>Overview</h3>
|
||||
|
||||
<p>This package contains the same public user interface as <a
|
||||
href="http://jakarta.apache.org/commons/logging/">Jakarta Commons
|
||||
Logging (JCL)</a>. It is intended as a 100% compatible drop-in
|
||||
replacement for the original JCL version 1.0.4.
|
||||
</p>
|
||||
|
||||
<p>As the original JCL version 1.0.4, the present version supports
|
||||
various logging APIs. It differs from the original in implementation
|
||||
but not the public API. This implementation uses SLF4J under the
|
||||
covers. As as such, all the logging systems that SLF4J supports,
|
||||
e.g. NOP, Simple, JDK14, nlog4j are supported by this version of JCL.
|
||||
</p>
|
||||
|
||||
<h3>Quick Start Guide</h3>
|
||||
|
||||
<p>For those impatient to just get on with it, the following example
|
||||
illustrates the typical declaration and use of a logger that is named (by
|
||||
convention) after the calling class:
|
||||
|
||||
<pre>
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class Foo {
|
||||
|
||||
static Log log = LogFactory.getLog(Foo.class);
|
||||
|
||||
public void foo() {
|
||||
...
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("About to do something to object " + name);
|
||||
}
|
||||
name.bar();
|
||||
} catch (IllegalStateException e) {
|
||||
log.error("Something bad happened to " + name, e);
|
||||
}
|
||||
...
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h3>Configuring the Commons Logging Package</h3>
|
||||
|
||||
<p>In this version of JCL, the selection of the logging system to use
|
||||
is chosen by the underlying SLF4J API. Consequently, all JCL-specific
|
||||
configration parameters are ignored.
|
||||
</p>
|
||||
|
||||
<h4>Choosing a <code>LogFactory</code> Implementation</h4>
|
||||
|
||||
<p>From an application perspective, the first requirement is to
|
||||
retrieve an object reference to the <code>LogFactory</code> instance
|
||||
that will be used to create <code><a href="Log.html">Log</a></code>
|
||||
instances for this application. This is normally accomplished by
|
||||
calling the static <code>getFactory()</code> method. This method
|
||||
always returns the same factory, i.e. a unique instance of the <a
|
||||
href="impl/SLF4FLogFactory.html">SLF4FLogFactory</a> class.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<h4>Configuring the Underlying Logging System</h4>
|
||||
|
||||
<p>The basic principle is that the user is totally responsible for the
|
||||
configuration of the underlying logging system.
|
||||
Commons-logging should not change the existing configuration.</p>
|
||||
|
||||
<p>Each individual <a href="Log.html">Log</a> implementation may
|
||||
support its own configuration properties. These will be documented in the
|
||||
class descriptions for the corresponding implementation class.</p>
|
||||
|
||||
<p>Finally, some <code>Log</code> implementations (such as the one for Log4J)
|
||||
require an external configuration file for the entire logging environment.
|
||||
This file should be prepared in a manner that is specific to the actual logging
|
||||
technology being used.</p>
|
||||
|
||||
|
||||
<h3>Using the Logging Package APIs</h3>
|
||||
|
||||
<p>Use of the Logging Package APIs, from the perspective of an application
|
||||
component, consists of the following steps:</p>
|
||||
<ol>
|
||||
<li>Acquire a reference to an instance of
|
||||
<a href="Log.html">org.apache.commons.logging.Log</a>, by calling the
|
||||
factory method
|
||||
<a href="LogFactory.html#getInstance(java.lang.String)">
|
||||
LogFactory.getInstance(String name)</a>. Your application can contain
|
||||
references to multiple loggers that are used for different
|
||||
purposes. A typical scenario for a server application is to have each
|
||||
major component of the server use its own Log instance.</li>
|
||||
<li>Cause messages to be logged (if the corresponding detail level is enabled)
|
||||
by calling appropriate methods (<code>trace()</code>, <code>debug()</code>,
|
||||
<code>info()</code>, <code>warn()</code>, <code>error</code>, and
|
||||
<code>fatal()</code>).</li>
|
||||
</ol>
|
||||
|
||||
<p>For convenience, <code>LogFactory</code> also offers a static method
|
||||
<code>getLog()</code> that combines the typical two-step pattern:</p>
|
||||
<pre>
|
||||
Log log = LogFactory.getFactory().getInstance(Foo.class);
|
||||
</pre>
|
||||
<p>into a single method call:</p>
|
||||
<pre>
|
||||
Log log = LogFactory.getLog(Foo.class);
|
||||
</pre>
|
||||
|
||||
<p>For example, you might use the following technique to initialize and
|
||||
use a <a href="Log.html">Log</a> instance in an application component:</p>
|
||||
<pre>
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class MyComponent {
|
||||
|
||||
protected static Log log =
|
||||
LogFactory.getLog(MyComponent.class);
|
||||
|
||||
// Called once at startup time
|
||||
public void start() {
|
||||
...
|
||||
log.info("MyComponent started");
|
||||
...
|
||||
}
|
||||
|
||||
// Called once at shutdown time
|
||||
public void stop() {
|
||||
...
|
||||
log.info("MyComponent stopped");
|
||||
...
|
||||
}
|
||||
|
||||
// Called repeatedly to process a particular argument value
|
||||
// which you want logged if debugging is enabled
|
||||
public void process(String value) {
|
||||
...
|
||||
// Do the string concatenation only if logging is enabled
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("MyComponent processing " + value);
|
||||
...
|
||||
}
|
||||
|
||||
}
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
<!--
|
||||
|
||||
Copyright 2001-2004 The Apache Software Foundation.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
-->
|
||||
|
||||
<body>
|
||||
<p>Jakarta Commons Logging implemented over SLF4J.</p>
|
||||
|
||||
|
||||
<h3>Overview</h3>
|
||||
|
||||
<p>This package contains the same public user interface as <a
|
||||
href="http://jakarta.apache.org/commons/logging/">Jakarta Commons
|
||||
Logging (JCL)</a>. It is intended as a 100% compatible drop-in
|
||||
replacement for the original JCL version 1.0.4.
|
||||
</p>
|
||||
|
||||
<p>As the original JCL version 1.0.4, the present version supports
|
||||
various logging APIs. It differs from the original in implementation
|
||||
but not the public API. This implementation uses SLF4J under the
|
||||
covers. As as such, all the logging systems that SLF4J supports,
|
||||
e.g. NOP, Simple, JDK14, nlog4j are supported by this version of JCL.
|
||||
</p>
|
||||
|
||||
<h3>Quick Start Guide</h3>
|
||||
|
||||
<p>For those impatient to just get on with it, the following example
|
||||
illustrates the typical declaration and use of a logger that is named (by
|
||||
convention) after the calling class:
|
||||
|
||||
<pre>
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class Foo {
|
||||
|
||||
static Log log = LogFactory.getLog(Foo.class);
|
||||
|
||||
public void foo() {
|
||||
...
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("About to do something to object " + name);
|
||||
}
|
||||
name.bar();
|
||||
} catch (IllegalStateException e) {
|
||||
log.error("Something bad happened to " + name, e);
|
||||
}
|
||||
...
|
||||
}
|
||||
</pre>
|
||||
|
||||
<h3>Configuring the Commons Logging Package</h3>
|
||||
|
||||
<p>In this version of JCL, the selection of the logging system to use
|
||||
is chosen by the underlying SLF4J API. Consequently, all JCL-specific
|
||||
configration parameters are ignored.
|
||||
</p>
|
||||
|
||||
<h4>Choosing a <code>LogFactory</code> Implementation</h4>
|
||||
|
||||
<p>From an application perspective, the first requirement is to
|
||||
retrieve an object reference to the <code>LogFactory</code> instance
|
||||
that will be used to create <code><a href="Log.html">Log</a></code>
|
||||
instances for this application. This is normally accomplished by
|
||||
calling the static <code>getFactory()</code> method. This method
|
||||
always returns the same factory, i.e. a unique instance of the <a
|
||||
href="impl/SLF4FLogFactory.html">SLF4FLogFactory</a> class.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<h4>Configuring the Underlying Logging System</h4>
|
||||
|
||||
<p>The basic principle is that the user is totally responsible for the
|
||||
configuration of the underlying logging system.
|
||||
Commons-logging should not change the existing configuration.</p>
|
||||
|
||||
<p>Each individual <a href="Log.html">Log</a> implementation may
|
||||
support its own configuration properties. These will be documented in the
|
||||
class descriptions for the corresponding implementation class.</p>
|
||||
|
||||
<p>Finally, some <code>Log</code> implementations (such as the one for Log4J)
|
||||
require an external configuration file for the entire logging environment.
|
||||
This file should be prepared in a manner that is specific to the actual logging
|
||||
technology being used.</p>
|
||||
|
||||
|
||||
<h3>Using the Logging Package APIs</h3>
|
||||
|
||||
<p>Use of the Logging Package APIs, from the perspective of an application
|
||||
component, consists of the following steps:</p>
|
||||
<ol>
|
||||
<li>Acquire a reference to an instance of
|
||||
<a href="Log.html">org.apache.commons.logging.Log</a>, by calling the
|
||||
factory method
|
||||
<a href="LogFactory.html#getInstance(java.lang.String)">
|
||||
LogFactory.getInstance(String name)</a>. Your application can contain
|
||||
references to multiple loggers that are used for different
|
||||
purposes. A typical scenario for a server application is to have each
|
||||
major component of the server use its own Log instance.</li>
|
||||
<li>Cause messages to be logged (if the corresponding detail level is enabled)
|
||||
by calling appropriate methods (<code>trace()</code>, <code>debug()</code>,
|
||||
<code>info()</code>, <code>warn()</code>, <code>error</code>, and
|
||||
<code>fatal()</code>).</li>
|
||||
</ol>
|
||||
|
||||
<p>For convenience, <code>LogFactory</code> also offers a static method
|
||||
<code>getLog()</code> that combines the typical two-step pattern:</p>
|
||||
<pre>
|
||||
Log log = LogFactory.getFactory().getInstance(Foo.class);
|
||||
</pre>
|
||||
<p>into a single method call:</p>
|
||||
<pre>
|
||||
Log log = LogFactory.getLog(Foo.class);
|
||||
</pre>
|
||||
|
||||
<p>For example, you might use the following technique to initialize and
|
||||
use a <a href="Log.html">Log</a> instance in an application component:</p>
|
||||
<pre>
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
public class MyComponent {
|
||||
|
||||
protected static Log log =
|
||||
LogFactory.getLog(MyComponent.class);
|
||||
|
||||
// Called once at startup time
|
||||
public void start() {
|
||||
...
|
||||
log.info("MyComponent started");
|
||||
...
|
||||
}
|
||||
|
||||
// Called once at shutdown time
|
||||
public void stop() {
|
||||
...
|
||||
log.info("MyComponent stopped");
|
||||
...
|
||||
}
|
||||
|
||||
// Called repeatedly to process a particular argument value
|
||||
// which you want logged if debugging is enabled
|
||||
public void process(String value) {
|
||||
...
|
||||
// Do the string concatenation only if logging is enabled
|
||||
if (log.isDebugEnabled())
|
||||
log.debug("MyComponent processing " + value);
|
||||
...
|
||||
}
|
||||
|
||||
}
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
Implementation-Title: jcl-over-slf4j
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-SymbolicName: jcl.over.slf4j
|
||||
Bundle-Name: jcl-over-slf4j
|
||||
Bundle-Vendor: SLF4J.ORG
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.3
|
||||
Export-Package: org.apache.commons.logging;version=1.1.1,
|
||||
org.apache.commons.logging.impl;version=1.1.1
|
||||
Import-Package: org.slf4j;version=${parsedVersion.osgiVersion}, org.slf4j.spi;version=${parsedVersion.osgiVersion}
|
||||
Implementation-Title: jcl-over-slf4j
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-SymbolicName: jcl.over.slf4j
|
||||
Bundle-Name: jcl-over-slf4j
|
||||
Bundle-Vendor: SLF4J.ORG
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.3
|
||||
Export-Package: org.apache.commons.logging;version=1.1.1,
|
||||
org.apache.commons.logging.impl;version=1.1.1
|
||||
Import-Package: org.slf4j;version=${parsedVersion.osgiVersion}, org.slf4j.spi;version=${parsedVersion.osgiVersion}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
org.apache.commons.logging.impl.SLF4JLogFactory
|
||||
|
||||
# Axis gets at JCL through its own mechanism as defined by Commons Discovery, which
|
||||
# in turn follows the instructions found at:
|
||||
# http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Service Provider
|
||||
org.apache.commons.logging.impl.SLF4JLogFactory
|
||||
|
||||
# Axis gets at JCL through its own mechanism as defined by Commons Discovery, which
|
||||
# in turn follows the instructions found at:
|
||||
# http://java.sun.com/j2se/1.3/docs/guide/jar/jar.html#Service Provider
|
||||
|
|
|
|||
|
|
@ -1,94 +1,94 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2005 SLF4J.ORG
|
||||
* Copyright (c) 2004-2005 QOS.ch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.commons.logging;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
||||
public class InvokeJCLTest extends TestCase {
|
||||
|
||||
public void testIsEnabledAPI() {
|
||||
// assume that we are running over slf4j-jdk14
|
||||
Log log = LogFactory.getLog(InvokeJCLTest.class);
|
||||
assertFalse(log.isTraceEnabled());
|
||||
assertFalse(log.isDebugEnabled());
|
||||
assertTrue(log.isInfoEnabled());
|
||||
assertTrue(log.isWarnEnabled());
|
||||
assertTrue(log.isErrorEnabled());
|
||||
assertTrue(log.isFatalEnabled());
|
||||
}
|
||||
|
||||
public void testPrintAPI() {
|
||||
Log log = LogFactory.getLog(InvokeJCLTest.class);
|
||||
Exception e = new Exception("just testing");
|
||||
|
||||
log.trace(null);
|
||||
log.trace("trace message");
|
||||
|
||||
log.debug(null);
|
||||
log.debug("debug message");
|
||||
|
||||
log.info(null);
|
||||
log.info("info message");
|
||||
|
||||
log.warn(null);
|
||||
log.warn("warn message");
|
||||
|
||||
log.error(null);
|
||||
log.error("error message");
|
||||
|
||||
log.fatal(null);
|
||||
log.fatal("fatal message");
|
||||
|
||||
|
||||
log.trace(null, e);
|
||||
log.trace("trace message", e);
|
||||
|
||||
log.debug(null, e);
|
||||
log.debug("debug message", e);
|
||||
|
||||
log.info(null, e);
|
||||
log.info("info message", e);
|
||||
|
||||
log.warn(null, e);
|
||||
log.warn("warn message", e);
|
||||
|
||||
log.error(null, e);
|
||||
log.error("error message", e);
|
||||
|
||||
log.fatal(null, e);
|
||||
log.fatal("fatal message", e);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2005 SLF4J.ORG
|
||||
* Copyright (c) 2004-2005 QOS.ch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.commons.logging;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
|
||||
public class InvokeJCLTest extends TestCase {
|
||||
|
||||
public void testIsEnabledAPI() {
|
||||
// assume that we are running over slf4j-jdk14
|
||||
Log log = LogFactory.getLog(InvokeJCLTest.class);
|
||||
assertFalse(log.isTraceEnabled());
|
||||
assertFalse(log.isDebugEnabled());
|
||||
assertTrue(log.isInfoEnabled());
|
||||
assertTrue(log.isWarnEnabled());
|
||||
assertTrue(log.isErrorEnabled());
|
||||
assertTrue(log.isFatalEnabled());
|
||||
}
|
||||
|
||||
public void testPrintAPI() {
|
||||
Log log = LogFactory.getLog(InvokeJCLTest.class);
|
||||
Exception e = new Exception("just testing");
|
||||
|
||||
log.trace(null);
|
||||
log.trace("trace message");
|
||||
|
||||
log.debug(null);
|
||||
log.debug("debug message");
|
||||
|
||||
log.info(null);
|
||||
log.info("info message");
|
||||
|
||||
log.warn(null);
|
||||
log.warn("warn message");
|
||||
|
||||
log.error(null);
|
||||
log.error("error message");
|
||||
|
||||
log.fatal(null);
|
||||
log.fatal("fatal message");
|
||||
|
||||
|
||||
log.trace(null, e);
|
||||
log.trace("trace message", e);
|
||||
|
||||
log.debug(null, e);
|
||||
log.debug("debug message", e);
|
||||
|
||||
log.info(null, e);
|
||||
log.info("info message", e);
|
||||
|
||||
log.warn(null, e);
|
||||
log.warn("warn message", e);
|
||||
|
||||
log.error(null, e);
|
||||
log.error("error message", e);
|
||||
|
||||
log.fatal(null, e);
|
||||
log.fatal("fatal message", e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,66 +1,66 @@
|
|||
package org.apache.commons.logging.impl;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.impl.JDK14LoggerFactory;
|
||||
import org.slf4j.spi.LocationAwareLogger;
|
||||
|
||||
public class SerializationTest extends TestCase {
|
||||
|
||||
ObjectInputStream ois;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos;
|
||||
|
||||
public SerializationTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
oos = new ObjectOutputStream(baos);
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
oos.close();
|
||||
}
|
||||
|
||||
public void verify() throws IOException, ClassNotFoundException {
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
|
||||
ois = new ObjectInputStream(bis);
|
||||
|
||||
Log resuscitatedLog = (Log) ois.readObject();
|
||||
// tests that the "private transient Logger logger" field is non-null
|
||||
resuscitatedLog.debug("");
|
||||
resuscitatedLog.isDebugEnabled();
|
||||
}
|
||||
|
||||
public void testSLF4JLog() throws Exception {
|
||||
JDK14LoggerFactory factory = new JDK14LoggerFactory();
|
||||
SLF4JLog log = new SLF4JLog(factory.getLogger("x"));
|
||||
oos.writeObject(log);
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testSmoke() throws Exception {
|
||||
Log log = LogFactory.getLog("testing");
|
||||
oos.writeObject(log);
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testLocationAware() throws Exception {
|
||||
JDK14LoggerFactory factory = new JDK14LoggerFactory();
|
||||
SLF4JLocationAwareLog log = new SLF4JLocationAwareLog(
|
||||
(LocationAwareLogger) factory.getLogger("x"));
|
||||
oos.writeObject(log);
|
||||
verify();
|
||||
}
|
||||
}
|
||||
package org.apache.commons.logging.impl;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.slf4j.impl.JDK14LoggerFactory;
|
||||
import org.slf4j.spi.LocationAwareLogger;
|
||||
|
||||
public class SerializationTest extends TestCase {
|
||||
|
||||
ObjectInputStream ois;
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
ObjectOutputStream oos;
|
||||
|
||||
public SerializationTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
oos = new ObjectOutputStream(baos);
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
oos.close();
|
||||
}
|
||||
|
||||
public void verify() throws IOException, ClassNotFoundException {
|
||||
ByteArrayInputStream bis = new ByteArrayInputStream(baos.toByteArray());
|
||||
ois = new ObjectInputStream(bis);
|
||||
|
||||
Log resuscitatedLog = (Log) ois.readObject();
|
||||
// tests that the "private transient Logger logger" field is non-null
|
||||
resuscitatedLog.debug("");
|
||||
resuscitatedLog.isDebugEnabled();
|
||||
}
|
||||
|
||||
public void testSLF4JLog() throws Exception {
|
||||
JDK14LoggerFactory factory = new JDK14LoggerFactory();
|
||||
SLF4JLog log = new SLF4JLog(factory.getLogger("x"));
|
||||
oos.writeObject(log);
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testSmoke() throws Exception {
|
||||
Log log = LogFactory.getLog("testing");
|
||||
oos.writeObject(log);
|
||||
verify();
|
||||
}
|
||||
|
||||
public void testLocationAware() throws Exception {
|
||||
JDK14LoggerFactory factory = new JDK14LoggerFactory();
|
||||
SLF4JLocationAwareLog log = new SLF4JLocationAwareLog(
|
||||
(LocationAwareLogger) factory.getLogger("x"));
|
||||
oos.writeObject(log);
|
||||
verify();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,31 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl104-over-slf4j</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>DEPRECATED - JCL 1.0.4 implemented over SLF4J</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
<description>
|
||||
DEPRECATED - JCL implemented over SLF4J
|
||||
</description>
|
||||
|
||||
<distributionManagement>
|
||||
<relocation>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
|
||||
<message>As it now supports JCL versions 1.0.4, 1.1 and 1.1.1, the jcl104-over-slf4j module has been renamed as jcl-over-slf4j.</message>
|
||||
</relocation>
|
||||
</distributionManagement>
|
||||
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl104-over-slf4j</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>DEPRECATED - JCL 1.0.4 implemented over SLF4J</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
<description>
|
||||
DEPRECATED - JCL implemented over SLF4J
|
||||
</description>
|
||||
|
||||
<distributionManagement>
|
||||
<relocation>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jcl-over-slf4j</artifactId>
|
||||
|
||||
<message>As it now supports JCL versions 1.0.4, 1.1 and 1.1.1, the jcl104-over-slf4j module has been renamed as jcl-over-slf4j.</message>
|
||||
</relocation>
|
||||
</distributionManagement>
|
||||
|
||||
|
||||
</project>
|
||||
|
|
@ -1,53 +1,53 @@
|
|||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<name>JUL to SLF4J bridge</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
<description>
|
||||
JUL to SLF4J bridge
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.4</source>
|
||||
<target>1.4</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>jul-to-slf4j</artifactId>
|
||||
|
||||
<packaging>jar</packaging>
|
||||
<name>JUL to SLF4J bridge</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
<description>
|
||||
JUL to SLF4J bridge
|
||||
</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.4</source>
|
||||
<target>1.4</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,273 +1,273 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*/
|
||||
|
||||
package org.slf4j.bridge;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.spi.LocationAwareLogger;
|
||||
|
||||
// Based on http://bugzilla.slf4j.org/show_bug.cgi?id=38
|
||||
|
||||
/**
|
||||
* Bridge/route all JUL log records to the SLF4J API.
|
||||
*
|
||||
* <p>
|
||||
* Essentially, the idea is to install on the root logger an instance of
|
||||
* SLF4JBridgeHandler as the sole JUL handler in the system. Subsequently, the
|
||||
* SLF4JBridgeHandler instance will redirect all JUL log records are redirected
|
||||
* to the SLF4J API based on the following mapping of levels:
|
||||
*
|
||||
* <pre>
|
||||
* FINEST -> TRACE
|
||||
* FINER -> DEBUG
|
||||
* FINE -> DEBUG
|
||||
* INFO -> INFO
|
||||
* WARNING -> WARN
|
||||
* SEVER -> ERROR
|
||||
* </pre>
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* <pre>
|
||||
* // call only once during initialization time of your application
|
||||
* SLF4JBridgeHandler.install();
|
||||
*
|
||||
* // usual pattern: get a Logger and then log a message
|
||||
* java.util.logging.Logger julLogger = java.util.logging.Logger
|
||||
* .getLogger("org.wombat");
|
||||
* julLogger.fine("hello world"); // this will get redirected to SLF4J
|
||||
* </pre>
|
||||
*
|
||||
* <p>
|
||||
* Please note that translating a java.util.logging event into SLF4J incurs the
|
||||
* cost of constructing {@link LogRecord} instance regardless of whether the
|
||||
* SLF4J logger is disabled for the given level. <b>Consequently, j.u.l. to
|
||||
* SLF4J translation can seriously impact on the cost of disabled logging
|
||||
* statements (60 fold increase) and a measurable impact on enabled log
|
||||
* statements (20% overall increase). </b>
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* If application performance is a concern, then use of SLF4JBridgeHandler is
|
||||
* appropriate only if few j.u.l. logging statements are in play.
|
||||
*
|
||||
* @author Christian Stein
|
||||
* @author Joern Huxhorn
|
||||
* @author Ceki Gülcü
|
||||
* @author Darryl Smith
|
||||
*
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public class SLF4JBridgeHandler extends Handler {
|
||||
|
||||
// The caller is java.util.logging.Logger
|
||||
private static final String FQCN = java.util.logging.Logger.class.getName();
|
||||
private static final String UNKNOWN_LOGGER_NAME = "unknown.jul.logger";
|
||||
|
||||
private static final int TRACE_LEVEL_THRESHOLD = Level.FINEST.intValue();
|
||||
private static final int DEBUG_LEVEL_THRESHOLD = Level.FINE.intValue();
|
||||
private static final int INFO_LEVEL_THRESHOLD = Level.INFO.intValue();
|
||||
private static final int WARN_LEVEL_THRESHOLD = Level.WARNING.intValue();
|
||||
|
||||
/**
|
||||
* Adds a SLF4JBridgeHandler instance to jul's root logger.
|
||||
*
|
||||
* <p>
|
||||
* This handler will redirect jul logging to SLF4J. However, only logs enabled
|
||||
* in j.u.l. will be redirected. For example, if a log statement invoking a
|
||||
* j.u.l. logger disabled that statement, by definition, will <em>not</em>
|
||||
* reach any SLF4JBridgeHandler instance and cannot be redirected.
|
||||
*/
|
||||
public static void install() {
|
||||
LogManager.getLogManager().getLogger("").addHandler(
|
||||
new SLF4JBridgeHandler());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes previously installed SLF4JBridgeHandler instances. See also
|
||||
* {@link #install()}.
|
||||
*
|
||||
* @throws SecurityException
|
||||
* A <code>SecurityException</code> is thrown, if a security manager
|
||||
* exists and if the caller does not have
|
||||
* LoggingPermission("control").
|
||||
*/
|
||||
public static void uninstall() throws SecurityException {
|
||||
java.util.logging.Logger rootLogger = LogManager.getLogManager().getLogger(
|
||||
"");
|
||||
Handler[] handlers = rootLogger.getHandlers();
|
||||
for (int i = 0; i < handlers.length; i++) {
|
||||
if (handlers[i] instanceof SLF4JBridgeHandler) {
|
||||
rootLogger.removeHandler(handlers[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize this handler.
|
||||
*
|
||||
*/
|
||||
public SLF4JBridgeHandler() {
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op implementation.
|
||||
*/
|
||||
public void close() {
|
||||
// empty
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op implementation.
|
||||
*/
|
||||
public void flush() {
|
||||
// empty
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Logger instance that will be used for logging.
|
||||
*/
|
||||
protected Logger getSLF4JLogger(LogRecord record) {
|
||||
String name = record.getLoggerName();
|
||||
if (name == null) {
|
||||
name = UNKNOWN_LOGGER_NAME;
|
||||
}
|
||||
return LoggerFactory.getLogger(name);
|
||||
}
|
||||
|
||||
protected void callLocationAwareLogger(LocationAwareLogger lal,
|
||||
LogRecord record) {
|
||||
int julLevelValue = record.getLevel().intValue();
|
||||
int slf4jLevel;
|
||||
|
||||
if (julLevelValue <= TRACE_LEVEL_THRESHOLD) {
|
||||
slf4jLevel = LocationAwareLogger.TRACE_INT;
|
||||
} else if (julLevelValue <= DEBUG_LEVEL_THRESHOLD) {
|
||||
slf4jLevel = LocationAwareLogger.DEBUG_INT;
|
||||
} else if (julLevelValue <= INFO_LEVEL_THRESHOLD) {
|
||||
slf4jLevel = LocationAwareLogger.INFO_INT;
|
||||
} else if (julLevelValue <= WARN_LEVEL_THRESHOLD) {
|
||||
slf4jLevel = LocationAwareLogger.WARN_INT;
|
||||
} else {
|
||||
slf4jLevel = LocationAwareLogger.ERROR_INT;
|
||||
}
|
||||
String i18nMessage = getMessageI18N(record);
|
||||
lal.log(null, FQCN, slf4jLevel, i18nMessage, record.getThrown());
|
||||
}
|
||||
|
||||
protected void callPlainSLF4JLogger(Logger slf4jLogger, LogRecord record) {
|
||||
String i18nMessage = getMessageI18N(record);
|
||||
int julLevelValue = record.getLevel().intValue();
|
||||
if (julLevelValue <= TRACE_LEVEL_THRESHOLD) {
|
||||
slf4jLogger.trace(i18nMessage, record.getThrown());
|
||||
} else if (julLevelValue <= DEBUG_LEVEL_THRESHOLD) {
|
||||
slf4jLogger.debug(i18nMessage, record.getThrown());
|
||||
} else if (julLevelValue <= INFO_LEVEL_THRESHOLD) {
|
||||
slf4jLogger.info(i18nMessage, record.getThrown());
|
||||
} else if (julLevelValue <= WARN_LEVEL_THRESHOLD) {
|
||||
slf4jLogger.warn(i18nMessage, record.getThrown());
|
||||
} else {
|
||||
slf4jLogger.error(i18nMessage, record.getThrown());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the record's message, possibly via a resource bundle.
|
||||
*
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
private String getMessageI18N(LogRecord record) {
|
||||
String message = record.getMessage();
|
||||
|
||||
if (message == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ResourceBundle bundle = record.getResourceBundle();
|
||||
if (bundle != null) {
|
||||
try {
|
||||
message = bundle.getString(message);
|
||||
} catch (MissingResourceException e) {
|
||||
}
|
||||
}
|
||||
Object[] params = record.getParameters();
|
||||
if (params != null) {
|
||||
message = MessageFormat.format(message, params);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a LogRecord.
|
||||
* <p>
|
||||
* The logging request was made initially to a Logger object, which
|
||||
* initialized the LogRecord and forwarded it here.
|
||||
* <p>
|
||||
* This handler ignores the Level attached to the LogRecord, as SLF4J cares
|
||||
* about discarding log statements.
|
||||
*
|
||||
* @param record
|
||||
* Description of the log event. A null record is silently ignored
|
||||
* and is not published.
|
||||
*/
|
||||
public void publish(LogRecord record) {
|
||||
// Silently ignore null records.
|
||||
if (record == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logger slf4jLogger = getSLF4JLogger(record);
|
||||
String message = record.getMessage(); // can be null!
|
||||
// this is a check to avoid calling the underlying logging system
|
||||
// with a null message. While it is legitimate to invoke j.u.l. with
|
||||
// a null message, other logging frameworks do not support this.
|
||||
// see also http://bugzilla.slf4j.org/show_bug.cgi?id=108
|
||||
if (message == null) {
|
||||
message = "";
|
||||
}
|
||||
if (slf4jLogger instanceof LocationAwareLogger) {
|
||||
callLocationAwareLogger((LocationAwareLogger) slf4jLogger, record);
|
||||
} else {
|
||||
callPlainSLF4JLogger(slf4jLogger, record);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*/
|
||||
|
||||
package org.slf4j.bridge;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.spi.LocationAwareLogger;
|
||||
|
||||
// Based on http://bugzilla.slf4j.org/show_bug.cgi?id=38
|
||||
|
||||
/**
|
||||
* Bridge/route all JUL log records to the SLF4J API.
|
||||
*
|
||||
* <p>
|
||||
* Essentially, the idea is to install on the root logger an instance of
|
||||
* SLF4JBridgeHandler as the sole JUL handler in the system. Subsequently, the
|
||||
* SLF4JBridgeHandler instance will redirect all JUL log records are redirected
|
||||
* to the SLF4J API based on the following mapping of levels:
|
||||
*
|
||||
* <pre>
|
||||
* FINEST -> TRACE
|
||||
* FINER -> DEBUG
|
||||
* FINE -> DEBUG
|
||||
* INFO -> INFO
|
||||
* WARNING -> WARN
|
||||
* SEVER -> ERROR
|
||||
* </pre>
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* <pre>
|
||||
* // call only once during initialization time of your application
|
||||
* SLF4JBridgeHandler.install();
|
||||
*
|
||||
* // usual pattern: get a Logger and then log a message
|
||||
* java.util.logging.Logger julLogger = java.util.logging.Logger
|
||||
* .getLogger("org.wombat");
|
||||
* julLogger.fine("hello world"); // this will get redirected to SLF4J
|
||||
* </pre>
|
||||
*
|
||||
* <p>
|
||||
* Please note that translating a java.util.logging event into SLF4J incurs the
|
||||
* cost of constructing {@link LogRecord} instance regardless of whether the
|
||||
* SLF4J logger is disabled for the given level. <b>Consequently, j.u.l. to
|
||||
* SLF4J translation can seriously impact on the cost of disabled logging
|
||||
* statements (60 fold increase) and a measurable impact on enabled log
|
||||
* statements (20% overall increase). </b>
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* If application performance is a concern, then use of SLF4JBridgeHandler is
|
||||
* appropriate only if few j.u.l. logging statements are in play.
|
||||
*
|
||||
* @author Christian Stein
|
||||
* @author Joern Huxhorn
|
||||
* @author Ceki Gülcü
|
||||
* @author Darryl Smith
|
||||
*
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public class SLF4JBridgeHandler extends Handler {
|
||||
|
||||
// The caller is java.util.logging.Logger
|
||||
private static final String FQCN = java.util.logging.Logger.class.getName();
|
||||
private static final String UNKNOWN_LOGGER_NAME = "unknown.jul.logger";
|
||||
|
||||
private static final int TRACE_LEVEL_THRESHOLD = Level.FINEST.intValue();
|
||||
private static final int DEBUG_LEVEL_THRESHOLD = Level.FINE.intValue();
|
||||
private static final int INFO_LEVEL_THRESHOLD = Level.INFO.intValue();
|
||||
private static final int WARN_LEVEL_THRESHOLD = Level.WARNING.intValue();
|
||||
|
||||
/**
|
||||
* Adds a SLF4JBridgeHandler instance to jul's root logger.
|
||||
*
|
||||
* <p>
|
||||
* This handler will redirect jul logging to SLF4J. However, only logs enabled
|
||||
* in j.u.l. will be redirected. For example, if a log statement invoking a
|
||||
* j.u.l. logger disabled that statement, by definition, will <em>not</em>
|
||||
* reach any SLF4JBridgeHandler instance and cannot be redirected.
|
||||
*/
|
||||
public static void install() {
|
||||
LogManager.getLogManager().getLogger("").addHandler(
|
||||
new SLF4JBridgeHandler());
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes previously installed SLF4JBridgeHandler instances. See also
|
||||
* {@link #install()}.
|
||||
*
|
||||
* @throws SecurityException
|
||||
* A <code>SecurityException</code> is thrown, if a security manager
|
||||
* exists and if the caller does not have
|
||||
* LoggingPermission("control").
|
||||
*/
|
||||
public static void uninstall() throws SecurityException {
|
||||
java.util.logging.Logger rootLogger = LogManager.getLogManager().getLogger(
|
||||
"");
|
||||
Handler[] handlers = rootLogger.getHandlers();
|
||||
for (int i = 0; i < handlers.length; i++) {
|
||||
if (handlers[i] instanceof SLF4JBridgeHandler) {
|
||||
rootLogger.removeHandler(handlers[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize this handler.
|
||||
*
|
||||
*/
|
||||
public SLF4JBridgeHandler() {
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op implementation.
|
||||
*/
|
||||
public void close() {
|
||||
// empty
|
||||
}
|
||||
|
||||
/**
|
||||
* No-op implementation.
|
||||
*/
|
||||
public void flush() {
|
||||
// empty
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Logger instance that will be used for logging.
|
||||
*/
|
||||
protected Logger getSLF4JLogger(LogRecord record) {
|
||||
String name = record.getLoggerName();
|
||||
if (name == null) {
|
||||
name = UNKNOWN_LOGGER_NAME;
|
||||
}
|
||||
return LoggerFactory.getLogger(name);
|
||||
}
|
||||
|
||||
protected void callLocationAwareLogger(LocationAwareLogger lal,
|
||||
LogRecord record) {
|
||||
int julLevelValue = record.getLevel().intValue();
|
||||
int slf4jLevel;
|
||||
|
||||
if (julLevelValue <= TRACE_LEVEL_THRESHOLD) {
|
||||
slf4jLevel = LocationAwareLogger.TRACE_INT;
|
||||
} else if (julLevelValue <= DEBUG_LEVEL_THRESHOLD) {
|
||||
slf4jLevel = LocationAwareLogger.DEBUG_INT;
|
||||
} else if (julLevelValue <= INFO_LEVEL_THRESHOLD) {
|
||||
slf4jLevel = LocationAwareLogger.INFO_INT;
|
||||
} else if (julLevelValue <= WARN_LEVEL_THRESHOLD) {
|
||||
slf4jLevel = LocationAwareLogger.WARN_INT;
|
||||
} else {
|
||||
slf4jLevel = LocationAwareLogger.ERROR_INT;
|
||||
}
|
||||
String i18nMessage = getMessageI18N(record);
|
||||
lal.log(null, FQCN, slf4jLevel, i18nMessage, record.getThrown());
|
||||
}
|
||||
|
||||
protected void callPlainSLF4JLogger(Logger slf4jLogger, LogRecord record) {
|
||||
String i18nMessage = getMessageI18N(record);
|
||||
int julLevelValue = record.getLevel().intValue();
|
||||
if (julLevelValue <= TRACE_LEVEL_THRESHOLD) {
|
||||
slf4jLogger.trace(i18nMessage, record.getThrown());
|
||||
} else if (julLevelValue <= DEBUG_LEVEL_THRESHOLD) {
|
||||
slf4jLogger.debug(i18nMessage, record.getThrown());
|
||||
} else if (julLevelValue <= INFO_LEVEL_THRESHOLD) {
|
||||
slf4jLogger.info(i18nMessage, record.getThrown());
|
||||
} else if (julLevelValue <= WARN_LEVEL_THRESHOLD) {
|
||||
slf4jLogger.warn(i18nMessage, record.getThrown());
|
||||
} else {
|
||||
slf4jLogger.error(i18nMessage, record.getThrown());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the record's message, possibly via a resource bundle.
|
||||
*
|
||||
* @param record
|
||||
* @return
|
||||
*/
|
||||
private String getMessageI18N(LogRecord record) {
|
||||
String message = record.getMessage();
|
||||
|
||||
if (message == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ResourceBundle bundle = record.getResourceBundle();
|
||||
if (bundle != null) {
|
||||
try {
|
||||
message = bundle.getString(message);
|
||||
} catch (MissingResourceException e) {
|
||||
}
|
||||
}
|
||||
Object[] params = record.getParameters();
|
||||
if (params != null) {
|
||||
message = MessageFormat.format(message, params);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Publish a LogRecord.
|
||||
* <p>
|
||||
* The logging request was made initially to a Logger object, which
|
||||
* initialized the LogRecord and forwarded it here.
|
||||
* <p>
|
||||
* This handler ignores the Level attached to the LogRecord, as SLF4J cares
|
||||
* about discarding log statements.
|
||||
*
|
||||
* @param record
|
||||
* Description of the log event. A null record is silently ignored
|
||||
* and is not published.
|
||||
*/
|
||||
public void publish(LogRecord record) {
|
||||
// Silently ignore null records.
|
||||
if (record == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Logger slf4jLogger = getSLF4JLogger(record);
|
||||
String message = record.getMessage(); // can be null!
|
||||
// this is a check to avoid calling the underlying logging system
|
||||
// with a null message. While it is legitimate to invoke j.u.l. with
|
||||
// a null message, other logging frameworks do not support this.
|
||||
// see also http://bugzilla.slf4j.org/show_bug.cgi?id=108
|
||||
if (message == null) {
|
||||
message = "";
|
||||
}
|
||||
if (slf4jLogger instanceof LocationAwareLogger) {
|
||||
callLocationAwareLogger((LocationAwareLogger) slf4jLogger, record);
|
||||
} else {
|
||||
callPlainSLF4JLogger(slf4jLogger, record);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<p>Bridge/route all JUL log records to the SLF4J API.</p>
|
||||
|
||||
<hr/>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<p>Bridge/route all JUL log records to the SLF4J API.</p>
|
||||
|
||||
<hr/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,53 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.bridge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.AppenderSkeleton;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
|
||||
public class ListAppender extends AppenderSkeleton {
|
||||
|
||||
public List list = new ArrayList();
|
||||
|
||||
public boolean extractLocationInfo = false;
|
||||
|
||||
protected void append(LoggingEvent event) {
|
||||
list.add(event);
|
||||
if(extractLocationInfo) {
|
||||
event.getLocationInformation();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
}
|
||||
|
||||
public boolean requiresLayout() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.bridge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.AppenderSkeleton;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
|
||||
public class ListAppender extends AppenderSkeleton {
|
||||
|
||||
public List list = new ArrayList();
|
||||
|
||||
public boolean extractLocationInfo = false;
|
||||
|
||||
protected void append(LoggingEvent event) {
|
||||
list.add(event);
|
||||
if(extractLocationInfo) {
|
||||
event.getLocationInformation();
|
||||
}
|
||||
}
|
||||
|
||||
public void close() {
|
||||
}
|
||||
|
||||
public boolean requiresLayout() {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,115 +1,115 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.bridge;
|
||||
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.FileAppender;
|
||||
import org.apache.log4j.PatternLayout;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SLF4JBridgeHandlerPerfTest extends TestCase {
|
||||
|
||||
static String LOGGER_NAME = "yay";
|
||||
static int RUN_LENGTH = 100*1000;
|
||||
|
||||
|
||||
// set to false to test enabled logging performance
|
||||
boolean disabledLogger = true;
|
||||
|
||||
FileAppender fileAppender;
|
||||
org.apache.log4j.Logger log4jRoot;
|
||||
java.util.logging.Logger julRootLogger = LogManager.getLogManager()
|
||||
.getLogger("");
|
||||
|
||||
java.util.logging.Logger julLogger = java.util.logging.Logger
|
||||
.getLogger(LOGGER_NAME);
|
||||
org.slf4j.Logger slf4jLogger = LoggerFactory.getLogger(LOGGER_NAME);
|
||||
|
||||
Handler[] existingHandlers;
|
||||
|
||||
public SLF4JBridgeHandlerPerfTest(String arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
fileAppender = new FileAppender(new PatternLayout("%r [%t] %p %c %x - %m%n"), "target/test-output/toto.log");
|
||||
|
||||
existingHandlers = julRootLogger.getHandlers();
|
||||
for (int i = 0; i < existingHandlers.length; i++) {
|
||||
julRootLogger.removeHandler(existingHandlers[i]);
|
||||
}
|
||||
log4jRoot = org.apache.log4j.Logger.getRootLogger();
|
||||
log4jRoot.addAppender(fileAppender);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
SLF4JBridgeHandler.uninstall();
|
||||
fileAppender.close();
|
||||
log4jRoot.getLoggerRepository().resetConfiguration();
|
||||
for (int i = 0; i < existingHandlers.length; i++) {
|
||||
julRootLogger.addHandler(existingHandlers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
double julLoggerLoop() {
|
||||
long start = System.nanoTime();
|
||||
for (int i = 0; i < RUN_LENGTH; i++) {
|
||||
julLogger.info("jul");
|
||||
}
|
||||
long end = System.nanoTime();
|
||||
return (end - start) * 1.0 / RUN_LENGTH;
|
||||
}
|
||||
|
||||
double slf4jLoggerLoop() {
|
||||
long start = System.nanoTime();
|
||||
for (int i = 0; i < RUN_LENGTH; i++) {
|
||||
slf4jLogger.info("slf4j");
|
||||
}
|
||||
long end = System.nanoTime();
|
||||
return (end - start) * 1.0 / RUN_LENGTH;
|
||||
}
|
||||
|
||||
public void testPerf() {
|
||||
SLF4JBridgeHandler.install();
|
||||
|
||||
if(disabledLogger) {
|
||||
log4jRoot.setLevel(org.apache.log4j.Level.ERROR);
|
||||
}
|
||||
julLoggerLoop();
|
||||
double julAvg=julLoggerLoop();
|
||||
System.out.println("Average cost per call (JUL->SLF4J->log4j): "+julAvg +" nanos");
|
||||
|
||||
slf4jLoggerLoop();
|
||||
double slf4jAvg=slf4jLoggerLoop();
|
||||
System.out.println("Average cost per call (SLF4J->log4j): "+slf4jAvg +" nanos");
|
||||
System.out.println("Ratio "+(julAvg/slf4jAvg));
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.bridge;
|
||||
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.FileAppender;
|
||||
import org.apache.log4j.PatternLayout;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SLF4JBridgeHandlerPerfTest extends TestCase {
|
||||
|
||||
static String LOGGER_NAME = "yay";
|
||||
static int RUN_LENGTH = 100*1000;
|
||||
|
||||
|
||||
// set to false to test enabled logging performance
|
||||
boolean disabledLogger = true;
|
||||
|
||||
FileAppender fileAppender;
|
||||
org.apache.log4j.Logger log4jRoot;
|
||||
java.util.logging.Logger julRootLogger = LogManager.getLogManager()
|
||||
.getLogger("");
|
||||
|
||||
java.util.logging.Logger julLogger = java.util.logging.Logger
|
||||
.getLogger(LOGGER_NAME);
|
||||
org.slf4j.Logger slf4jLogger = LoggerFactory.getLogger(LOGGER_NAME);
|
||||
|
||||
Handler[] existingHandlers;
|
||||
|
||||
public SLF4JBridgeHandlerPerfTest(String arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
fileAppender = new FileAppender(new PatternLayout("%r [%t] %p %c %x - %m%n"), "target/test-output/toto.log");
|
||||
|
||||
existingHandlers = julRootLogger.getHandlers();
|
||||
for (int i = 0; i < existingHandlers.length; i++) {
|
||||
julRootLogger.removeHandler(existingHandlers[i]);
|
||||
}
|
||||
log4jRoot = org.apache.log4j.Logger.getRootLogger();
|
||||
log4jRoot.addAppender(fileAppender);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
SLF4JBridgeHandler.uninstall();
|
||||
fileAppender.close();
|
||||
log4jRoot.getLoggerRepository().resetConfiguration();
|
||||
for (int i = 0; i < existingHandlers.length; i++) {
|
||||
julRootLogger.addHandler(existingHandlers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
double julLoggerLoop() {
|
||||
long start = System.nanoTime();
|
||||
for (int i = 0; i < RUN_LENGTH; i++) {
|
||||
julLogger.info("jul");
|
||||
}
|
||||
long end = System.nanoTime();
|
||||
return (end - start) * 1.0 / RUN_LENGTH;
|
||||
}
|
||||
|
||||
double slf4jLoggerLoop() {
|
||||
long start = System.nanoTime();
|
||||
for (int i = 0; i < RUN_LENGTH; i++) {
|
||||
slf4jLogger.info("slf4j");
|
||||
}
|
||||
long end = System.nanoTime();
|
||||
return (end - start) * 1.0 / RUN_LENGTH;
|
||||
}
|
||||
|
||||
public void testPerf() {
|
||||
SLF4JBridgeHandler.install();
|
||||
|
||||
if(disabledLogger) {
|
||||
log4jRoot.setLevel(org.apache.log4j.Level.ERROR);
|
||||
}
|
||||
julLoggerLoop();
|
||||
double julAvg=julLoggerLoop();
|
||||
System.out.println("Average cost per call (JUL->SLF4J->log4j): "+julAvg +" nanos");
|
||||
|
||||
slf4jLoggerLoop();
|
||||
double slf4jAvg=slf4jLoggerLoop();
|
||||
System.out.println("Average cost per call (SLF4J->log4j): "+slf4jAvg +" nanos");
|
||||
System.out.println("Ratio "+(julAvg/slf4jAvg));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,175 +1,175 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.bridge;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.spi.LocationInfo;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
|
||||
public class SLF4JBridgeHandlerTest extends TestCase {
|
||||
|
||||
static String LOGGER_NAME = "yay";
|
||||
|
||||
ListAppender listAppender = new ListAppender();
|
||||
org.apache.log4j.Logger log4jRoot;
|
||||
java.util.logging.Logger julLogger = java.util.logging.Logger
|
||||
.getLogger("yay");
|
||||
|
||||
public SLF4JBridgeHandlerTest(String arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
listAppender.extractLocationInfo = true;
|
||||
log4jRoot = org.apache.log4j.Logger.getRootLogger();
|
||||
log4jRoot.addAppender(listAppender);
|
||||
log4jRoot.setLevel(org.apache.log4j.Level.TRACE);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
SLF4JBridgeHandler.uninstall();
|
||||
log4jRoot.getLoggerRepository().resetConfiguration();
|
||||
}
|
||||
|
||||
public void testSmoke() {
|
||||
SLF4JBridgeHandler.install();
|
||||
String msg = "msg";
|
||||
julLogger.info(msg);
|
||||
assertEquals(1, listAppender.list.size());
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
|
||||
assertEquals(LOGGER_NAME, le.getLoggerName());
|
||||
assertEquals(msg, le.getMessage());
|
||||
|
||||
// get the location info in the event.
|
||||
// Note that this must have been computed previously
|
||||
// within an appender for the following assertion to
|
||||
// work properly
|
||||
LocationInfo li = le.getLocationInformation();
|
||||
System.out.println(li.fullInfo);
|
||||
assertEquals("SLF4JBridgeHandlerTest.java", li.getFileName());
|
||||
assertEquals("testSmoke", li.getMethodName());
|
||||
}
|
||||
|
||||
public void testLevels() {
|
||||
SLF4JBridgeHandler.install();
|
||||
String msg = "msg";
|
||||
julLogger.setLevel(Level.ALL);
|
||||
|
||||
julLogger.finest(msg);
|
||||
julLogger.finer(msg);
|
||||
julLogger.fine(msg);
|
||||
julLogger.info(msg);
|
||||
julLogger.warning(msg);
|
||||
julLogger.severe(msg);
|
||||
|
||||
assertEquals(6, listAppender.list.size());
|
||||
int i = 0;
|
||||
assertLevel(i++, org.apache.log4j.Level.TRACE);
|
||||
assertLevel(i++, org.apache.log4j.Level.DEBUG);
|
||||
assertLevel(i++, org.apache.log4j.Level.DEBUG);
|
||||
assertLevel(i++, org.apache.log4j.Level.INFO);
|
||||
assertLevel(i++, org.apache.log4j.Level.WARN);
|
||||
assertLevel(i++, org.apache.log4j.Level.ERROR);
|
||||
}
|
||||
|
||||
public void testLogWithResourceBundle() {
|
||||
SLF4JBridgeHandler.install();
|
||||
|
||||
String resourceBundleName = "org.slf4j.bridge.testLogStrings";
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(resourceBundleName);
|
||||
String resourceKey = "resource_key";
|
||||
String expectedMsg = bundle.getString(resourceKey);
|
||||
String msg = resourceKey;
|
||||
|
||||
java.util.logging.Logger julResourceBundleLogger = java.util.logging.Logger
|
||||
.getLogger("yay", resourceBundleName);
|
||||
|
||||
julResourceBundleLogger.info(msg);
|
||||
assertEquals(1, listAppender.list.size());
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
|
||||
assertEquals(LOGGER_NAME, le.getLoggerName());
|
||||
assertEquals(expectedMsg, le.getMessage());
|
||||
}
|
||||
|
||||
public void testLogWithResourceBundleWithParameters() {
|
||||
SLF4JBridgeHandler.install();
|
||||
|
||||
String resourceBundleName = "org.slf4j.bridge.testLogStrings";
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(resourceBundleName);
|
||||
|
||||
java.util.logging.Logger julResourceBundleLogger = java.util.logging.Logger
|
||||
.getLogger("foo", resourceBundleName);
|
||||
|
||||
String resourceKey1 = "resource_key_1";
|
||||
String expectedMsg1 = bundle.getString(resourceKey1);
|
||||
julResourceBundleLogger.info(resourceKey1); // 1st log
|
||||
|
||||
String resourceKey2 = "resource_key_2";
|
||||
Object[] params2 = new Object[] { "foo", "bar" };
|
||||
String expectedMsg2 = MessageFormat.format(bundle.getString(resourceKey2),
|
||||
params2);
|
||||
julResourceBundleLogger.log(Level.INFO, resourceKey2, params2); // 2nd log
|
||||
|
||||
|
||||
String resourceKey3 = "invalidKey {0}";
|
||||
Object[] params3 = new Object[] { "John" };
|
||||
String expectedMsg3 = MessageFormat.format(resourceKey3, params3);
|
||||
julResourceBundleLogger.log(Level.INFO, resourceKey3, params3); // 3rd log
|
||||
|
||||
julLogger.log(Level.INFO, resourceKey3, params3); // 4th log
|
||||
|
||||
assertEquals(4, listAppender.list.size());
|
||||
|
||||
LoggingEvent le = null;
|
||||
|
||||
le = (LoggingEvent) listAppender.list.get(0);
|
||||
assertEquals("foo", le.getLoggerName());
|
||||
assertEquals(expectedMsg1, le.getMessage());
|
||||
|
||||
le = (LoggingEvent) listAppender.list.get(1);
|
||||
assertEquals("foo", le.getLoggerName());
|
||||
assertEquals(expectedMsg2, le.getMessage());
|
||||
|
||||
le = (LoggingEvent) listAppender.list.get(2);
|
||||
assertEquals("foo", le.getLoggerName());
|
||||
assertEquals(expectedMsg3, le.getMessage());
|
||||
|
||||
le = (LoggingEvent) listAppender.list.get(3);
|
||||
assertEquals("yay", le.getLoggerName());
|
||||
assertEquals(expectedMsg3, le.getMessage());
|
||||
}
|
||||
|
||||
void assertLevel(int index, org.apache.log4j.Level expectedLevel) {
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(index);
|
||||
assertEquals(expectedLevel, le.getLevel());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.bridge;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.spi.LocationInfo;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
|
||||
public class SLF4JBridgeHandlerTest extends TestCase {
|
||||
|
||||
static String LOGGER_NAME = "yay";
|
||||
|
||||
ListAppender listAppender = new ListAppender();
|
||||
org.apache.log4j.Logger log4jRoot;
|
||||
java.util.logging.Logger julLogger = java.util.logging.Logger
|
||||
.getLogger("yay");
|
||||
|
||||
public SLF4JBridgeHandlerTest(String arg0) {
|
||||
super(arg0);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
listAppender.extractLocationInfo = true;
|
||||
log4jRoot = org.apache.log4j.Logger.getRootLogger();
|
||||
log4jRoot.addAppender(listAppender);
|
||||
log4jRoot.setLevel(org.apache.log4j.Level.TRACE);
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
SLF4JBridgeHandler.uninstall();
|
||||
log4jRoot.getLoggerRepository().resetConfiguration();
|
||||
}
|
||||
|
||||
public void testSmoke() {
|
||||
SLF4JBridgeHandler.install();
|
||||
String msg = "msg";
|
||||
julLogger.info(msg);
|
||||
assertEquals(1, listAppender.list.size());
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
|
||||
assertEquals(LOGGER_NAME, le.getLoggerName());
|
||||
assertEquals(msg, le.getMessage());
|
||||
|
||||
// get the location info in the event.
|
||||
// Note that this must have been computed previously
|
||||
// within an appender for the following assertion to
|
||||
// work properly
|
||||
LocationInfo li = le.getLocationInformation();
|
||||
System.out.println(li.fullInfo);
|
||||
assertEquals("SLF4JBridgeHandlerTest.java", li.getFileName());
|
||||
assertEquals("testSmoke", li.getMethodName());
|
||||
}
|
||||
|
||||
public void testLevels() {
|
||||
SLF4JBridgeHandler.install();
|
||||
String msg = "msg";
|
||||
julLogger.setLevel(Level.ALL);
|
||||
|
||||
julLogger.finest(msg);
|
||||
julLogger.finer(msg);
|
||||
julLogger.fine(msg);
|
||||
julLogger.info(msg);
|
||||
julLogger.warning(msg);
|
||||
julLogger.severe(msg);
|
||||
|
||||
assertEquals(6, listAppender.list.size());
|
||||
int i = 0;
|
||||
assertLevel(i++, org.apache.log4j.Level.TRACE);
|
||||
assertLevel(i++, org.apache.log4j.Level.DEBUG);
|
||||
assertLevel(i++, org.apache.log4j.Level.DEBUG);
|
||||
assertLevel(i++, org.apache.log4j.Level.INFO);
|
||||
assertLevel(i++, org.apache.log4j.Level.WARN);
|
||||
assertLevel(i++, org.apache.log4j.Level.ERROR);
|
||||
}
|
||||
|
||||
public void testLogWithResourceBundle() {
|
||||
SLF4JBridgeHandler.install();
|
||||
|
||||
String resourceBundleName = "org.slf4j.bridge.testLogStrings";
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(resourceBundleName);
|
||||
String resourceKey = "resource_key";
|
||||
String expectedMsg = bundle.getString(resourceKey);
|
||||
String msg = resourceKey;
|
||||
|
||||
java.util.logging.Logger julResourceBundleLogger = java.util.logging.Logger
|
||||
.getLogger("yay", resourceBundleName);
|
||||
|
||||
julResourceBundleLogger.info(msg);
|
||||
assertEquals(1, listAppender.list.size());
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(0);
|
||||
assertEquals(LOGGER_NAME, le.getLoggerName());
|
||||
assertEquals(expectedMsg, le.getMessage());
|
||||
}
|
||||
|
||||
public void testLogWithResourceBundleWithParameters() {
|
||||
SLF4JBridgeHandler.install();
|
||||
|
||||
String resourceBundleName = "org.slf4j.bridge.testLogStrings";
|
||||
ResourceBundle bundle = ResourceBundle.getBundle(resourceBundleName);
|
||||
|
||||
java.util.logging.Logger julResourceBundleLogger = java.util.logging.Logger
|
||||
.getLogger("foo", resourceBundleName);
|
||||
|
||||
String resourceKey1 = "resource_key_1";
|
||||
String expectedMsg1 = bundle.getString(resourceKey1);
|
||||
julResourceBundleLogger.info(resourceKey1); // 1st log
|
||||
|
||||
String resourceKey2 = "resource_key_2";
|
||||
Object[] params2 = new Object[] { "foo", "bar" };
|
||||
String expectedMsg2 = MessageFormat.format(bundle.getString(resourceKey2),
|
||||
params2);
|
||||
julResourceBundleLogger.log(Level.INFO, resourceKey2, params2); // 2nd log
|
||||
|
||||
|
||||
String resourceKey3 = "invalidKey {0}";
|
||||
Object[] params3 = new Object[] { "John" };
|
||||
String expectedMsg3 = MessageFormat.format(resourceKey3, params3);
|
||||
julResourceBundleLogger.log(Level.INFO, resourceKey3, params3); // 3rd log
|
||||
|
||||
julLogger.log(Level.INFO, resourceKey3, params3); // 4th log
|
||||
|
||||
assertEquals(4, listAppender.list.size());
|
||||
|
||||
LoggingEvent le = null;
|
||||
|
||||
le = (LoggingEvent) listAppender.list.get(0);
|
||||
assertEquals("foo", le.getLoggerName());
|
||||
assertEquals(expectedMsg1, le.getMessage());
|
||||
|
||||
le = (LoggingEvent) listAppender.list.get(1);
|
||||
assertEquals("foo", le.getLoggerName());
|
||||
assertEquals(expectedMsg2, le.getMessage());
|
||||
|
||||
le = (LoggingEvent) listAppender.list.get(2);
|
||||
assertEquals("foo", le.getLoggerName());
|
||||
assertEquals(expectedMsg3, le.getMessage());
|
||||
|
||||
le = (LoggingEvent) listAppender.list.get(3);
|
||||
assertEquals("yay", le.getLoggerName());
|
||||
assertEquals(expectedMsg3, le.getMessage());
|
||||
}
|
||||
|
||||
void assertLevel(int index, org.apache.log4j.Level expectedLevel) {
|
||||
LoggingEvent le = (LoggingEvent) listAppender.list.get(index);
|
||||
assertEquals(expectedLevel, le.getLevel());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
resource_key=msg
|
||||
resource_key_1=msg
|
||||
resource_key_2=msg {0} {1}
|
||||
resource_key=msg
|
||||
resource_key_1=msg
|
||||
resource_key_2=msg {0} {1}
|
||||
|
|
|
|||
|
|
@ -1,137 +1,137 @@
|
|||
<project name="testing-log4j-bridge" default="usage" basedir=".">
|
||||
|
||||
<property name="lbversion" value="0.9.8-SNAPSHOT" />
|
||||
<property name="slf4jversion" value="1.4.2" />
|
||||
<property name="source.home" value="./src/main/java/" />
|
||||
<property name="javac.dest.12" value="./target/classes12/" />
|
||||
<property name="javac.dest.13" value="./target/classes13/" />
|
||||
<property name="lib" value="./lib" />
|
||||
|
||||
<property name="deprecation" value="on" />
|
||||
|
||||
<path id="basic.classpath">
|
||||
<pathelement location="${source.home}" />
|
||||
<pathelement location="${lib}/junit-3.8.1.jar" />
|
||||
</path>
|
||||
|
||||
<path id="log4j12.classpath">
|
||||
<path refid="basic.classpath" />
|
||||
<pathelement location="${javac.dest.12}" />
|
||||
<pathelement location="${lib}/log4j-1.2.14.jar" />
|
||||
</path>
|
||||
|
||||
<path id="log4j13.classpath">
|
||||
<path refid="basic.classpath" />
|
||||
<pathelement location="${javac.dest.13}" />
|
||||
<pathelement location="${lib}/log4j-1.3alpha-8.jar" />
|
||||
</path>
|
||||
|
||||
<path id="los.classpath">
|
||||
<path refid="basic.classpath" />
|
||||
<pathelement location="${lib}/log4j-over-slf4j-${slf4jversion}.jar" />
|
||||
<pathelement location="${lib}/logback-classic-${lbversion}.jar" />
|
||||
<pathelement location="${lib}/logback-core-${lbversion}.jar" />
|
||||
<pathelement location="${lib}/slf4j-api-${slf4jversion}.jar" />
|
||||
</path>
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- Default target -->
|
||||
<!-- ================================================================= -->
|
||||
<target name="usage">
|
||||
<echo>
|
||||
These are some of the targets supported by this ANT build scpript:
|
||||
|
||||
all - run all available tests
|
||||
refresh - copy required jar files to the lib directory
|
||||
</echo>
|
||||
</target>
|
||||
|
||||
<delete>
|
||||
<fileset dir="." includes="**/*.bak"/>
|
||||
</delete>
|
||||
|
||||
<target name="refresh">
|
||||
<delete>
|
||||
<fileset dir="lib">
|
||||
<include name="logback-*.jar"/>
|
||||
<include name="log4j-bridge-*.jar"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
<copy file="../../slf4j-api/target/slf4j-api-${slf4jversion}.jar" todir="lib/"/>
|
||||
<copy file="../target/log4j-over-slf4j-${slf4jversion}.jar" todir="lib/"/>
|
||||
|
||||
</target>
|
||||
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="${javac.dest.12}" />
|
||||
<mkdir dir="${javac.dest.13}" />
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete>
|
||||
<fileset dir="${javac.dest.12}" includes="**" />
|
||||
<fileset dir="${javac.dest.13}" includes="**" />
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="build_log4j12" depends="init">
|
||||
<javac srcdir="${source.home}"
|
||||
destdir="${javac.dest.12}"
|
||||
includes="**/Log4j12Calls.java"
|
||||
deprecation="${deprecation}" debug="on">
|
||||
<classpath refid="log4j12.classpath" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="build_log4j13" depends="init">
|
||||
<javac srcdir="${source.home}"
|
||||
destdir="${javac.dest.13}"
|
||||
includes="**/Log4j13Calls.java" deprecation="${deprecation}" debug="on">
|
||||
<classpath refid="log4j13.classpath" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="build_loggerTest" depends="init">
|
||||
<javac srcdir="${source.home}"
|
||||
destdir="${javac.dest.12}"
|
||||
includes="**/LoggerTest.java"
|
||||
deprecation="${deprecation}" debug="on">
|
||||
<classpath refid="los.classpath" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- Run tests -->
|
||||
<!-- ================================================================= -->
|
||||
<target name="all" depends="test12, test13, loggerTest" />
|
||||
|
||||
|
||||
<target name="loggerTest" depends="build_loggerTest">
|
||||
<junit printsummary="yes" fork="yes" haltonfailure="yes">
|
||||
<classpath refid="los.classpath" />
|
||||
<classpath location="${javac.dest.12}" />
|
||||
<formatter type="plain" usefile="false" />
|
||||
<test name="test.LoggerTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="test12" depends="build_log4j12">
|
||||
<junit printsummary="yes" fork="yes" haltonfailure="yes">
|
||||
<classpath refid="los.classpath" />
|
||||
<classpath location="${javac.dest.12}" />
|
||||
<formatter type="plain" usefile="false" />
|
||||
<test name="test.Log4j12Calls" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="test13" depends="build_log4j13">
|
||||
<junit printsummary="yes" fork="yes" haltonfailure="yes">
|
||||
<classpath refid="los.classpath" />
|
||||
<classpath location="${javac.dest.13}" />
|
||||
<formatter type="plain" usefile="false" />
|
||||
<test name="test.Log4j13Calls" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
<project name="testing-log4j-bridge" default="usage" basedir=".">
|
||||
|
||||
<property name="lbversion" value="0.9.8-SNAPSHOT" />
|
||||
<property name="slf4jversion" value="1.4.2" />
|
||||
<property name="source.home" value="./src/main/java/" />
|
||||
<property name="javac.dest.12" value="./target/classes12/" />
|
||||
<property name="javac.dest.13" value="./target/classes13/" />
|
||||
<property name="lib" value="./lib" />
|
||||
|
||||
<property name="deprecation" value="on" />
|
||||
|
||||
<path id="basic.classpath">
|
||||
<pathelement location="${source.home}" />
|
||||
<pathelement location="${lib}/junit-3.8.1.jar" />
|
||||
</path>
|
||||
|
||||
<path id="log4j12.classpath">
|
||||
<path refid="basic.classpath" />
|
||||
<pathelement location="${javac.dest.12}" />
|
||||
<pathelement location="${lib}/log4j-1.2.14.jar" />
|
||||
</path>
|
||||
|
||||
<path id="log4j13.classpath">
|
||||
<path refid="basic.classpath" />
|
||||
<pathelement location="${javac.dest.13}" />
|
||||
<pathelement location="${lib}/log4j-1.3alpha-8.jar" />
|
||||
</path>
|
||||
|
||||
<path id="los.classpath">
|
||||
<path refid="basic.classpath" />
|
||||
<pathelement location="${lib}/log4j-over-slf4j-${slf4jversion}.jar" />
|
||||
<pathelement location="${lib}/logback-classic-${lbversion}.jar" />
|
||||
<pathelement location="${lib}/logback-core-${lbversion}.jar" />
|
||||
<pathelement location="${lib}/slf4j-api-${slf4jversion}.jar" />
|
||||
</path>
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- Default target -->
|
||||
<!-- ================================================================= -->
|
||||
<target name="usage">
|
||||
<echo>
|
||||
These are some of the targets supported by this ANT build scpript:
|
||||
|
||||
all - run all available tests
|
||||
refresh - copy required jar files to the lib directory
|
||||
</echo>
|
||||
</target>
|
||||
|
||||
<delete>
|
||||
<fileset dir="." includes="**/*.bak"/>
|
||||
</delete>
|
||||
|
||||
<target name="refresh">
|
||||
<delete>
|
||||
<fileset dir="lib">
|
||||
<include name="logback-*.jar"/>
|
||||
<include name="log4j-bridge-*.jar"/>
|
||||
</fileset>
|
||||
</delete>
|
||||
<copy file="../../slf4j-api/target/slf4j-api-${slf4jversion}.jar" todir="lib/"/>
|
||||
<copy file="../target/log4j-over-slf4j-${slf4jversion}.jar" todir="lib/"/>
|
||||
|
||||
</target>
|
||||
|
||||
|
||||
<target name="init">
|
||||
<mkdir dir="${javac.dest.12}" />
|
||||
<mkdir dir="${javac.dest.13}" />
|
||||
</target>
|
||||
|
||||
<target name="clean">
|
||||
<delete>
|
||||
<fileset dir="${javac.dest.12}" includes="**" />
|
||||
<fileset dir="${javac.dest.13}" includes="**" />
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="build_log4j12" depends="init">
|
||||
<javac srcdir="${source.home}"
|
||||
destdir="${javac.dest.12}"
|
||||
includes="**/Log4j12Calls.java"
|
||||
deprecation="${deprecation}" debug="on">
|
||||
<classpath refid="log4j12.classpath" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="build_log4j13" depends="init">
|
||||
<javac srcdir="${source.home}"
|
||||
destdir="${javac.dest.13}"
|
||||
includes="**/Log4j13Calls.java" deprecation="${deprecation}" debug="on">
|
||||
<classpath refid="log4j13.classpath" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<target name="build_loggerTest" depends="init">
|
||||
<javac srcdir="${source.home}"
|
||||
destdir="${javac.dest.12}"
|
||||
includes="**/LoggerTest.java"
|
||||
deprecation="${deprecation}" debug="on">
|
||||
<classpath refid="los.classpath" />
|
||||
</javac>
|
||||
</target>
|
||||
|
||||
<!-- ================================================================= -->
|
||||
<!-- Run tests -->
|
||||
<!-- ================================================================= -->
|
||||
<target name="all" depends="test12, test13, loggerTest" />
|
||||
|
||||
|
||||
<target name="loggerTest" depends="build_loggerTest">
|
||||
<junit printsummary="yes" fork="yes" haltonfailure="yes">
|
||||
<classpath refid="los.classpath" />
|
||||
<classpath location="${javac.dest.12}" />
|
||||
<formatter type="plain" usefile="false" />
|
||||
<test name="test.LoggerTest" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="test12" depends="build_log4j12">
|
||||
<junit printsummary="yes" fork="yes" haltonfailure="yes">
|
||||
<classpath refid="los.classpath" />
|
||||
<classpath location="${javac.dest.12}" />
|
||||
<formatter type="plain" usefile="false" />
|
||||
<test name="test.Log4j12Calls" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
<target name="test13" depends="build_log4j13">
|
||||
<junit printsummary="yes" fork="yes" haltonfailure="yes">
|
||||
<classpath refid="los.classpath" />
|
||||
<classpath location="${javac.dest.13}" />
|
||||
<formatter type="plain" usefile="false" />
|
||||
<test name="test.Log4j13Calls" />
|
||||
</junit>
|
||||
</target>
|
||||
|
||||
</project>
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
|
||||
This directory is used to test the module against various log4j calls.
|
||||
Two test cases simulate the typical calls that one can find in an application
|
||||
that uses either log4j 1.2.x, or log4j 1.3.x.
|
||||
|
||||
In the same directory is a build.xml file that uses ant to
|
||||
compile the test cases with the corresponding log4j version,
|
||||
and to runs these tests without log4j in the classpath but with
|
||||
logback jars instead.
|
||||
|
||||
To run the tests, one must have ant installed. Issuing the following command,
|
||||
once in the compatibility directory will launch the tests:
|
||||
|
||||
ant all
|
||||
|
||||
To obtain more information about the use of the log4j-over-slf4j module,
|
||||
|
||||
This directory is used to test the module against various log4j calls.
|
||||
Two test cases simulate the typical calls that one can find in an application
|
||||
that uses either log4j 1.2.x, or log4j 1.3.x.
|
||||
|
||||
In the same directory is a build.xml file that uses ant to
|
||||
compile the test cases with the corresponding log4j version,
|
||||
and to runs these tests without log4j in the classpath but with
|
||||
logback jars instead.
|
||||
|
||||
To run the tests, one must have ant installed. Issuing the following command,
|
||||
once in the compatibility directory will launch the tests:
|
||||
|
||||
ant all
|
||||
|
||||
To obtain more information about the use of the log4j-over-slf4j module,
|
||||
please visit http://www..slf4j.org/log4j-over-slf4j.html
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package test;
|
||||
|
||||
public class DummyObject {
|
||||
|
||||
public String toString() {
|
||||
return "dummy";
|
||||
}
|
||||
}
|
||||
package test;
|
||||
|
||||
public class DummyObject {
|
||||
|
||||
public String toString() {
|
||||
return "dummy";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,39 +1,39 @@
|
|||
/**
|
||||
* Logback: the reliable, generic, fast and flexible logging framework.
|
||||
*
|
||||
* Copyright (C) 1999-2006, QOS.ch
|
||||
*
|
||||
* This library is free software, you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation.
|
||||
*/
|
||||
package test;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.MDC;
|
||||
|
||||
/**
|
||||
*
|
||||
* A test case that issues the typical calls
|
||||
* that an application using log4j 1.2 would do.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author Sébastien Pennec
|
||||
*/
|
||||
public class Log4j12Calls extends TestCase {
|
||||
public static final Logger logger = Logger.getLogger(Log4j12Calls.class);
|
||||
|
||||
public void testLog() {
|
||||
MDC.put("key", "value1");
|
||||
|
||||
logger.trace("Trace level can be noisy");
|
||||
logger.debug("Entering application");
|
||||
logger.info("Violets are blue");
|
||||
logger.warn("Here is a warning");
|
||||
logger.error("Exiting application", new Exception("just testing"));
|
||||
|
||||
MDC.remove("key");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Logback: the reliable, generic, fast and flexible logging framework.
|
||||
*
|
||||
* Copyright (C) 1999-2006, QOS.ch
|
||||
*
|
||||
* This library is free software, you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation.
|
||||
*/
|
||||
package test;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.MDC;
|
||||
|
||||
/**
|
||||
*
|
||||
* A test case that issues the typical calls
|
||||
* that an application using log4j 1.2 would do.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author Sébastien Pennec
|
||||
*/
|
||||
public class Log4j12Calls extends TestCase {
|
||||
public static final Logger logger = Logger.getLogger(Log4j12Calls.class);
|
||||
|
||||
public void testLog() {
|
||||
MDC.put("key", "value1");
|
||||
|
||||
logger.trace("Trace level can be noisy");
|
||||
logger.debug("Entering application");
|
||||
logger.info("Violets are blue");
|
||||
logger.warn("Here is a warning");
|
||||
logger.error("Exiting application", new Exception("just testing"));
|
||||
|
||||
MDC.remove("key");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,46 +1,46 @@
|
|||
/**
|
||||
* Logback: the reliable, generic, fast and flexible logging framework.
|
||||
*
|
||||
* Copyright (C) 1999-2006, QOS.ch
|
||||
*
|
||||
* This library is free software, you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation.
|
||||
*/
|
||||
|
||||
package test;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.MDC;
|
||||
|
||||
/**
|
||||
*
|
||||
* A test case that issues the typical calls
|
||||
* that an application using log4j 1.3 would do.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author Sébastien Pennec
|
||||
*/
|
||||
|
||||
public class Log4j13Calls extends TestCase {
|
||||
public static final Logger logger = Logger.getLogger(Log4j12Calls.class);
|
||||
|
||||
public void testLog() {
|
||||
MDC.put("key", "value1");
|
||||
|
||||
logger.trace("Trace level can be noisy");
|
||||
logger.debug("Entering application");
|
||||
logger.info("Violets are blue");
|
||||
logger.warn("Here is a warning");
|
||||
logger.info("The answer is {}.", new Integer(42));
|
||||
logger.info("Number: {} and another one: {}.", new Integer(42), new Integer(24));
|
||||
|
||||
logger.error("Exiting application", new Exception("just testing"));
|
||||
|
||||
MDC.remove("key");
|
||||
|
||||
MDC.clear();
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Logback: the reliable, generic, fast and flexible logging framework.
|
||||
*
|
||||
* Copyright (C) 1999-2006, QOS.ch
|
||||
*
|
||||
* This library is free software, you can redistribute it and/or modify it under
|
||||
* the terms of the GNU Lesser General Public License as published by the Free
|
||||
* Software Foundation.
|
||||
*/
|
||||
|
||||
package test;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.log4j.MDC;
|
||||
|
||||
/**
|
||||
*
|
||||
* A test case that issues the typical calls
|
||||
* that an application using log4j 1.3 would do.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author Sébastien Pennec
|
||||
*/
|
||||
|
||||
public class Log4j13Calls extends TestCase {
|
||||
public static final Logger logger = Logger.getLogger(Log4j12Calls.class);
|
||||
|
||||
public void testLog() {
|
||||
MDC.put("key", "value1");
|
||||
|
||||
logger.trace("Trace level can be noisy");
|
||||
logger.debug("Entering application");
|
||||
logger.info("Violets are blue");
|
||||
logger.warn("Here is a warning");
|
||||
logger.info("The answer is {}.", new Integer(42));
|
||||
logger.info("Number: {} and another one: {}.", new Integer(42), new Integer(24));
|
||||
|
||||
logger.error("Exiting application", new Exception("just testing"));
|
||||
|
||||
MDC.remove("key");
|
||||
|
||||
MDC.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,169 +1,169 @@
|
|||
package test;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import ch.qos.logback.classic.spi.LoggingEvent;
|
||||
import ch.qos.logback.core.read.ListAppender;
|
||||
import org.apache.log4j.Level;
|
||||
|
||||
/**
|
||||
* A class that tests the invocation of the org.apache.log4j.Logger class that
|
||||
* belongs to the log4j-bridge package
|
||||
*
|
||||
* @author Sébastien Pennec
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
|
||||
public class LoggerTest extends TestCase {
|
||||
|
||||
LoggerContext context;
|
||||
ListAppender<LoggingEvent> appender;
|
||||
ch.qos.logback.classic.Logger logbackLogger;
|
||||
org.apache.log4j.Logger log4jLogger;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
context = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
context.shutdownAndReset();
|
||||
appender = new ListAppender<LoggingEvent>();
|
||||
appender.setContext(context);
|
||||
appender.setName("listAppender");
|
||||
appender.start();
|
||||
ch.qos.logback.classic.Logger lbLogger = context
|
||||
.getLogger(LoggerContext.ROOT_NAME);
|
||||
lbLogger.addAppender(appender);
|
||||
|
||||
log4jLogger = org.apache.log4j.Logger.getLogger(LoggerTest.class);
|
||||
logbackLogger = context.getLogger(LoggerTest.class);
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
appender.stop();
|
||||
context.stop();
|
||||
appender = null;
|
||||
context = null;
|
||||
logbackLogger = null;
|
||||
log4jLogger = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testLogWithObjectMessages() {
|
||||
LoggingEvent event;
|
||||
|
||||
log4jLogger.debug("test");
|
||||
event = appender.list.get(0);
|
||||
assertEquals("test", event.getMessage());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug(null);
|
||||
event = appender.list.get(0);
|
||||
assertEquals(null, event.getMessage());
|
||||
appender.list.clear();
|
||||
|
||||
DummyObject dummy = new DummyObject();
|
||||
log4jLogger.debug(dummy);
|
||||
event = appender.list.get(0);
|
||||
assertEquals(dummy.toString(), event.getMessage());
|
||||
appender.list.clear();
|
||||
}
|
||||
|
||||
public void testIsEnabledAPI() {
|
||||
assertFalse(log4jLogger.isTraceEnabled());
|
||||
assertTrue(log4jLogger.isDebugEnabled());
|
||||
assertTrue(log4jLogger.isInfoEnabled());
|
||||
assertTrue(log4jLogger.isWarnEnabled());
|
||||
assertTrue(log4jLogger.isErrorEnabled());
|
||||
}
|
||||
|
||||
public void testPrintAPI() {
|
||||
Exception e = new Exception("just testing");
|
||||
|
||||
log4jLogger.trace(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug("debug message");
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.info(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.info("info message");
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.warn(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.warn("warn message");
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.error(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.error("error message");
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug(null, e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug("debug message", e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.info(null, e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.info("info message", e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.warn(null, e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.warn("warn message", e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.error(null, e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.error("error message", e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
}
|
||||
|
||||
public void testLogAPI() {
|
||||
log4jLogger.log("x", Level.TRACE, "x", null);
|
||||
assertEquals(0, appender.list.size());
|
||||
|
||||
log4jLogger.log("x", Level.DEBUG, "x", null);
|
||||
log4jLogger.log("x", Level.INFO, "x", null);
|
||||
log4jLogger.log("x", Level.WARN, "x", null);
|
||||
log4jLogger.log("x", Level.ERROR, "x", null);
|
||||
log4jLogger.log("x", Level.FATAL, "x", null);
|
||||
|
||||
assertEquals(5, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
package test;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ch.qos.logback.classic.LoggerContext;
|
||||
import ch.qos.logback.classic.spi.LoggingEvent;
|
||||
import ch.qos.logback.core.read.ListAppender;
|
||||
import org.apache.log4j.Level;
|
||||
|
||||
/**
|
||||
* A class that tests the invocation of the org.apache.log4j.Logger class that
|
||||
* belongs to the log4j-bridge package
|
||||
*
|
||||
* @author Sébastien Pennec
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
|
||||
public class LoggerTest extends TestCase {
|
||||
|
||||
LoggerContext context;
|
||||
ListAppender<LoggingEvent> appender;
|
||||
ch.qos.logback.classic.Logger logbackLogger;
|
||||
org.apache.log4j.Logger log4jLogger;
|
||||
|
||||
public void setUp() throws Exception {
|
||||
context = (LoggerContext) LoggerFactory.getILoggerFactory();
|
||||
context.shutdownAndReset();
|
||||
appender = new ListAppender<LoggingEvent>();
|
||||
appender.setContext(context);
|
||||
appender.setName("listAppender");
|
||||
appender.start();
|
||||
ch.qos.logback.classic.Logger lbLogger = context
|
||||
.getLogger(LoggerContext.ROOT_NAME);
|
||||
lbLogger.addAppender(appender);
|
||||
|
||||
log4jLogger = org.apache.log4j.Logger.getLogger(LoggerTest.class);
|
||||
logbackLogger = context.getLogger(LoggerTest.class);
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
appender.stop();
|
||||
context.stop();
|
||||
appender = null;
|
||||
context = null;
|
||||
logbackLogger = null;
|
||||
log4jLogger = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
public void testLogWithObjectMessages() {
|
||||
LoggingEvent event;
|
||||
|
||||
log4jLogger.debug("test");
|
||||
event = appender.list.get(0);
|
||||
assertEquals("test", event.getMessage());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug(null);
|
||||
event = appender.list.get(0);
|
||||
assertEquals(null, event.getMessage());
|
||||
appender.list.clear();
|
||||
|
||||
DummyObject dummy = new DummyObject();
|
||||
log4jLogger.debug(dummy);
|
||||
event = appender.list.get(0);
|
||||
assertEquals(dummy.toString(), event.getMessage());
|
||||
appender.list.clear();
|
||||
}
|
||||
|
||||
public void testIsEnabledAPI() {
|
||||
assertFalse(log4jLogger.isTraceEnabled());
|
||||
assertTrue(log4jLogger.isDebugEnabled());
|
||||
assertTrue(log4jLogger.isInfoEnabled());
|
||||
assertTrue(log4jLogger.isWarnEnabled());
|
||||
assertTrue(log4jLogger.isErrorEnabled());
|
||||
}
|
||||
|
||||
public void testPrintAPI() {
|
||||
Exception e = new Exception("just testing");
|
||||
|
||||
log4jLogger.trace(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug("debug message");
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.info(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.info("info message");
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.warn(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.warn("warn message");
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.error(null);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.error("error message");
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug(null, e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.debug("debug message", e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.info(null, e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.info("info message", e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.warn(null, e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.warn("warn message", e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.error(null, e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
log4jLogger.error("error message", e);
|
||||
assertEquals(1, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
}
|
||||
|
||||
public void testLogAPI() {
|
||||
log4jLogger.log("x", Level.TRACE, "x", null);
|
||||
assertEquals(0, appender.list.size());
|
||||
|
||||
log4jLogger.log("x", Level.DEBUG, "x", null);
|
||||
log4jLogger.log("x", Level.INFO, "x", null);
|
||||
log4jLogger.log("x", Level.WARN, "x", null);
|
||||
log4jLogger.log("x", Level.ERROR, "x", null);
|
||||
log4jLogger.log("x", Level.FATAL, "x", null);
|
||||
|
||||
assertEquals(5, appender.list.size());
|
||||
appender.list.clear();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,68 +1,68 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>log4j-over-slf4j</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Log4j Implemented Over SLF4J</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
|
||||
<description>
|
||||
<!--
|
||||
Never _never_ let Eclipse's auto format function add
|
||||
a line return in the description.
|
||||
The generated jar will contain a corrupt MANIFEST file.
|
||||
-->
|
||||
Log4j implemented over SLF4J
|
||||
</description>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache Software Licenses</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
|
||||
<Bundle-Description>${project.description}</Bundle-Description>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
</manifestEntries>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>log4j-over-slf4j</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Log4j Implemented Over SLF4J</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
|
||||
<description>
|
||||
<!--
|
||||
Never _never_ let Eclipse's auto format function add
|
||||
a line return in the description.
|
||||
The generated jar will contain a corrupt MANIFEST file.
|
||||
-->
|
||||
Log4j implemented over SLF4J
|
||||
</description>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache Software Licenses</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
|
||||
<Bundle-Description>${project.description}</Bundle-Description>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
</manifestEntries>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,335 +1,335 @@
|
|||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.log4j;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Marker;
|
||||
import org.slf4j.MarkerFactory;
|
||||
import org.slf4j.spi.LocationAwareLogger;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This class is a minimal implementation of the original
|
||||
* <code>org.apache.log4j.Category</code> class (as found in log4j 1.2) by
|
||||
* delegation of all calls to a {@link org.slf4j.Logger} instance.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Log4j's <code>trace</code>, <code>debug()</code>, <code>info()</code>,
|
||||
* <code>warn()</code>, <code>error()</code> printing methods are directly
|
||||
* mapped to their SLF4J equivalents. Log4j's <code>fatal()</code> printing
|
||||
* method is mapped to SLF4J's <code>error()</code> method with a FATAL
|
||||
* marker.
|
||||
*
|
||||
* @author Sébastien Pennec
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class Category {
|
||||
|
||||
private static final String CATEGORY_FQCN = Category.class.getName();
|
||||
|
||||
private String name;
|
||||
|
||||
protected org.slf4j.Logger slf4jLogger;
|
||||
private org.slf4j.spi.LocationAwareLogger locationAwareLogger;
|
||||
|
||||
private static Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL");
|
||||
|
||||
Category(String name) {
|
||||
this.name = name;
|
||||
slf4jLogger = LoggerFactory.getLogger(name);
|
||||
if (slf4jLogger instanceof LocationAwareLogger) {
|
||||
locationAwareLogger = (LocationAwareLogger) slf4jLogger;
|
||||
}
|
||||
}
|
||||
|
||||
public static Category getInstance(Class clazz) {
|
||||
return Log4jLoggerFactory.getLogger(clazz.getName());
|
||||
}
|
||||
|
||||
public static Category getInstance(String name) {
|
||||
return Log4jLoggerFactory.getLogger(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the obvious.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the level in effect for this category/logger.
|
||||
*
|
||||
* <p>
|
||||
* The result is computed by simulation.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Level getEffectiveLevel() {
|
||||
if (slf4jLogger.isTraceEnabled()) {
|
||||
return Level.TRACE;
|
||||
}
|
||||
if (slf4jLogger.isDebugEnabled()) {
|
||||
return Level.DEBUG;
|
||||
}
|
||||
if (slf4jLogger.isInfoEnabled()) {
|
||||
return Level.INFO;
|
||||
}
|
||||
if (slf4jLogger.isWarnEnabled()) {
|
||||
return Level.WARN;
|
||||
}
|
||||
return Level.ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the assigned {@link Level}, if any, for this Category. This
|
||||
* implementation always returns null.
|
||||
*
|
||||
* @return Level - the assigned Level, can be <code>null</code>.
|
||||
*/
|
||||
final public Level getLevel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link #getLevel} instead.
|
||||
*/
|
||||
final public Level getPriority() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#isDebugEnabled} method in SLF4J
|
||||
*/
|
||||
public boolean isDebugEnabled() {
|
||||
return slf4jLogger.isDebugEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#isInfoEnabled} method in SLF4J
|
||||
*/
|
||||
public boolean isInfoEnabled() {
|
||||
return slf4jLogger.isInfoEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates tob {@link org.slf4j.Logger#isWarnEnabled} method in SLF4J
|
||||
*/
|
||||
public boolean isWarnEnabled() {
|
||||
return slf4jLogger.isWarnEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#isErrorEnabled} method in SLF4J
|
||||
*/
|
||||
public boolean isErrorEnabled() {
|
||||
return slf4jLogger.isErrorEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the priority passed as parameter is enabled in the
|
||||
* underlying SLF4J logger. Each log4j priority is mapped directly to its
|
||||
* SLF4J equivalent, except for FATAL which is mapped as ERROR.
|
||||
*
|
||||
* @param p
|
||||
* the priority to check against
|
||||
* @return true if this logger is enabled for the given level, false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isEnabledFor(Priority p) {
|
||||
switch (p.level) {
|
||||
case Level.TRACE_INT:
|
||||
return slf4jLogger.isTraceEnabled();
|
||||
case Level.DEBUG_INT:
|
||||
return slf4jLogger.isDebugEnabled();
|
||||
case Level.INFO_INT:
|
||||
return slf4jLogger.isInfoEnabled();
|
||||
case Level.WARN_INT:
|
||||
return slf4jLogger.isWarnEnabled();
|
||||
case Level.ERROR_INT:
|
||||
return slf4jLogger.isErrorEnabled();
|
||||
case Priority.FATAL_INT:
|
||||
return slf4jLogger.isErrorEnabled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void differentiatedLog(Marker marker, String fqcn, int level, Object message,
|
||||
Throwable t) {
|
||||
String m = convertToString(message);
|
||||
if (locationAwareLogger != null) {
|
||||
locationAwareLogger.log(marker, fqcn, level, m, t);
|
||||
} else {
|
||||
switch (level) {
|
||||
case LocationAwareLogger.TRACE_INT:
|
||||
slf4jLogger.trace(marker, m);
|
||||
break;
|
||||
case LocationAwareLogger.DEBUG_INT:
|
||||
slf4jLogger.debug(marker, m);
|
||||
break;
|
||||
case LocationAwareLogger.INFO_INT:
|
||||
slf4jLogger.info(marker, m);
|
||||
break;
|
||||
case LocationAwareLogger.WARN_INT:
|
||||
slf4jLogger.warn(marker, m);
|
||||
break;
|
||||
case LocationAwareLogger.ERROR_INT:
|
||||
slf4jLogger.error(marker, m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#debug(String)} method of SLF4J.
|
||||
*/
|
||||
public void debug(Object message) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT,
|
||||
message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#debug(String,Throwable)} method in
|
||||
* SLF4J.
|
||||
*/
|
||||
public void debug(Object message, Throwable t) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT,
|
||||
message, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#info(String)} method in SLF4J.
|
||||
*/
|
||||
public void info(Object message) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT,
|
||||
message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#info(String,Throwable)} method in
|
||||
* SLF4J.
|
||||
*/
|
||||
public void info(Object message, Throwable t) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT,
|
||||
message, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#warn(String)} method in SLF4J.
|
||||
*/
|
||||
public void warn(Object message) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT,
|
||||
message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#warn(String,Throwable)} method in
|
||||
* SLF4J.
|
||||
*/
|
||||
public void warn(Object message, Throwable t) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT,
|
||||
message, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#error(String)} method in SLF4J.
|
||||
*/
|
||||
public void error(Object message) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT,
|
||||
message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#error(String,Throwable)} method in
|
||||
* SLF4J.
|
||||
*/
|
||||
public void error(Object message, Throwable t) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT,
|
||||
message, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#error(String)} method in SLF4J.
|
||||
*/
|
||||
public void fatal(Object message) {
|
||||
differentiatedLog(FATAL_MARKER, CATEGORY_FQCN,
|
||||
LocationAwareLogger.ERROR_INT, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#error(String,Throwable)} method in
|
||||
* SLF4J. In addition, the call is marked with a marker named "FATAL".
|
||||
*/
|
||||
public void fatal(Object message, Throwable t) {
|
||||
differentiatedLog(FATAL_MARKER, CATEGORY_FQCN,
|
||||
LocationAwareLogger.ERROR_INT, message, t);
|
||||
}
|
||||
|
||||
|
||||
public void log(String FQCN, Priority p, Object msg, Throwable t) {
|
||||
int levelInt = priorityToLevelInt(p);
|
||||
if (locationAwareLogger != null) {
|
||||
locationAwareLogger.log(null, FQCN, levelInt, convertToString(msg), t);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("The logger [" + slf4jLogger
|
||||
+ "] does not seem to be location aware.");
|
||||
}
|
||||
}
|
||||
|
||||
public void log(Priority p, Object message, Throwable t) {
|
||||
int levelInt = priorityToLevelInt(p);
|
||||
differentiatedLog(null, CATEGORY_FQCN, levelInt,
|
||||
message, t);
|
||||
}
|
||||
|
||||
public void log(Priority p, Object message) {
|
||||
int levelInt = priorityToLevelInt(p);
|
||||
differentiatedLog(null, CATEGORY_FQCN, levelInt,
|
||||
message, null);
|
||||
}
|
||||
|
||||
|
||||
private int priorityToLevelInt(Priority p) {
|
||||
switch (p.level) {
|
||||
case Level.TRACE_INT:
|
||||
return LocationAwareLogger.TRACE_INT;
|
||||
case Priority.DEBUG_INT:
|
||||
return LocationAwareLogger.DEBUG_INT;
|
||||
case Priority.INFO_INT:
|
||||
return LocationAwareLogger.INFO_INT;
|
||||
case Priority.WARN_INT:
|
||||
return LocationAwareLogger.WARN_INT;
|
||||
case Priority.ERROR_INT:
|
||||
return LocationAwareLogger.ERROR_INT;
|
||||
case Priority.FATAL_INT:
|
||||
return LocationAwareLogger.ERROR_INT;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown Priority " + p);
|
||||
}
|
||||
}
|
||||
|
||||
protected final String convertToString(Object message) {
|
||||
if (message == null) {
|
||||
return (String) message;
|
||||
} else {
|
||||
return message.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.log4j;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.slf4j.Marker;
|
||||
import org.slf4j.MarkerFactory;
|
||||
import org.slf4j.spi.LocationAwareLogger;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This class is a minimal implementation of the original
|
||||
* <code>org.apache.log4j.Category</code> class (as found in log4j 1.2) by
|
||||
* delegation of all calls to a {@link org.slf4j.Logger} instance.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Log4j's <code>trace</code>, <code>debug()</code>, <code>info()</code>,
|
||||
* <code>warn()</code>, <code>error()</code> printing methods are directly
|
||||
* mapped to their SLF4J equivalents. Log4j's <code>fatal()</code> printing
|
||||
* method is mapped to SLF4J's <code>error()</code> method with a FATAL
|
||||
* marker.
|
||||
*
|
||||
* @author Sébastien Pennec
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class Category {
|
||||
|
||||
private static final String CATEGORY_FQCN = Category.class.getName();
|
||||
|
||||
private String name;
|
||||
|
||||
protected org.slf4j.Logger slf4jLogger;
|
||||
private org.slf4j.spi.LocationAwareLogger locationAwareLogger;
|
||||
|
||||
private static Marker FATAL_MARKER = MarkerFactory.getMarker("FATAL");
|
||||
|
||||
Category(String name) {
|
||||
this.name = name;
|
||||
slf4jLogger = LoggerFactory.getLogger(name);
|
||||
if (slf4jLogger instanceof LocationAwareLogger) {
|
||||
locationAwareLogger = (LocationAwareLogger) slf4jLogger;
|
||||
}
|
||||
}
|
||||
|
||||
public static Category getInstance(Class clazz) {
|
||||
return Log4jLoggerFactory.getLogger(clazz.getName());
|
||||
}
|
||||
|
||||
public static Category getInstance(String name) {
|
||||
return Log4jLoggerFactory.getLogger(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the obvious.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the level in effect for this category/logger.
|
||||
*
|
||||
* <p>
|
||||
* The result is computed by simulation.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Level getEffectiveLevel() {
|
||||
if (slf4jLogger.isTraceEnabled()) {
|
||||
return Level.TRACE;
|
||||
}
|
||||
if (slf4jLogger.isDebugEnabled()) {
|
||||
return Level.DEBUG;
|
||||
}
|
||||
if (slf4jLogger.isInfoEnabled()) {
|
||||
return Level.INFO;
|
||||
}
|
||||
if (slf4jLogger.isWarnEnabled()) {
|
||||
return Level.WARN;
|
||||
}
|
||||
return Level.ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the assigned {@link Level}, if any, for this Category. This
|
||||
* implementation always returns null.
|
||||
*
|
||||
* @return Level - the assigned Level, can be <code>null</code>.
|
||||
*/
|
||||
final public Level getLevel() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link #getLevel} instead.
|
||||
*/
|
||||
final public Level getPriority() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#isDebugEnabled} method in SLF4J
|
||||
*/
|
||||
public boolean isDebugEnabled() {
|
||||
return slf4jLogger.isDebugEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#isInfoEnabled} method in SLF4J
|
||||
*/
|
||||
public boolean isInfoEnabled() {
|
||||
return slf4jLogger.isInfoEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates tob {@link org.slf4j.Logger#isWarnEnabled} method in SLF4J
|
||||
*/
|
||||
public boolean isWarnEnabled() {
|
||||
return slf4jLogger.isWarnEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#isErrorEnabled} method in SLF4J
|
||||
*/
|
||||
public boolean isErrorEnabled() {
|
||||
return slf4jLogger.isErrorEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the priority passed as parameter is enabled in the
|
||||
* underlying SLF4J logger. Each log4j priority is mapped directly to its
|
||||
* SLF4J equivalent, except for FATAL which is mapped as ERROR.
|
||||
*
|
||||
* @param p
|
||||
* the priority to check against
|
||||
* @return true if this logger is enabled for the given level, false
|
||||
* otherwise.
|
||||
*/
|
||||
public boolean isEnabledFor(Priority p) {
|
||||
switch (p.level) {
|
||||
case Level.TRACE_INT:
|
||||
return slf4jLogger.isTraceEnabled();
|
||||
case Level.DEBUG_INT:
|
||||
return slf4jLogger.isDebugEnabled();
|
||||
case Level.INFO_INT:
|
||||
return slf4jLogger.isInfoEnabled();
|
||||
case Level.WARN_INT:
|
||||
return slf4jLogger.isWarnEnabled();
|
||||
case Level.ERROR_INT:
|
||||
return slf4jLogger.isErrorEnabled();
|
||||
case Priority.FATAL_INT:
|
||||
return slf4jLogger.isErrorEnabled();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void differentiatedLog(Marker marker, String fqcn, int level, Object message,
|
||||
Throwable t) {
|
||||
String m = convertToString(message);
|
||||
if (locationAwareLogger != null) {
|
||||
locationAwareLogger.log(marker, fqcn, level, m, t);
|
||||
} else {
|
||||
switch (level) {
|
||||
case LocationAwareLogger.TRACE_INT:
|
||||
slf4jLogger.trace(marker, m);
|
||||
break;
|
||||
case LocationAwareLogger.DEBUG_INT:
|
||||
slf4jLogger.debug(marker, m);
|
||||
break;
|
||||
case LocationAwareLogger.INFO_INT:
|
||||
slf4jLogger.info(marker, m);
|
||||
break;
|
||||
case LocationAwareLogger.WARN_INT:
|
||||
slf4jLogger.warn(marker, m);
|
||||
break;
|
||||
case LocationAwareLogger.ERROR_INT:
|
||||
slf4jLogger.error(marker, m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#debug(String)} method of SLF4J.
|
||||
*/
|
||||
public void debug(Object message) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT,
|
||||
message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#debug(String,Throwable)} method in
|
||||
* SLF4J.
|
||||
*/
|
||||
public void debug(Object message, Throwable t) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.DEBUG_INT,
|
||||
message, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#info(String)} method in SLF4J.
|
||||
*/
|
||||
public void info(Object message) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT,
|
||||
message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#info(String,Throwable)} method in
|
||||
* SLF4J.
|
||||
*/
|
||||
public void info(Object message, Throwable t) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.INFO_INT,
|
||||
message, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#warn(String)} method in SLF4J.
|
||||
*/
|
||||
public void warn(Object message) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT,
|
||||
message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#warn(String,Throwable)} method in
|
||||
* SLF4J.
|
||||
*/
|
||||
public void warn(Object message, Throwable t) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.WARN_INT,
|
||||
message, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#error(String)} method in SLF4J.
|
||||
*/
|
||||
public void error(Object message) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT,
|
||||
message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#error(String,Throwable)} method in
|
||||
* SLF4J.
|
||||
*/
|
||||
public void error(Object message, Throwable t) {
|
||||
differentiatedLog(null, CATEGORY_FQCN, LocationAwareLogger.ERROR_INT,
|
||||
message, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#error(String)} method in SLF4J.
|
||||
*/
|
||||
public void fatal(Object message) {
|
||||
differentiatedLog(FATAL_MARKER, CATEGORY_FQCN,
|
||||
LocationAwareLogger.ERROR_INT, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#error(String,Throwable)} method in
|
||||
* SLF4J. In addition, the call is marked with a marker named "FATAL".
|
||||
*/
|
||||
public void fatal(Object message, Throwable t) {
|
||||
differentiatedLog(FATAL_MARKER, CATEGORY_FQCN,
|
||||
LocationAwareLogger.ERROR_INT, message, t);
|
||||
}
|
||||
|
||||
|
||||
public void log(String FQCN, Priority p, Object msg, Throwable t) {
|
||||
int levelInt = priorityToLevelInt(p);
|
||||
if (locationAwareLogger != null) {
|
||||
locationAwareLogger.log(null, FQCN, levelInt, convertToString(msg), t);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("The logger [" + slf4jLogger
|
||||
+ "] does not seem to be location aware.");
|
||||
}
|
||||
}
|
||||
|
||||
public void log(Priority p, Object message, Throwable t) {
|
||||
int levelInt = priorityToLevelInt(p);
|
||||
differentiatedLog(null, CATEGORY_FQCN, levelInt,
|
||||
message, t);
|
||||
}
|
||||
|
||||
public void log(Priority p, Object message) {
|
||||
int levelInt = priorityToLevelInt(p);
|
||||
differentiatedLog(null, CATEGORY_FQCN, levelInt,
|
||||
message, null);
|
||||
}
|
||||
|
||||
|
||||
private int priorityToLevelInt(Priority p) {
|
||||
switch (p.level) {
|
||||
case Level.TRACE_INT:
|
||||
return LocationAwareLogger.TRACE_INT;
|
||||
case Priority.DEBUG_INT:
|
||||
return LocationAwareLogger.DEBUG_INT;
|
||||
case Priority.INFO_INT:
|
||||
return LocationAwareLogger.INFO_INT;
|
||||
case Priority.WARN_INT:
|
||||
return LocationAwareLogger.WARN_INT;
|
||||
case Priority.ERROR_INT:
|
||||
return LocationAwareLogger.ERROR_INT;
|
||||
case Priority.FATAL_INT:
|
||||
return LocationAwareLogger.ERROR_INT;
|
||||
default:
|
||||
throw new IllegalStateException("Unknown Priority " + p);
|
||||
}
|
||||
}
|
||||
|
||||
protected final String convertToString(Object message) {
|
||||
if (message == null) {
|
||||
return (String) message;
|
||||
} else {
|
||||
return message.toString();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,218 +1,218 @@
|
|||
/*
|
||||
* Copyright 1999-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Contributors: Kitching Simon <Simon.Kitching@orange.ch>
|
||||
// Nicholas Wolff
|
||||
|
||||
package org.apache.log4j;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
Defines the minimum set of levels recognized by the system, that is
|
||||
<code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
|
||||
<code>WARN</code>, <code>INFO</code>, <code>DEBUG</code> and
|
||||
<code>ALL</code>.
|
||||
|
||||
<p>The <code>Level</code> class may be subclassed to define a larger
|
||||
level set.
|
||||
|
||||
@author Ceki Gülcü
|
||||
|
||||
*/
|
||||
public class Level extends Priority implements Serializable {
|
||||
|
||||
/**
|
||||
* TRACE level integer value.
|
||||
* @since 1.2.12
|
||||
*/
|
||||
public static final int TRACE_INT = 5000;
|
||||
|
||||
/**
|
||||
The <code>OFF</code> has the highest possible rank and is
|
||||
intended to turn off logging. */
|
||||
final static public Level OFF = new Level(OFF_INT, "OFF", 0);
|
||||
|
||||
/**
|
||||
The <code>FATAL</code> level designates very severe error
|
||||
events that will presumably lead the application to abort.
|
||||
*/
|
||||
final static public Level FATAL = new Level(FATAL_INT, "FATAL", 0);
|
||||
|
||||
/**
|
||||
The <code>ERROR</code> level designates error events that
|
||||
might still allow the application to continue running. */
|
||||
final static public Level ERROR = new Level(ERROR_INT, "ERROR", 3);
|
||||
|
||||
/**
|
||||
The <code>WARN</code> level designates potentially harmful situations.
|
||||
*/
|
||||
final static public Level WARN = new Level(WARN_INT, "WARN", 4);
|
||||
|
||||
/**
|
||||
The <code>INFO</code> level designates informational messages
|
||||
that highlight the progress of the application at coarse-grained
|
||||
level. */
|
||||
final static public Level INFO = new Level(INFO_INT, "INFO", 6);
|
||||
|
||||
/**
|
||||
The <code>DEBUG</code> Level designates fine-grained
|
||||
informational events that are most useful to debug an
|
||||
application. */
|
||||
final static public Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
|
||||
|
||||
/**
|
||||
* The <code>TRACE</code> Level designates finer-grained
|
||||
* informational events than the <code>DEBUG</code level.
|
||||
* @since 1.2.12
|
||||
*/
|
||||
public static final Level TRACE = new Level(TRACE_INT, "TRACE", 7);
|
||||
|
||||
|
||||
/**
|
||||
The <code>ALL</code> has the lowest possible rank and is intended to
|
||||
turn on all logging. */
|
||||
final static public Level ALL = new Level(ALL_INT, "ALL", 7);
|
||||
|
||||
/**
|
||||
* Serialization version id.
|
||||
*/
|
||||
static final long serialVersionUID = 3491141966387921974L;
|
||||
|
||||
/**
|
||||
Instantiate a Level object.
|
||||
*/
|
||||
protected
|
||||
Level(int level, String levelStr, int syslogEquivalent) {
|
||||
super(level, levelStr, syslogEquivalent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert the string passed as argument to a level. If the
|
||||
conversion fails, then this method returns {@link #DEBUG}.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Level toLevel(String sArg) {
|
||||
return (Level) toLevel(sArg, Level.DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
Convert an integer passed as argument to a level. If the
|
||||
conversion fails, then this method returns {@link #DEBUG}.
|
||||
|
||||
*/
|
||||
public
|
||||
static
|
||||
Level toLevel(int val) {
|
||||
return (Level) toLevel(val, Level.DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
Convert an integer passed as argument to a level. If the
|
||||
conversion fails, then this method returns the specified default.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Level toLevel(int val, Level defaultLevel) {
|
||||
switch(val) {
|
||||
case ALL_INT: return ALL;
|
||||
case DEBUG_INT: return Level.DEBUG;
|
||||
case INFO_INT: return Level.INFO;
|
||||
case WARN_INT: return Level.WARN;
|
||||
case ERROR_INT: return Level.ERROR;
|
||||
case FATAL_INT: return Level.FATAL;
|
||||
case OFF_INT: return OFF;
|
||||
case TRACE_INT: return Level.TRACE;
|
||||
default: return defaultLevel;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Convert the string passed as argument to a level. If the
|
||||
conversion fails, then this method returns the value of
|
||||
<code>defaultLevel</code>.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Level toLevel(String sArg, Level defaultLevel) {
|
||||
if(sArg == null)
|
||||
return defaultLevel;
|
||||
|
||||
String s = sArg.toUpperCase();
|
||||
|
||||
if(s.equals("ALL")) return Level.ALL;
|
||||
if(s.equals("DEBUG")) return Level.DEBUG;
|
||||
if(s.equals("INFO")) return Level.INFO;
|
||||
if(s.equals("WARN")) return Level.WARN;
|
||||
if(s.equals("ERROR")) return Level.ERROR;
|
||||
if(s.equals("FATAL")) return Level.FATAL;
|
||||
if(s.equals("OFF")) return Level.OFF;
|
||||
if(s.equals("TRACE")) return Level.TRACE;
|
||||
return defaultLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom deserialization of Level.
|
||||
* @param s serialization stream.
|
||||
* @throws IOException if IO exception.
|
||||
* @throws ClassNotFoundException if class not found.
|
||||
*/
|
||||
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
|
||||
s.defaultReadObject();
|
||||
level = s.readInt();
|
||||
syslogEquivalent = s.readInt();
|
||||
levelStr = s.readUTF();
|
||||
if (levelStr == null) {
|
||||
levelStr = "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize level.
|
||||
* @param s serialization stream.
|
||||
* @throws IOException if exception during serialization.
|
||||
*/
|
||||
private void writeObject(final ObjectOutputStream s) throws IOException {
|
||||
s.defaultWriteObject();
|
||||
s.writeInt(level);
|
||||
s.writeInt(syslogEquivalent);
|
||||
s.writeUTF(levelStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolved deserialized level to one of the stock instances.
|
||||
* May be overriden in classes derived from Level.
|
||||
* @return resolved object.
|
||||
* @throws ObjectStreamException if exception during resolution.
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
//
|
||||
// if the deserizalized object is exactly an instance of Level
|
||||
//
|
||||
if (getClass() == Level.class) {
|
||||
return toLevel(level);
|
||||
}
|
||||
//
|
||||
// extension of Level can't substitute stock item
|
||||
//
|
||||
return this;
|
||||
}
|
||||
/*
|
||||
* Copyright 1999-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Contributors: Kitching Simon <Simon.Kitching@orange.ch>
|
||||
// Nicholas Wolff
|
||||
|
||||
package org.apache.log4j;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
Defines the minimum set of levels recognized by the system, that is
|
||||
<code>OFF</code>, <code>FATAL</code>, <code>ERROR</code>,
|
||||
<code>WARN</code>, <code>INFO</code>, <code>DEBUG</code> and
|
||||
<code>ALL</code>.
|
||||
|
||||
<p>The <code>Level</code> class may be subclassed to define a larger
|
||||
level set.
|
||||
|
||||
@author Ceki Gülcü
|
||||
|
||||
*/
|
||||
public class Level extends Priority implements Serializable {
|
||||
|
||||
/**
|
||||
* TRACE level integer value.
|
||||
* @since 1.2.12
|
||||
*/
|
||||
public static final int TRACE_INT = 5000;
|
||||
|
||||
/**
|
||||
The <code>OFF</code> has the highest possible rank and is
|
||||
intended to turn off logging. */
|
||||
final static public Level OFF = new Level(OFF_INT, "OFF", 0);
|
||||
|
||||
/**
|
||||
The <code>FATAL</code> level designates very severe error
|
||||
events that will presumably lead the application to abort.
|
||||
*/
|
||||
final static public Level FATAL = new Level(FATAL_INT, "FATAL", 0);
|
||||
|
||||
/**
|
||||
The <code>ERROR</code> level designates error events that
|
||||
might still allow the application to continue running. */
|
||||
final static public Level ERROR = new Level(ERROR_INT, "ERROR", 3);
|
||||
|
||||
/**
|
||||
The <code>WARN</code> level designates potentially harmful situations.
|
||||
*/
|
||||
final static public Level WARN = new Level(WARN_INT, "WARN", 4);
|
||||
|
||||
/**
|
||||
The <code>INFO</code> level designates informational messages
|
||||
that highlight the progress of the application at coarse-grained
|
||||
level. */
|
||||
final static public Level INFO = new Level(INFO_INT, "INFO", 6);
|
||||
|
||||
/**
|
||||
The <code>DEBUG</code> Level designates fine-grained
|
||||
informational events that are most useful to debug an
|
||||
application. */
|
||||
final static public Level DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
|
||||
|
||||
/**
|
||||
* The <code>TRACE</code> Level designates finer-grained
|
||||
* informational events than the <code>DEBUG</code level.
|
||||
* @since 1.2.12
|
||||
*/
|
||||
public static final Level TRACE = new Level(TRACE_INT, "TRACE", 7);
|
||||
|
||||
|
||||
/**
|
||||
The <code>ALL</code> has the lowest possible rank and is intended to
|
||||
turn on all logging. */
|
||||
final static public Level ALL = new Level(ALL_INT, "ALL", 7);
|
||||
|
||||
/**
|
||||
* Serialization version id.
|
||||
*/
|
||||
static final long serialVersionUID = 3491141966387921974L;
|
||||
|
||||
/**
|
||||
Instantiate a Level object.
|
||||
*/
|
||||
protected
|
||||
Level(int level, String levelStr, int syslogEquivalent) {
|
||||
super(level, levelStr, syslogEquivalent);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Convert the string passed as argument to a level. If the
|
||||
conversion fails, then this method returns {@link #DEBUG}.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Level toLevel(String sArg) {
|
||||
return (Level) toLevel(sArg, Level.DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
Convert an integer passed as argument to a level. If the
|
||||
conversion fails, then this method returns {@link #DEBUG}.
|
||||
|
||||
*/
|
||||
public
|
||||
static
|
||||
Level toLevel(int val) {
|
||||
return (Level) toLevel(val, Level.DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
Convert an integer passed as argument to a level. If the
|
||||
conversion fails, then this method returns the specified default.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Level toLevel(int val, Level defaultLevel) {
|
||||
switch(val) {
|
||||
case ALL_INT: return ALL;
|
||||
case DEBUG_INT: return Level.DEBUG;
|
||||
case INFO_INT: return Level.INFO;
|
||||
case WARN_INT: return Level.WARN;
|
||||
case ERROR_INT: return Level.ERROR;
|
||||
case FATAL_INT: return Level.FATAL;
|
||||
case OFF_INT: return OFF;
|
||||
case TRACE_INT: return Level.TRACE;
|
||||
default: return defaultLevel;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Convert the string passed as argument to a level. If the
|
||||
conversion fails, then this method returns the value of
|
||||
<code>defaultLevel</code>.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Level toLevel(String sArg, Level defaultLevel) {
|
||||
if(sArg == null)
|
||||
return defaultLevel;
|
||||
|
||||
String s = sArg.toUpperCase();
|
||||
|
||||
if(s.equals("ALL")) return Level.ALL;
|
||||
if(s.equals("DEBUG")) return Level.DEBUG;
|
||||
if(s.equals("INFO")) return Level.INFO;
|
||||
if(s.equals("WARN")) return Level.WARN;
|
||||
if(s.equals("ERROR")) return Level.ERROR;
|
||||
if(s.equals("FATAL")) return Level.FATAL;
|
||||
if(s.equals("OFF")) return Level.OFF;
|
||||
if(s.equals("TRACE")) return Level.TRACE;
|
||||
return defaultLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom deserialization of Level.
|
||||
* @param s serialization stream.
|
||||
* @throws IOException if IO exception.
|
||||
* @throws ClassNotFoundException if class not found.
|
||||
*/
|
||||
private void readObject(final ObjectInputStream s) throws IOException, ClassNotFoundException {
|
||||
s.defaultReadObject();
|
||||
level = s.readInt();
|
||||
syslogEquivalent = s.readInt();
|
||||
levelStr = s.readUTF();
|
||||
if (levelStr == null) {
|
||||
levelStr = "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize level.
|
||||
* @param s serialization stream.
|
||||
* @throws IOException if exception during serialization.
|
||||
*/
|
||||
private void writeObject(final ObjectOutputStream s) throws IOException {
|
||||
s.defaultWriteObject();
|
||||
s.writeInt(level);
|
||||
s.writeInt(syslogEquivalent);
|
||||
s.writeUTF(levelStr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolved deserialized level to one of the stock instances.
|
||||
* May be overriden in classes derived from Level.
|
||||
* @return resolved object.
|
||||
* @throws ObjectStreamException if exception during resolution.
|
||||
*/
|
||||
private Object readResolve() throws ObjectStreamException {
|
||||
//
|
||||
// if the deserizalized object is exactly an instance of Level
|
||||
//
|
||||
if (getClass() == Level.class) {
|
||||
return toLevel(level);
|
||||
}
|
||||
//
|
||||
// extension of Level can't substitute stock item
|
||||
//
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,46 +1,46 @@
|
|||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.log4j;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* This class is a factory that creates and maintains org.apache.log4j.Loggers
|
||||
* wrapping org.slf4j.Loggers.
|
||||
*
|
||||
* It keeps a hashtable of all created org.apache.log4j.Logger instances so that
|
||||
* all newly created instances are not dulpicates of existing loggers.
|
||||
*
|
||||
* @author Sébastien Pennec
|
||||
*/
|
||||
class Log4jLoggerFactory {
|
||||
|
||||
// String, Logger
|
||||
private static Hashtable log4jLoggers = new Hashtable();
|
||||
|
||||
public static synchronized Logger getLogger(String name) {
|
||||
if (log4jLoggers.containsKey(name)) {
|
||||
return (org.apache.log4j.Logger) log4jLoggers.get(name);
|
||||
} else {
|
||||
Logger log4jLogger = new Logger(name);
|
||||
|
||||
log4jLoggers.put(name, log4jLogger);
|
||||
return log4jLogger;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.log4j;
|
||||
|
||||
import java.util.Hashtable;
|
||||
|
||||
/**
|
||||
* This class is a factory that creates and maintains org.apache.log4j.Loggers
|
||||
* wrapping org.slf4j.Loggers.
|
||||
*
|
||||
* It keeps a hashtable of all created org.apache.log4j.Logger instances so that
|
||||
* all newly created instances are not dulpicates of existing loggers.
|
||||
*
|
||||
* @author Sébastien Pennec
|
||||
*/
|
||||
class Log4jLoggerFactory {
|
||||
|
||||
// String, Logger
|
||||
private static Hashtable log4jLoggers = new Hashtable();
|
||||
|
||||
public static synchronized Logger getLogger(String name) {
|
||||
if (log4jLoggers.containsKey(name)) {
|
||||
return (org.apache.log4j.Logger) log4jLoggers.get(name);
|
||||
} else {
|
||||
Logger log4jLogger = new Logger(name);
|
||||
|
||||
log4jLoggers.put(name, log4jLogger);
|
||||
return log4jLogger;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,45 +1,45 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.log4j;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This class is a minimal implementation of the original
|
||||
* <code>org.apache.log4j.LogManager</code> class (as found in log4j 1.2)
|
||||
* delegating all calls to SLF4J.
|
||||
*
|
||||
* <p>
|
||||
* This implementation does <b>NOT</b> implement the setRepositorySelector(),
|
||||
* getLoggerRepository(), exists(), getCurrentLoggers(), shutdown() and
|
||||
* resetConfiguration() methods which do not have SLF4J equivalents.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* */
|
||||
public class LogManager {
|
||||
|
||||
public static Logger getRootLogger() {
|
||||
return Log4jLoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
|
||||
}
|
||||
|
||||
public static Logger getLogger(final String name) {
|
||||
return Log4jLoggerFactory.getLogger(name);
|
||||
}
|
||||
|
||||
public static Logger getLogger(final Class clazz) {
|
||||
return Log4jLoggerFactory.getLogger(clazz.getName());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.log4j;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This class is a minimal implementation of the original
|
||||
* <code>org.apache.log4j.LogManager</code> class (as found in log4j 1.2)
|
||||
* delegating all calls to SLF4J.
|
||||
*
|
||||
* <p>
|
||||
* This implementation does <b>NOT</b> implement the setRepositorySelector(),
|
||||
* getLoggerRepository(), exists(), getCurrentLoggers(), shutdown() and
|
||||
* resetConfiguration() methods which do not have SLF4J equivalents.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* */
|
||||
public class LogManager {
|
||||
|
||||
public static Logger getRootLogger() {
|
||||
return Log4jLoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
|
||||
}
|
||||
|
||||
public static Logger getLogger(final String name) {
|
||||
return Log4jLoggerFactory.getLogger(name);
|
||||
}
|
||||
|
||||
public static Logger getLogger(final Class clazz) {
|
||||
return Log4jLoggerFactory.getLogger(clazz.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,79 +1,79 @@
|
|||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.log4j;
|
||||
|
||||
import org.slf4j.spi.LocationAwareLogger;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This class is a minimal implementation of the original
|
||||
* <code>org.apache.log4j.Logger</code> class (as found in log4j 1.2)
|
||||
* delegating all calls to a {@link org.slf4j.Logger} instance.
|
||||
* </p>
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* */
|
||||
public class Logger extends Category {
|
||||
|
||||
private static final String LOGGER_FQCN = Logger.class.getName();
|
||||
|
||||
Logger(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Logger getLogger(String name) {
|
||||
return Log4jLoggerFactory.getLogger(name);
|
||||
}
|
||||
|
||||
public static Logger getLogger(Class clazz) {
|
||||
return getLogger(clazz.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the obvious.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Logger getRootLogger() {
|
||||
return Log4jLoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#isTraceEnabled}
|
||||
* method of SLF4J.
|
||||
*/
|
||||
public boolean isTraceEnabled() {
|
||||
return slf4jLogger.isTraceEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#trace(String)} method in SLF4J.
|
||||
*/
|
||||
public void trace(Object message) {
|
||||
differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#trace(String,Throwable)}
|
||||
* method in SLF4J.
|
||||
*/
|
||||
public void trace(Object message, Throwable t) {
|
||||
differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright 2001-2004 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.log4j;
|
||||
|
||||
import org.slf4j.spi.LocationAwareLogger;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This class is a minimal implementation of the original
|
||||
* <code>org.apache.log4j.Logger</code> class (as found in log4j 1.2)
|
||||
* delegating all calls to a {@link org.slf4j.Logger} instance.
|
||||
* </p>
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* */
|
||||
public class Logger extends Category {
|
||||
|
||||
private static final String LOGGER_FQCN = Logger.class.getName();
|
||||
|
||||
Logger(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public static Logger getLogger(String name) {
|
||||
return Log4jLoggerFactory.getLogger(name);
|
||||
}
|
||||
|
||||
public static Logger getLogger(Class clazz) {
|
||||
return getLogger(clazz.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the obvious.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static Logger getRootLogger() {
|
||||
return Log4jLoggerFactory.getLogger(org.slf4j.Logger.ROOT_LOGGER_NAME);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#isTraceEnabled}
|
||||
* method of SLF4J.
|
||||
*/
|
||||
public boolean isTraceEnabled() {
|
||||
return slf4jLogger.isTraceEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#trace(String)} method in SLF4J.
|
||||
*/
|
||||
public void trace(Object message) {
|
||||
differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delegates to {@link org.slf4j.Logger#trace(String,Throwable)}
|
||||
* method in SLF4J.
|
||||
*/
|
||||
public void trace(Object message, Throwable t) {
|
||||
differentiatedLog(null, LOGGER_FQCN, LocationAwareLogger.TRACE_INT, message, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,28 @@
|
|||
package org.apache.log4j;
|
||||
|
||||
public class MDC {
|
||||
|
||||
public static void put(String key, String value) {
|
||||
org.slf4j.MDC.put(key, value);
|
||||
}
|
||||
|
||||
public static void put(String key, Object value) {
|
||||
if (value != null) {
|
||||
put(key, value.toString());
|
||||
} else {
|
||||
put(key, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object get(String key) {
|
||||
return org.slf4j.MDC.get(key);
|
||||
}
|
||||
|
||||
public static void remove(String key) {
|
||||
org.slf4j.MDC.remove(key);
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
org.slf4j.MDC.clear();
|
||||
}
|
||||
}
|
||||
package org.apache.log4j;
|
||||
|
||||
public class MDC {
|
||||
|
||||
public static void put(String key, String value) {
|
||||
org.slf4j.MDC.put(key, value);
|
||||
}
|
||||
|
||||
public static void put(String key, Object value) {
|
||||
if (value != null) {
|
||||
put(key, value.toString());
|
||||
} else {
|
||||
put(key, null);
|
||||
}
|
||||
}
|
||||
|
||||
public static Object get(String key) {
|
||||
return org.slf4j.MDC.get(key);
|
||||
}
|
||||
|
||||
public static void remove(String key) {
|
||||
org.slf4j.MDC.remove(key);
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
org.slf4j.MDC.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,194 +1,194 @@
|
|||
/*
|
||||
* Copyright 1999-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Contributors: Kitching Simon <Simon.Kitching@orange.ch>
|
||||
|
||||
package org.apache.log4j;
|
||||
|
||||
// Contributors: Kitching Simon <Simon.Kitching@OOOrange.ch>
|
||||
|
||||
/**
|
||||
<font color="#AA4444">Refrain from using this class directly, use
|
||||
the {@link Level} class instead</font>.
|
||||
|
||||
@author Ceki Gülcü */
|
||||
public class Priority {
|
||||
|
||||
transient int level;
|
||||
transient String levelStr;
|
||||
transient int syslogEquivalent;
|
||||
|
||||
public final static int OFF_INT = Integer.MAX_VALUE;
|
||||
public final static int FATAL_INT = 50000;
|
||||
public final static int ERROR_INT = 40000;
|
||||
public final static int WARN_INT = 30000;
|
||||
public final static int INFO_INT = 20000;
|
||||
public final static int DEBUG_INT = 10000;
|
||||
//public final static int FINE_INT = DEBUG_INT;
|
||||
public final static int ALL_INT = Integer.MIN_VALUE;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Level#FATAL} instead.
|
||||
*/
|
||||
final static public Priority FATAL = new Level(FATAL_INT, "FATAL", 0);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Level#ERROR} instead.
|
||||
*/
|
||||
final static public Priority ERROR = new Level(ERROR_INT, "ERROR", 3);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Level#WARN} instead.
|
||||
*/
|
||||
final static public Priority WARN = new Level(WARN_INT, "WARN", 4);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Level#INFO} instead.
|
||||
*/
|
||||
final static public Priority INFO = new Level(INFO_INT, "INFO", 6);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Level#DEBUG} instead.
|
||||
*/
|
||||
final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor for deserialization.
|
||||
*/
|
||||
protected Priority() {
|
||||
level = DEBUG_INT;
|
||||
levelStr = "DEBUG";
|
||||
syslogEquivalent = 7;
|
||||
}
|
||||
|
||||
/**
|
||||
Instantiate a level object.
|
||||
*/
|
||||
protected
|
||||
Priority(int level, String levelStr, int syslogEquivalent) {
|
||||
this.level = level;
|
||||
this.levelStr = levelStr;
|
||||
this.syslogEquivalent = syslogEquivalent;
|
||||
}
|
||||
|
||||
/**
|
||||
Two priorities are equal if their level fields are equal.
|
||||
@since 1.2
|
||||
*/
|
||||
public
|
||||
boolean equals(Object o) {
|
||||
if(o instanceof Priority) {
|
||||
Priority r = (Priority) o;
|
||||
return (this.level == r.level);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Return the syslog equivalent of this priority as an integer.
|
||||
*/
|
||||
public
|
||||
final
|
||||
int getSyslogEquivalent() {
|
||||
return syslogEquivalent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Returns <code>true</code> if this level has a higher or equal
|
||||
level than the level passed as argument, <code>false</code>
|
||||
otherwise.
|
||||
|
||||
<p>You should think twice before overriding the default
|
||||
implementation of <code>isGreaterOrEqual</code> method.
|
||||
|
||||
*/
|
||||
public
|
||||
boolean isGreaterOrEqual(Priority r) {
|
||||
return level >= r.level;
|
||||
}
|
||||
|
||||
/**
|
||||
Return all possible priorities as an array of Level objects in
|
||||
descending order.
|
||||
|
||||
@deprecated This method will be removed with no replacement.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Priority[] getAllPossiblePriorities() {
|
||||
return new Priority[] {Priority.FATAL, Priority.ERROR, Level.WARN,
|
||||
Priority.INFO, Priority.DEBUG};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns the string representation of this priority.
|
||||
*/
|
||||
final
|
||||
public
|
||||
String toString() {
|
||||
return levelStr;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the integer representation of this level.
|
||||
*/
|
||||
public
|
||||
final
|
||||
int toInt() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use the {@link Level#toLevel(String)} method instead.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Priority toPriority(String sArg) {
|
||||
return Level.toLevel(sArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use the {@link Level#toLevel(int)} method instead.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Priority toPriority(int val) {
|
||||
return toPriority(val, Priority.DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use the {@link Level#toLevel(int, Level)} method instead.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Priority toPriority(int val, Priority defaultPriority) {
|
||||
return Level.toLevel(val, (Level) defaultPriority);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use the {@link Level#toLevel(String, Level)} method instead.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Priority toPriority(String sArg, Priority defaultPriority) {
|
||||
return Level.toLevel(sArg, (Level) defaultPriority);
|
||||
}
|
||||
/*
|
||||
* Copyright 1999-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Contributors: Kitching Simon <Simon.Kitching@orange.ch>
|
||||
|
||||
package org.apache.log4j;
|
||||
|
||||
// Contributors: Kitching Simon <Simon.Kitching@OOOrange.ch>
|
||||
|
||||
/**
|
||||
<font color="#AA4444">Refrain from using this class directly, use
|
||||
the {@link Level} class instead</font>.
|
||||
|
||||
@author Ceki Gülcü */
|
||||
public class Priority {
|
||||
|
||||
transient int level;
|
||||
transient String levelStr;
|
||||
transient int syslogEquivalent;
|
||||
|
||||
public final static int OFF_INT = Integer.MAX_VALUE;
|
||||
public final static int FATAL_INT = 50000;
|
||||
public final static int ERROR_INT = 40000;
|
||||
public final static int WARN_INT = 30000;
|
||||
public final static int INFO_INT = 20000;
|
||||
public final static int DEBUG_INT = 10000;
|
||||
//public final static int FINE_INT = DEBUG_INT;
|
||||
public final static int ALL_INT = Integer.MIN_VALUE;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Level#FATAL} instead.
|
||||
*/
|
||||
final static public Priority FATAL = new Level(FATAL_INT, "FATAL", 0);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Level#ERROR} instead.
|
||||
*/
|
||||
final static public Priority ERROR = new Level(ERROR_INT, "ERROR", 3);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Level#WARN} instead.
|
||||
*/
|
||||
final static public Priority WARN = new Level(WARN_INT, "WARN", 4);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Level#INFO} instead.
|
||||
*/
|
||||
final static public Priority INFO = new Level(INFO_INT, "INFO", 6);
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link Level#DEBUG} instead.
|
||||
*/
|
||||
final static public Priority DEBUG = new Level(DEBUG_INT, "DEBUG", 7);
|
||||
|
||||
|
||||
/**
|
||||
* Default constructor for deserialization.
|
||||
*/
|
||||
protected Priority() {
|
||||
level = DEBUG_INT;
|
||||
levelStr = "DEBUG";
|
||||
syslogEquivalent = 7;
|
||||
}
|
||||
|
||||
/**
|
||||
Instantiate a level object.
|
||||
*/
|
||||
protected
|
||||
Priority(int level, String levelStr, int syslogEquivalent) {
|
||||
this.level = level;
|
||||
this.levelStr = levelStr;
|
||||
this.syslogEquivalent = syslogEquivalent;
|
||||
}
|
||||
|
||||
/**
|
||||
Two priorities are equal if their level fields are equal.
|
||||
@since 1.2
|
||||
*/
|
||||
public
|
||||
boolean equals(Object o) {
|
||||
if(o instanceof Priority) {
|
||||
Priority r = (Priority) o;
|
||||
return (this.level == r.level);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Return the syslog equivalent of this priority as an integer.
|
||||
*/
|
||||
public
|
||||
final
|
||||
int getSyslogEquivalent() {
|
||||
return syslogEquivalent;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Returns <code>true</code> if this level has a higher or equal
|
||||
level than the level passed as argument, <code>false</code>
|
||||
otherwise.
|
||||
|
||||
<p>You should think twice before overriding the default
|
||||
implementation of <code>isGreaterOrEqual</code> method.
|
||||
|
||||
*/
|
||||
public
|
||||
boolean isGreaterOrEqual(Priority r) {
|
||||
return level >= r.level;
|
||||
}
|
||||
|
||||
/**
|
||||
Return all possible priorities as an array of Level objects in
|
||||
descending order.
|
||||
|
||||
@deprecated This method will be removed with no replacement.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Priority[] getAllPossiblePriorities() {
|
||||
return new Priority[] {Priority.FATAL, Priority.ERROR, Level.WARN,
|
||||
Priority.INFO, Priority.DEBUG};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Returns the string representation of this priority.
|
||||
*/
|
||||
final
|
||||
public
|
||||
String toString() {
|
||||
return levelStr;
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the integer representation of this level.
|
||||
*/
|
||||
public
|
||||
final
|
||||
int toInt() {
|
||||
return level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use the {@link Level#toLevel(String)} method instead.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Priority toPriority(String sArg) {
|
||||
return Level.toLevel(sArg);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use the {@link Level#toLevel(int)} method instead.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Priority toPriority(int val) {
|
||||
return toPriority(val, Priority.DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use the {@link Level#toLevel(int, Level)} method instead.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Priority toPriority(int val, Priority defaultPriority) {
|
||||
return Level.toLevel(val, (Level) defaultPriority);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use the {@link Level#toLevel(String, Level)} method instead.
|
||||
*/
|
||||
public
|
||||
static
|
||||
Priority toPriority(String sArg, Priority defaultPriority) {
|
||||
return Level.toLevel(sArg, (Level) defaultPriority);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<p>An rather minimal but sufficient implementation redirecting all
|
||||
calls to a log4j logger to a logback logger.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<p>An rather minimal but sufficient implementation redirecting all
|
||||
calls to a log4j logger to a logback logger.</p>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
Implementation-Title: log4j-over-slf4j
|
||||
Bundle-SymbolicName: log4j.over.slf4j
|
||||
Bundle-Name: log4j-over-slf4j
|
||||
Bundle-Vendor: SLF4J.ORG
|
||||
Export-Package: org.apache.log4j
|
||||
Import-Package: org.slf4j, org.slf4j.spi
|
||||
Implementation-Title: log4j-over-slf4j
|
||||
Bundle-SymbolicName: log4j.over.slf4j
|
||||
Bundle-Name: log4j-over-slf4j
|
||||
Bundle-Vendor: SLF4J.ORG
|
||||
Export-Package: org.apache.log4j
|
||||
Import-Package: org.slf4j, org.slf4j.spi
|
||||
|
|
|
|||
|
|
@ -1,51 +1,51 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.apache.log4j;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class Trivial extends TestCase {
|
||||
|
||||
public void testSmoke() {
|
||||
Logger l = Logger.getLogger("a");
|
||||
l.trace("t");
|
||||
l.debug("d");
|
||||
l.info("i");
|
||||
l.warn("w");
|
||||
l.error("e");
|
||||
l.fatal("f");
|
||||
|
||||
Exception e = new Exception("testing");
|
||||
l.trace("t", e);
|
||||
l.debug("d", e);
|
||||
l.info("i", e);
|
||||
l.warn("w", e);
|
||||
l.error("e", e);
|
||||
l.fatal("f", e);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.apache.log4j;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class Trivial extends TestCase {
|
||||
|
||||
public void testSmoke() {
|
||||
Logger l = Logger.getLogger("a");
|
||||
l.trace("t");
|
||||
l.debug("d");
|
||||
l.info("i");
|
||||
l.warn("w");
|
||||
l.error("e");
|
||||
l.fatal("f");
|
||||
|
||||
Exception e = new Exception("testing");
|
||||
l.trace("t", e);
|
||||
l.debug("d", e);
|
||||
l.info("i", e);
|
||||
l.warn("w", e);
|
||||
l.error("e", e);
|
||||
l.fatal("f", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,68 +1,68 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.dummy;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.Category;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class Bug131 extends TestCase {
|
||||
|
||||
public void testBug131() {
|
||||
|
||||
ListHandler listHandler = new ListHandler();
|
||||
java.util.logging.Logger root = java.util.logging.Logger.getLogger("");
|
||||
root.addHandler(listHandler);
|
||||
root.setLevel(Level.FINEST);
|
||||
Logger log4jLogger = Logger.getLogger("a");
|
||||
Category log4jCategory = Logger.getLogger("b");
|
||||
|
||||
int n = 0;
|
||||
|
||||
log4jLogger.trace("msg" +(n++));
|
||||
log4jLogger.debug("msg" +(n++));
|
||||
log4jLogger.info("msg" +(n++));
|
||||
log4jLogger.warn("msg" +(n++));
|
||||
log4jLogger.error("msg" +(n++));
|
||||
log4jLogger.fatal("msg" +(n++));
|
||||
|
||||
log4jCategory.debug("msg" +(n++));
|
||||
log4jCategory.info("msg" +(n++));
|
||||
log4jCategory.warn("msg" +(n++));
|
||||
log4jCategory.error("msg" +(n++));
|
||||
log4jCategory.fatal("msg" +(n++));
|
||||
|
||||
assertEquals(n, listHandler.list.size());
|
||||
|
||||
for(int i = 0; i < n; i++) {
|
||||
LogRecord logRecord = (LogRecord) listHandler.list.get(i);
|
||||
assertEquals("testBug131", logRecord.getSourceMethodName());
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.dummy;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.Category;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class Bug131 extends TestCase {
|
||||
|
||||
public void testBug131() {
|
||||
|
||||
ListHandler listHandler = new ListHandler();
|
||||
java.util.logging.Logger root = java.util.logging.Logger.getLogger("");
|
||||
root.addHandler(listHandler);
|
||||
root.setLevel(Level.FINEST);
|
||||
Logger log4jLogger = Logger.getLogger("a");
|
||||
Category log4jCategory = Logger.getLogger("b");
|
||||
|
||||
int n = 0;
|
||||
|
||||
log4jLogger.trace("msg" +(n++));
|
||||
log4jLogger.debug("msg" +(n++));
|
||||
log4jLogger.info("msg" +(n++));
|
||||
log4jLogger.warn("msg" +(n++));
|
||||
log4jLogger.error("msg" +(n++));
|
||||
log4jLogger.fatal("msg" +(n++));
|
||||
|
||||
log4jCategory.debug("msg" +(n++));
|
||||
log4jCategory.info("msg" +(n++));
|
||||
log4jCategory.warn("msg" +(n++));
|
||||
log4jCategory.error("msg" +(n++));
|
||||
log4jCategory.fatal("msg" +(n++));
|
||||
|
||||
assertEquals(n, listHandler.list.size());
|
||||
|
||||
for(int i = 0; i < n; i++) {
|
||||
LogRecord logRecord = (LogRecord) listHandler.list.get(i);
|
||||
assertEquals("testBug131", logRecord.getSourceMethodName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,57 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.dummy;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.Category;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class Bug139 extends TestCase {
|
||||
|
||||
public void test() {
|
||||
ListHandler listHandler = new ListHandler();
|
||||
java.util.logging.Logger root = java.util.logging.Logger.getLogger("");
|
||||
root.addHandler(listHandler);
|
||||
root.setLevel(Level.FINEST);
|
||||
Logger log4jLogger = Logger.getLogger("a");
|
||||
Category log4jCategory = Logger.getLogger("b");
|
||||
|
||||
int n = 0;
|
||||
|
||||
log4jLogger.log(org.apache.log4j.Level.DEBUG, "hello"+(++n));
|
||||
log4jCategory.log(org.apache.log4j.Level.DEBUG, "world"+(++n));
|
||||
|
||||
assertEquals(n, listHandler.list.size());
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
LogRecord logRecord = (LogRecord) listHandler.list.get(i);
|
||||
assertEquals("test", logRecord.getSourceMethodName());
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.dummy;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.apache.log4j.Category;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class Bug139 extends TestCase {
|
||||
|
||||
public void test() {
|
||||
ListHandler listHandler = new ListHandler();
|
||||
java.util.logging.Logger root = java.util.logging.Logger.getLogger("");
|
||||
root.addHandler(listHandler);
|
||||
root.setLevel(Level.FINEST);
|
||||
Logger log4jLogger = Logger.getLogger("a");
|
||||
Category log4jCategory = Logger.getLogger("b");
|
||||
|
||||
int n = 0;
|
||||
|
||||
log4jLogger.log(org.apache.log4j.Level.DEBUG, "hello"+(++n));
|
||||
log4jCategory.log(org.apache.log4j.Level.DEBUG, "world"+(++n));
|
||||
|
||||
assertEquals(n, listHandler.list.size());
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
LogRecord logRecord = (LogRecord) listHandler.list.get(i);
|
||||
assertEquals("test", logRecord.getSourceMethodName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
package org.dummy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
public class ListHandler extends Handler {
|
||||
|
||||
List list = new ArrayList();
|
||||
|
||||
public void close() throws SecurityException {
|
||||
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
|
||||
}
|
||||
|
||||
public void publish(LogRecord logRecord) {
|
||||
logRecord.getSourceClassName();
|
||||
list.add(logRecord);
|
||||
}
|
||||
|
||||
}
|
||||
package org.dummy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
public class ListHandler extends Handler {
|
||||
|
||||
List list = new ArrayList();
|
||||
|
||||
public void close() throws SecurityException {
|
||||
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
|
||||
}
|
||||
|
||||
public void publish(LogRecord logRecord) {
|
||||
logRecord.getSourceClassName();
|
||||
list.add(logRecord);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,24 +1,24 @@
|
|||
Copyright (c) 2004-2007 QOS.ch
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
Copyright (c) 2004-2007 QOS.ch
|
||||
All rights reserved.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,101 +1,101 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>SLF4J API Module</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
<description>The slf4j API</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<forkMode>once</forkMode>
|
||||
<reportFormat>plain</reportFormat>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
<excludes>
|
||||
<exclude>**/AllTest.java</exclude>
|
||||
<exclude>**/PackageTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
|
||||
<Bundle-Description>${project.description}</Bundle-Description>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
</manifestEntries>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>bundle-test-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<echo>Removing slf4j-api's dummy StaticLoggerBinder and StaticMarkerBinder</echo>
|
||||
<delete dir="target/classes/org/slf4j/impl"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>clirr-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<comparisonVersion>1.5.6</comparisonVersion>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>SLF4J API Module</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
<description>The slf4j API</description>
|
||||
|
||||
<dependencies>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<forkMode>once</forkMode>
|
||||
<reportFormat>plain</reportFormat>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
<excludes>
|
||||
<exclude>**/AllTest.java</exclude>
|
||||
<exclude>**/PackageTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
|
||||
<Bundle-Description>${project.description}</Bundle-Description>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
</manifestEntries>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>bundle-test-jar</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
<goal>test-jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>process-classes</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<echo>Removing slf4j-api's dummy StaticLoggerBinder and StaticMarkerBinder</echo>
|
||||
<delete dir="target/classes/org/slf4j/impl"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>clirr-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<comparisonVersion>1.5.6</comparisonVersion>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,57 +1,57 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
|
||||
/**
|
||||
* <code>ILoggerFactory</code> instances manufacture {@link Logger}
|
||||
* instances by name.
|
||||
*
|
||||
* <p>Most users retrieve {@link Logger} instances through the static
|
||||
* {@link LoggerFactory#getLogger(String)} method. An instance of of this
|
||||
* interface is bound internally with {@link LoggerFactory} class at
|
||||
* compile time.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public interface ILoggerFactory {
|
||||
|
||||
/**
|
||||
* Return an appropriate {@link Logger} instance as specified by the
|
||||
* <code>name</code> parameter.
|
||||
*
|
||||
* <p>If the name parameter is equal to {@link Logger#ROOT_LOGGER_NAME}, that is
|
||||
* the string value "ROOT" (case insensitive), then the root logger of the
|
||||
* underlying logging system is returned.
|
||||
*
|
||||
* <p>Null-valued name arguments are considered invalid.
|
||||
*
|
||||
* <p>Certain extremely simple logging systems, e.g. NOP, may always
|
||||
* return the same logger instance regardless of the requested name.
|
||||
*
|
||||
* @param name the name of the Logger to return
|
||||
*/
|
||||
public Logger getLogger(String name);
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
|
||||
/**
|
||||
* <code>ILoggerFactory</code> instances manufacture {@link Logger}
|
||||
* instances by name.
|
||||
*
|
||||
* <p>Most users retrieve {@link Logger} instances through the static
|
||||
* {@link LoggerFactory#getLogger(String)} method. An instance of of this
|
||||
* interface is bound internally with {@link LoggerFactory} class at
|
||||
* compile time.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public interface ILoggerFactory {
|
||||
|
||||
/**
|
||||
* Return an appropriate {@link Logger} instance as specified by the
|
||||
* <code>name</code> parameter.
|
||||
*
|
||||
* <p>If the name parameter is equal to {@link Logger#ROOT_LOGGER_NAME}, that is
|
||||
* the string value "ROOT" (case insensitive), then the root logger of the
|
||||
* underlying logging system is returned.
|
||||
*
|
||||
* <p>Null-valued name arguments are considered invalid.
|
||||
*
|
||||
* <p>Certain extremely simple logging systems, e.g. NOP, may always
|
||||
* return the same logger instance regardless of the requested name.
|
||||
*
|
||||
* @param name the name of the Logger to return
|
||||
*/
|
||||
public Logger getLogger(String name);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,81 +1,81 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
|
||||
/**
|
||||
* Implementaitons of this interface are used to manufacture {@link Marker}
|
||||
* instances.
|
||||
*
|
||||
* <p>See the section <a href="http://slf4j.org/faq.html#3">Implementing
|
||||
* the SLF4J API</a> in the FAQ for details on how to make your logging
|
||||
* system conform to SLF4J.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public interface IMarkerFactory {
|
||||
|
||||
/**
|
||||
* Manufacture a {@link Marker} instance by name. If the instance has been
|
||||
* created earlier, return the previously created instance.
|
||||
*
|
||||
* <p>Null name values are not allowed.
|
||||
*
|
||||
* @param name the name of the marker to be created, null value is
|
||||
* not allowed.
|
||||
*
|
||||
* @return a Marker instance
|
||||
*/
|
||||
Marker getMarker(String name);
|
||||
|
||||
/**
|
||||
* Checks if the marker with the name already exists. If name is null, then false
|
||||
* is returned.
|
||||
*
|
||||
* @return true id the marker exists, false otherwise.
|
||||
*/
|
||||
boolean exists(String name);
|
||||
|
||||
/**
|
||||
* Detach an existing marker.
|
||||
* <p>
|
||||
* Note that after a marker is detached, there might still be "dangling" references
|
||||
* to the detached marker.
|
||||
*
|
||||
*
|
||||
* @param name The name of the marker to detach
|
||||
* @return whether the marker could be detached or not
|
||||
*/
|
||||
boolean detachMarker(String name);
|
||||
|
||||
|
||||
/**
|
||||
* Create a marker which is detached (even at birth) from this IMarkerFactory.
|
||||
*
|
||||
* @return a dangling marker
|
||||
* @since 1.5.1
|
||||
*/
|
||||
Marker getDetachedMarker(String name);
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
|
||||
/**
|
||||
* Implementaitons of this interface are used to manufacture {@link Marker}
|
||||
* instances.
|
||||
*
|
||||
* <p>See the section <a href="http://slf4j.org/faq.html#3">Implementing
|
||||
* the SLF4J API</a> in the FAQ for details on how to make your logging
|
||||
* system conform to SLF4J.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public interface IMarkerFactory {
|
||||
|
||||
/**
|
||||
* Manufacture a {@link Marker} instance by name. If the instance has been
|
||||
* created earlier, return the previously created instance.
|
||||
*
|
||||
* <p>Null name values are not allowed.
|
||||
*
|
||||
* @param name the name of the marker to be created, null value is
|
||||
* not allowed.
|
||||
*
|
||||
* @return a Marker instance
|
||||
*/
|
||||
Marker getMarker(String name);
|
||||
|
||||
/**
|
||||
* Checks if the marker with the name already exists. If name is null, then false
|
||||
* is returned.
|
||||
*
|
||||
* @return true id the marker exists, false otherwise.
|
||||
*/
|
||||
boolean exists(String name);
|
||||
|
||||
/**
|
||||
* Detach an existing marker.
|
||||
* <p>
|
||||
* Note that after a marker is detached, there might still be "dangling" references
|
||||
* to the detached marker.
|
||||
*
|
||||
*
|
||||
* @param name The name of the marker to detach
|
||||
* @return whether the marker could be detached or not
|
||||
*/
|
||||
boolean detachMarker(String name);
|
||||
|
||||
|
||||
/**
|
||||
* Create a marker which is detached (even at birth) from this IMarkerFactory.
|
||||
*
|
||||
* @return a dangling marker
|
||||
* @since 1.5.1
|
||||
*/
|
||||
Marker getDetachedMarker(String name);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -1,290 +1,290 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.helpers.SubstituteLoggerFactory;
|
||||
import org.slf4j.helpers.Util;
|
||||
import org.slf4j.impl.StaticLoggerBinder;
|
||||
|
||||
/**
|
||||
* The <code>LoggerFactory</code> is a utility class producing Loggers for
|
||||
* various logging APIs, most notably for log4j, logback and JDK 1.4 logging.
|
||||
* Other implementations such as {@link org.slf4j.impl.NOPLogger NOPLogger} and
|
||||
* {@link org.slf4j.impl.SimpleLogger SimpleLogger} are also supported.
|
||||
*
|
||||
* <p>
|
||||
* <code>LoggerFactory</code> is essentially a wrapper around an
|
||||
* {@link ILoggerFactory} instance bound with <code>LoggerFactory</code> at
|
||||
* compile time.
|
||||
*
|
||||
* <p>
|
||||
* Please note that all methods in <code>LoggerFactory</code> are static.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author Robert Elliot
|
||||
*/
|
||||
public final class LoggerFactory {
|
||||
|
||||
static final String NO_STATICLOGGERBINDER_URL = "http://www.slf4j.org/codes.html#StaticLoggerBinder";
|
||||
static final String MULTIPLE_BINDINGS_URL = "http://www.slf4j.org/codes.html#multiple_bindings";
|
||||
static final String NULL_LF_URL = "http://www.slf4j.org/codes.html#null_LF";
|
||||
static final String VERSION_MISMATCH = "http://www.slf4j.org/codes.html#version_mismatch";
|
||||
static final String SUBSTITUTE_LOGGER_URL = "http://www.slf4j.org/codes.html#substituteLogger";
|
||||
|
||||
static final String UNSUCCESSFUL_INIT_URL = "http://www.slf4j.org/codes.html#unsuccessfulInit";
|
||||
static final String UNSUCCESSFUL_INIT_MSG = "org.slf4j.LoggerFactory could not be successfully initialized. See also "
|
||||
+ UNSUCCESSFUL_INIT_URL;
|
||||
|
||||
static final int UNINITIALIZED = 0;
|
||||
static final int ONGOING_INITILIZATION = 1;
|
||||
static final int FAILED_INITILIZATION = 2;
|
||||
static final int SUCCESSFUL_INITILIZATION = 3;
|
||||
|
||||
static final int GET_SINGLETON_INEXISTENT = 1;
|
||||
static final int GET_SINGLETON_EXISTS = 2;
|
||||
|
||||
static int INITIALIZATION_STATE = UNINITIALIZED;
|
||||
static int GET_SINGLETON_METHOD = UNINITIALIZED;
|
||||
static SubstituteLoggerFactory TEMP_FACTORY = new SubstituteLoggerFactory();
|
||||
|
||||
/**
|
||||
* It is LoggerFactory's responsibility to track version changes and manage
|
||||
* the compatibility list.
|
||||
*
|
||||
* <p>
|
||||
* It is assumed that qualifiers after the 3rd digit have no impact on
|
||||
* compatibility. Thus, 1.5.7-SNAPSHOT, 1.5.7.RC0 are compatible with 1.5.7.
|
||||
*/
|
||||
static private final String[] API_COMPATIBILITY_LIST = new String[] {
|
||||
"1.5.5", "1.5.6", "1.5.7", "1.5.8", "1.5.9", "1.5.10" };
|
||||
|
||||
// private constructor prevents instantiation
|
||||
private LoggerFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Force LoggerFactory to consider itself uninitialized.
|
||||
*
|
||||
* <p>
|
||||
* This method is intended to be called by classes (in the same package) for
|
||||
* testing purposes. This method is internal. It can be modified, renamed or
|
||||
* removed at any time without notice.
|
||||
*
|
||||
* <p>
|
||||
* You are strongly discouraged from calling this method in production code.
|
||||
*/
|
||||
static void reset() {
|
||||
INITIALIZATION_STATE = UNINITIALIZED;
|
||||
GET_SINGLETON_METHOD = UNINITIALIZED;
|
||||
TEMP_FACTORY = new SubstituteLoggerFactory();
|
||||
}
|
||||
|
||||
private final static void performInitialization() {
|
||||
bind();
|
||||
versionSanityCheck();
|
||||
singleImplementationSanityCheck();
|
||||
|
||||
}
|
||||
|
||||
private final static void bind() {
|
||||
try {
|
||||
// the next line does the binding
|
||||
getSingleton();
|
||||
INITIALIZATION_STATE = SUCCESSFUL_INITILIZATION;
|
||||
emitSubstituteLoggerWarning();
|
||||
} catch (NoClassDefFoundError ncde) {
|
||||
INITIALIZATION_STATE = FAILED_INITILIZATION;
|
||||
String msg = ncde.getMessage();
|
||||
if (msg != null && msg.indexOf("org/slf4j/impl/StaticLoggerBinder") != -1) {
|
||||
Util
|
||||
.reportFailure("Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".");
|
||||
Util.reportFailure("See " + NO_STATICLOGGERBINDER_URL
|
||||
+ " for further details.");
|
||||
|
||||
}
|
||||
throw ncde;
|
||||
} catch (Exception e) {
|
||||
INITIALIZATION_STATE = FAILED_INITILIZATION;
|
||||
// we should never get here
|
||||
Util.reportFailure("Failed to instantiate logger ["
|
||||
+ getSingleton().getLoggerFactoryClassStr() + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
private final static void emitSubstituteLoggerWarning() {
|
||||
List loggerNameList = TEMP_FACTORY.getLoggerNameList();
|
||||
if (loggerNameList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
Util
|
||||
.reportFailure("The following loggers will not work becasue they were created");
|
||||
Util
|
||||
.reportFailure("during the default configuration phase of the underlying logging system.");
|
||||
Util.reportFailure("See also " + SUBSTITUTE_LOGGER_URL);
|
||||
for (int i = 0; i < loggerNameList.size(); i++) {
|
||||
String loggerName = (String) loggerNameList.get(i);
|
||||
Util.reportFailure(loggerName);
|
||||
}
|
||||
}
|
||||
|
||||
private final static void versionSanityCheck() {
|
||||
try {
|
||||
String requested = StaticLoggerBinder.REQUESTED_API_VERSION;
|
||||
|
||||
boolean match = false;
|
||||
for (int i = 0; i < API_COMPATIBILITY_LIST.length; i++) {
|
||||
if (requested.startsWith(API_COMPATIBILITY_LIST[i])) {
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
if (!match) {
|
||||
Util.reportFailure("The requested version " + requested
|
||||
+ " by your slf4j binding is not compatible with "
|
||||
+ Arrays.asList(API_COMPATIBILITY_LIST).toString());
|
||||
Util.reportFailure("See " + VERSION_MISMATCH + " for further details.");
|
||||
}
|
||||
} catch (java.lang.NoSuchFieldError nsfe) {
|
||||
// given our large user base and SLF4J's commitment to backward
|
||||
// compatibility, we cannot cry here. Only for implementations
|
||||
// which willingly declare a REQUESTED_API_VERSION field do we
|
||||
// emit compatibility warnings.
|
||||
} catch (Throwable e) {
|
||||
// we should never reach here
|
||||
Util.reportFailure(
|
||||
"Unexpected problem occured during version sanity check", e);
|
||||
}
|
||||
}
|
||||
|
||||
// We need to use the name of the StaticLoggerBinder class, we can't reference
|
||||
// the class itseld.
|
||||
private static String STATIC_LOGGER_BINDER_PATH = "org/slf4j/impl/StaticLoggerBinder.class";
|
||||
|
||||
private static void singleImplementationSanityCheck() {
|
||||
try {
|
||||
ClassLoader loggerFactoryClassLoader = LoggerFactory.class
|
||||
.getClassLoader();
|
||||
if (loggerFactoryClassLoader == null) {
|
||||
// see http://bugzilla.slf4j.org/show_bug.cgi?id=146
|
||||
return; // better than a null pointer exception
|
||||
}
|
||||
Enumeration paths = loggerFactoryClassLoader
|
||||
.getResources(STATIC_LOGGER_BINDER_PATH);
|
||||
List implementationList = new ArrayList();
|
||||
while (paths.hasMoreElements()) {
|
||||
URL path = (URL) paths.nextElement();
|
||||
implementationList.add(path);
|
||||
}
|
||||
if (implementationList.size() > 1) {
|
||||
Util.reportFailure("Class path contains multiple SLF4J bindings.");
|
||||
for (int i = 0; i < implementationList.size(); i++) {
|
||||
Util.reportFailure("Found binding in [" + implementationList.get(i)
|
||||
+ "]");
|
||||
}
|
||||
Util.reportFailure("See " + MULTIPLE_BINDINGS_URL
|
||||
+ " for an explanation.");
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
Util.reportFailure("Error getting resources from path", ioe);
|
||||
}
|
||||
}
|
||||
|
||||
private final static StaticLoggerBinder getSingleton() {
|
||||
if (GET_SINGLETON_METHOD == GET_SINGLETON_INEXISTENT) {
|
||||
return StaticLoggerBinder.SINGLETON;
|
||||
}
|
||||
|
||||
if (GET_SINGLETON_METHOD == GET_SINGLETON_EXISTS) {
|
||||
return StaticLoggerBinder.getSingleton();
|
||||
}
|
||||
|
||||
try {
|
||||
StaticLoggerBinder singleton = StaticLoggerBinder.getSingleton();
|
||||
GET_SINGLETON_METHOD = GET_SINGLETON_EXISTS;
|
||||
return singleton;
|
||||
} catch (NoSuchMethodError nsme) {
|
||||
GET_SINGLETON_METHOD = GET_SINGLETON_INEXISTENT;
|
||||
return StaticLoggerBinder.SINGLETON;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a logger named according to the name parameter using the statically
|
||||
* bound {@link ILoggerFactory} instance.
|
||||
*
|
||||
* @param name
|
||||
* The name of the logger.
|
||||
* @return logger
|
||||
*/
|
||||
public static Logger getLogger(String name) {
|
||||
ILoggerFactory iLoggerFactory = getILoggerFactory();
|
||||
return iLoggerFactory.getLogger(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a logger named corresponding to the class passed as parameter, using
|
||||
* the statically bound {@link ILoggerFactory} instance.
|
||||
*
|
||||
* @param clazz
|
||||
* the returned logger will be named after clazz
|
||||
* @return logger
|
||||
*/
|
||||
public static Logger getLogger(Class clazz) {
|
||||
return getLogger(clazz.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link ILoggerFactory} instance in use.
|
||||
*
|
||||
* <p>
|
||||
* ILoggerFactory instance is bound with this class at compile time.
|
||||
*
|
||||
* @return the ILoggerFactory instance in use
|
||||
*/
|
||||
public static ILoggerFactory getILoggerFactory() {
|
||||
if (INITIALIZATION_STATE == UNINITIALIZED) {
|
||||
INITIALIZATION_STATE = ONGOING_INITILIZATION;
|
||||
performInitialization();
|
||||
|
||||
}
|
||||
switch (INITIALIZATION_STATE) {
|
||||
case SUCCESSFUL_INITILIZATION:
|
||||
return getSingleton().getLoggerFactory();
|
||||
case FAILED_INITILIZATION:
|
||||
throw new IllegalStateException(UNSUCCESSFUL_INIT_MSG);
|
||||
case ONGOING_INITILIZATION:
|
||||
// support re-entrant behavior.
|
||||
// See also http://bugzilla.slf4j.org/show_bug.cgi?id=106
|
||||
return TEMP_FACTORY;
|
||||
}
|
||||
throw new IllegalStateException("Unreachable code");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.helpers.SubstituteLoggerFactory;
|
||||
import org.slf4j.helpers.Util;
|
||||
import org.slf4j.impl.StaticLoggerBinder;
|
||||
|
||||
/**
|
||||
* The <code>LoggerFactory</code> is a utility class producing Loggers for
|
||||
* various logging APIs, most notably for log4j, logback and JDK 1.4 logging.
|
||||
* Other implementations such as {@link org.slf4j.impl.NOPLogger NOPLogger} and
|
||||
* {@link org.slf4j.impl.SimpleLogger SimpleLogger} are also supported.
|
||||
*
|
||||
* <p>
|
||||
* <code>LoggerFactory</code> is essentially a wrapper around an
|
||||
* {@link ILoggerFactory} instance bound with <code>LoggerFactory</code> at
|
||||
* compile time.
|
||||
*
|
||||
* <p>
|
||||
* Please note that all methods in <code>LoggerFactory</code> are static.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author Robert Elliot
|
||||
*/
|
||||
public final class LoggerFactory {
|
||||
|
||||
static final String NO_STATICLOGGERBINDER_URL = "http://www.slf4j.org/codes.html#StaticLoggerBinder";
|
||||
static final String MULTIPLE_BINDINGS_URL = "http://www.slf4j.org/codes.html#multiple_bindings";
|
||||
static final String NULL_LF_URL = "http://www.slf4j.org/codes.html#null_LF";
|
||||
static final String VERSION_MISMATCH = "http://www.slf4j.org/codes.html#version_mismatch";
|
||||
static final String SUBSTITUTE_LOGGER_URL = "http://www.slf4j.org/codes.html#substituteLogger";
|
||||
|
||||
static final String UNSUCCESSFUL_INIT_URL = "http://www.slf4j.org/codes.html#unsuccessfulInit";
|
||||
static final String UNSUCCESSFUL_INIT_MSG = "org.slf4j.LoggerFactory could not be successfully initialized. See also "
|
||||
+ UNSUCCESSFUL_INIT_URL;
|
||||
|
||||
static final int UNINITIALIZED = 0;
|
||||
static final int ONGOING_INITILIZATION = 1;
|
||||
static final int FAILED_INITILIZATION = 2;
|
||||
static final int SUCCESSFUL_INITILIZATION = 3;
|
||||
|
||||
static final int GET_SINGLETON_INEXISTENT = 1;
|
||||
static final int GET_SINGLETON_EXISTS = 2;
|
||||
|
||||
static int INITIALIZATION_STATE = UNINITIALIZED;
|
||||
static int GET_SINGLETON_METHOD = UNINITIALIZED;
|
||||
static SubstituteLoggerFactory TEMP_FACTORY = new SubstituteLoggerFactory();
|
||||
|
||||
/**
|
||||
* It is LoggerFactory's responsibility to track version changes and manage
|
||||
* the compatibility list.
|
||||
*
|
||||
* <p>
|
||||
* It is assumed that qualifiers after the 3rd digit have no impact on
|
||||
* compatibility. Thus, 1.5.7-SNAPSHOT, 1.5.7.RC0 are compatible with 1.5.7.
|
||||
*/
|
||||
static private final String[] API_COMPATIBILITY_LIST = new String[] {
|
||||
"1.5.5", "1.5.6", "1.5.7", "1.5.8", "1.5.9", "1.5.10" };
|
||||
|
||||
// private constructor prevents instantiation
|
||||
private LoggerFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Force LoggerFactory to consider itself uninitialized.
|
||||
*
|
||||
* <p>
|
||||
* This method is intended to be called by classes (in the same package) for
|
||||
* testing purposes. This method is internal. It can be modified, renamed or
|
||||
* removed at any time without notice.
|
||||
*
|
||||
* <p>
|
||||
* You are strongly discouraged from calling this method in production code.
|
||||
*/
|
||||
static void reset() {
|
||||
INITIALIZATION_STATE = UNINITIALIZED;
|
||||
GET_SINGLETON_METHOD = UNINITIALIZED;
|
||||
TEMP_FACTORY = new SubstituteLoggerFactory();
|
||||
}
|
||||
|
||||
private final static void performInitialization() {
|
||||
bind();
|
||||
versionSanityCheck();
|
||||
singleImplementationSanityCheck();
|
||||
|
||||
}
|
||||
|
||||
private final static void bind() {
|
||||
try {
|
||||
// the next line does the binding
|
||||
getSingleton();
|
||||
INITIALIZATION_STATE = SUCCESSFUL_INITILIZATION;
|
||||
emitSubstituteLoggerWarning();
|
||||
} catch (NoClassDefFoundError ncde) {
|
||||
INITIALIZATION_STATE = FAILED_INITILIZATION;
|
||||
String msg = ncde.getMessage();
|
||||
if (msg != null && msg.indexOf("org/slf4j/impl/StaticLoggerBinder") != -1) {
|
||||
Util
|
||||
.reportFailure("Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".");
|
||||
Util.reportFailure("See " + NO_STATICLOGGERBINDER_URL
|
||||
+ " for further details.");
|
||||
|
||||
}
|
||||
throw ncde;
|
||||
} catch (Exception e) {
|
||||
INITIALIZATION_STATE = FAILED_INITILIZATION;
|
||||
// we should never get here
|
||||
Util.reportFailure("Failed to instantiate logger ["
|
||||
+ getSingleton().getLoggerFactoryClassStr() + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
private final static void emitSubstituteLoggerWarning() {
|
||||
List loggerNameList = TEMP_FACTORY.getLoggerNameList();
|
||||
if (loggerNameList.size() == 0) {
|
||||
return;
|
||||
}
|
||||
Util
|
||||
.reportFailure("The following loggers will not work becasue they were created");
|
||||
Util
|
||||
.reportFailure("during the default configuration phase of the underlying logging system.");
|
||||
Util.reportFailure("See also " + SUBSTITUTE_LOGGER_URL);
|
||||
for (int i = 0; i < loggerNameList.size(); i++) {
|
||||
String loggerName = (String) loggerNameList.get(i);
|
||||
Util.reportFailure(loggerName);
|
||||
}
|
||||
}
|
||||
|
||||
private final static void versionSanityCheck() {
|
||||
try {
|
||||
String requested = StaticLoggerBinder.REQUESTED_API_VERSION;
|
||||
|
||||
boolean match = false;
|
||||
for (int i = 0; i < API_COMPATIBILITY_LIST.length; i++) {
|
||||
if (requested.startsWith(API_COMPATIBILITY_LIST[i])) {
|
||||
match = true;
|
||||
}
|
||||
}
|
||||
if (!match) {
|
||||
Util.reportFailure("The requested version " + requested
|
||||
+ " by your slf4j binding is not compatible with "
|
||||
+ Arrays.asList(API_COMPATIBILITY_LIST).toString());
|
||||
Util.reportFailure("See " + VERSION_MISMATCH + " for further details.");
|
||||
}
|
||||
} catch (java.lang.NoSuchFieldError nsfe) {
|
||||
// given our large user base and SLF4J's commitment to backward
|
||||
// compatibility, we cannot cry here. Only for implementations
|
||||
// which willingly declare a REQUESTED_API_VERSION field do we
|
||||
// emit compatibility warnings.
|
||||
} catch (Throwable e) {
|
||||
// we should never reach here
|
||||
Util.reportFailure(
|
||||
"Unexpected problem occured during version sanity check", e);
|
||||
}
|
||||
}
|
||||
|
||||
// We need to use the name of the StaticLoggerBinder class, we can't reference
|
||||
// the class itseld.
|
||||
private static String STATIC_LOGGER_BINDER_PATH = "org/slf4j/impl/StaticLoggerBinder.class";
|
||||
|
||||
private static void singleImplementationSanityCheck() {
|
||||
try {
|
||||
ClassLoader loggerFactoryClassLoader = LoggerFactory.class
|
||||
.getClassLoader();
|
||||
if (loggerFactoryClassLoader == null) {
|
||||
// see http://bugzilla.slf4j.org/show_bug.cgi?id=146
|
||||
return; // better than a null pointer exception
|
||||
}
|
||||
Enumeration paths = loggerFactoryClassLoader
|
||||
.getResources(STATIC_LOGGER_BINDER_PATH);
|
||||
List implementationList = new ArrayList();
|
||||
while (paths.hasMoreElements()) {
|
||||
URL path = (URL) paths.nextElement();
|
||||
implementationList.add(path);
|
||||
}
|
||||
if (implementationList.size() > 1) {
|
||||
Util.reportFailure("Class path contains multiple SLF4J bindings.");
|
||||
for (int i = 0; i < implementationList.size(); i++) {
|
||||
Util.reportFailure("Found binding in [" + implementationList.get(i)
|
||||
+ "]");
|
||||
}
|
||||
Util.reportFailure("See " + MULTIPLE_BINDINGS_URL
|
||||
+ " for an explanation.");
|
||||
}
|
||||
} catch (IOException ioe) {
|
||||
Util.reportFailure("Error getting resources from path", ioe);
|
||||
}
|
||||
}
|
||||
|
||||
private final static StaticLoggerBinder getSingleton() {
|
||||
if (GET_SINGLETON_METHOD == GET_SINGLETON_INEXISTENT) {
|
||||
return StaticLoggerBinder.SINGLETON;
|
||||
}
|
||||
|
||||
if (GET_SINGLETON_METHOD == GET_SINGLETON_EXISTS) {
|
||||
return StaticLoggerBinder.getSingleton();
|
||||
}
|
||||
|
||||
try {
|
||||
StaticLoggerBinder singleton = StaticLoggerBinder.getSingleton();
|
||||
GET_SINGLETON_METHOD = GET_SINGLETON_EXISTS;
|
||||
return singleton;
|
||||
} catch (NoSuchMethodError nsme) {
|
||||
GET_SINGLETON_METHOD = GET_SINGLETON_INEXISTENT;
|
||||
return StaticLoggerBinder.SINGLETON;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a logger named according to the name parameter using the statically
|
||||
* bound {@link ILoggerFactory} instance.
|
||||
*
|
||||
* @param name
|
||||
* The name of the logger.
|
||||
* @return logger
|
||||
*/
|
||||
public static Logger getLogger(String name) {
|
||||
ILoggerFactory iLoggerFactory = getILoggerFactory();
|
||||
return iLoggerFactory.getLogger(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a logger named corresponding to the class passed as parameter, using
|
||||
* the statically bound {@link ILoggerFactory} instance.
|
||||
*
|
||||
* @param clazz
|
||||
* the returned logger will be named after clazz
|
||||
* @return logger
|
||||
*/
|
||||
public static Logger getLogger(Class clazz) {
|
||||
return getLogger(clazz.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link ILoggerFactory} instance in use.
|
||||
*
|
||||
* <p>
|
||||
* ILoggerFactory instance is bound with this class at compile time.
|
||||
*
|
||||
* @return the ILoggerFactory instance in use
|
||||
*/
|
||||
public static ILoggerFactory getILoggerFactory() {
|
||||
if (INITIALIZATION_STATE == UNINITIALIZED) {
|
||||
INITIALIZATION_STATE = ONGOING_INITILIZATION;
|
||||
performInitialization();
|
||||
|
||||
}
|
||||
switch (INITIALIZATION_STATE) {
|
||||
case SUCCESSFUL_INITILIZATION:
|
||||
return getSingleton().getLoggerFactory();
|
||||
case FAILED_INITILIZATION:
|
||||
throw new IllegalStateException(UNSUCCESSFUL_INIT_MSG);
|
||||
case ONGOING_INITILIZATION:
|
||||
// support re-entrant behavior.
|
||||
// See also http://bugzilla.slf4j.org/show_bug.cgi?id=106
|
||||
return TEMP_FACTORY;
|
||||
}
|
||||
throw new IllegalStateException("Unreachable code");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,207 +1,207 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.helpers.BasicMDCAdapter;
|
||||
import org.slf4j.helpers.Util;
|
||||
import org.slf4j.impl.StaticMDCBinder;
|
||||
import org.slf4j.spi.MDCAdapter;
|
||||
|
||||
/**
|
||||
* This class hides and serves as a substitute for the underlying logging
|
||||
* system's MDC implementation.
|
||||
*
|
||||
* <p>
|
||||
* If the underlying logging system offers MDC functionality, then SLF4J's MDC,
|
||||
* i.e. this class, will delegate to the underlying system's MDC. Note that at
|
||||
* this time, only two logging systems, namely log4j and logback, offer MDC
|
||||
* functionality. If the underlying system does not support MDC, e.g. java.util.logging,
|
||||
* then SLF4J will use a {@link BasicMDCAdapter}.
|
||||
*
|
||||
* <p>
|
||||
* Thus, as a SLF4J user, you can take advantage of MDC in the presence of log4j
|
||||
* logback, or java.util.logging, but without forcing these systems as dependencies
|
||||
* upon your users.
|
||||
*
|
||||
* <p>
|
||||
* For more information on MDC please see the <a
|
||||
* href="http://logback.qos.ch/manual/mdc.html">chapter on MDC</a> in the
|
||||
* logback manual.
|
||||
*
|
||||
* <p>
|
||||
* Please note that all methods in this class are static.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @since 1.4.1
|
||||
*/
|
||||
public class MDC {
|
||||
|
||||
static final String NULL_MDCA_URL = "http://www.slf4j.org/codes.html#null_MDCA";
|
||||
static final String NO_STATIC_MDC_BINDER_URL = "http://www.slf4j.org/codes.html#no_static_mdc_binder";
|
||||
static MDCAdapter mdcAdapter;
|
||||
|
||||
private MDC() {
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
mdcAdapter = StaticMDCBinder.SINGLETON.getMDCA();
|
||||
} catch (NoClassDefFoundError ncde) {
|
||||
String msg = ncde.getMessage();
|
||||
if (msg != null && msg.indexOf("org/slf4j/impl/StaticMDCBinder") != -1) {
|
||||
Util
|
||||
.reportFailure("Failed to load class \"org.slf4j.impl.StaticMDCBinder\".");
|
||||
Util.reportFailure("See " + NO_STATIC_MDC_BINDER_URL
|
||||
+ " for further details.");
|
||||
|
||||
}
|
||||
throw ncde;
|
||||
} catch (Exception e) {
|
||||
// we should never get here
|
||||
Util.reportFailure("Could not bind with an instance of class ["
|
||||
+ StaticMDCBinder.SINGLETON.getMDCAdapterClassStr() + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a context value (the <code>val</code> parameter) as identified with
|
||||
* the <code>key</code> parameter into the current thread's context map.
|
||||
* The <code>key</code> parameter cannot be null. The <code>val</code> parameter
|
||||
* can be null only if the underlying implementation supports it.
|
||||
*
|
||||
* <p>
|
||||
* This method delegates all work to the MDC of the underlying logging system.
|
||||
*
|
||||
* @throws IllegalArgumentException in case the "key" parameter is null
|
||||
*/
|
||||
public static void put(String key, String val) throws IllegalArgumentException {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("key parameter cannot be null");
|
||||
}
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also "
|
||||
+ NULL_MDCA_URL);
|
||||
}
|
||||
mdcAdapter.put(key, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the context identified by the <code>key</code> parameter. The
|
||||
* <code>key</code> parameter cannot be null.
|
||||
*
|
||||
* <p>This method delegates all work to the MDC of the underlying logging system.
|
||||
*
|
||||
* @return the string value identified by the <code>key</code> parameter.
|
||||
* @throws IllegalArgumentException in case the "key" parameter is null
|
||||
*/
|
||||
public static String get(String key) throws IllegalArgumentException {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("key parameter cannot be null");
|
||||
}
|
||||
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also "
|
||||
+ NULL_MDCA_URL);
|
||||
}
|
||||
return mdcAdapter.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the the context identified by the <code>key</code> parameter using
|
||||
* the underlying system's MDC implementation. The <code>key</code> parameter
|
||||
* cannot be null. This method does nothing if there is no previous value
|
||||
* associated with <code>key</code>.
|
||||
*
|
||||
* @throws IllegalArgumentException in case the "key" parameter is null
|
||||
*/
|
||||
public static void remove(String key) throws IllegalArgumentException {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("key parameter cannot be null");
|
||||
}
|
||||
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also "
|
||||
+ NULL_MDCA_URL);
|
||||
}
|
||||
mdcAdapter.remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all entries in the MDC of the underlying implementation.
|
||||
*/
|
||||
public static void clear() {
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also "
|
||||
+ NULL_MDCA_URL);
|
||||
}
|
||||
mdcAdapter.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a copy of the current thread's context map, with keys and
|
||||
* values of type String. Returned value may be null.
|
||||
*
|
||||
* @return A copy of the current thread's context map. May be null.
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public static Map getCopyOfContextMap() {
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also "
|
||||
+ NULL_MDCA_URL);
|
||||
}
|
||||
return mdcAdapter.getCopyOfContextMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current thread's context map by first clearing any existing
|
||||
* map and then copying the map passed as parameter. The context map passed
|
||||
* as parameter must only contain keys and values of type String.
|
||||
*
|
||||
* @param contextMap must contain only keys and values of type String
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public static void setContextMap(Map contextMap) {
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also "
|
||||
+ NULL_MDCA_URL);
|
||||
}
|
||||
mdcAdapter.setContextMap(contextMap);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the MDCAdapter instance currently in use.
|
||||
*
|
||||
* @return the MDcAdapter instance currently in use.
|
||||
* @since 1.4.2
|
||||
*/
|
||||
public static MDCAdapter getMDCAdapter() {
|
||||
return mdcAdapter;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.helpers.BasicMDCAdapter;
|
||||
import org.slf4j.helpers.Util;
|
||||
import org.slf4j.impl.StaticMDCBinder;
|
||||
import org.slf4j.spi.MDCAdapter;
|
||||
|
||||
/**
|
||||
* This class hides and serves as a substitute for the underlying logging
|
||||
* system's MDC implementation.
|
||||
*
|
||||
* <p>
|
||||
* If the underlying logging system offers MDC functionality, then SLF4J's MDC,
|
||||
* i.e. this class, will delegate to the underlying system's MDC. Note that at
|
||||
* this time, only two logging systems, namely log4j and logback, offer MDC
|
||||
* functionality. If the underlying system does not support MDC, e.g. java.util.logging,
|
||||
* then SLF4J will use a {@link BasicMDCAdapter}.
|
||||
*
|
||||
* <p>
|
||||
* Thus, as a SLF4J user, you can take advantage of MDC in the presence of log4j
|
||||
* logback, or java.util.logging, but without forcing these systems as dependencies
|
||||
* upon your users.
|
||||
*
|
||||
* <p>
|
||||
* For more information on MDC please see the <a
|
||||
* href="http://logback.qos.ch/manual/mdc.html">chapter on MDC</a> in the
|
||||
* logback manual.
|
||||
*
|
||||
* <p>
|
||||
* Please note that all methods in this class are static.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @since 1.4.1
|
||||
*/
|
||||
public class MDC {
|
||||
|
||||
static final String NULL_MDCA_URL = "http://www.slf4j.org/codes.html#null_MDCA";
|
||||
static final String NO_STATIC_MDC_BINDER_URL = "http://www.slf4j.org/codes.html#no_static_mdc_binder";
|
||||
static MDCAdapter mdcAdapter;
|
||||
|
||||
private MDC() {
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
mdcAdapter = StaticMDCBinder.SINGLETON.getMDCA();
|
||||
} catch (NoClassDefFoundError ncde) {
|
||||
String msg = ncde.getMessage();
|
||||
if (msg != null && msg.indexOf("org/slf4j/impl/StaticMDCBinder") != -1) {
|
||||
Util
|
||||
.reportFailure("Failed to load class \"org.slf4j.impl.StaticMDCBinder\".");
|
||||
Util.reportFailure("See " + NO_STATIC_MDC_BINDER_URL
|
||||
+ " for further details.");
|
||||
|
||||
}
|
||||
throw ncde;
|
||||
} catch (Exception e) {
|
||||
// we should never get here
|
||||
Util.reportFailure("Could not bind with an instance of class ["
|
||||
+ StaticMDCBinder.SINGLETON.getMDCAdapterClassStr() + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a context value (the <code>val</code> parameter) as identified with
|
||||
* the <code>key</code> parameter into the current thread's context map.
|
||||
* The <code>key</code> parameter cannot be null. The <code>val</code> parameter
|
||||
* can be null only if the underlying implementation supports it.
|
||||
*
|
||||
* <p>
|
||||
* This method delegates all work to the MDC of the underlying logging system.
|
||||
*
|
||||
* @throws IllegalArgumentException in case the "key" parameter is null
|
||||
*/
|
||||
public static void put(String key, String val) throws IllegalArgumentException {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("key parameter cannot be null");
|
||||
}
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also "
|
||||
+ NULL_MDCA_URL);
|
||||
}
|
||||
mdcAdapter.put(key, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the context identified by the <code>key</code> parameter. The
|
||||
* <code>key</code> parameter cannot be null.
|
||||
*
|
||||
* <p>This method delegates all work to the MDC of the underlying logging system.
|
||||
*
|
||||
* @return the string value identified by the <code>key</code> parameter.
|
||||
* @throws IllegalArgumentException in case the "key" parameter is null
|
||||
*/
|
||||
public static String get(String key) throws IllegalArgumentException {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("key parameter cannot be null");
|
||||
}
|
||||
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also "
|
||||
+ NULL_MDCA_URL);
|
||||
}
|
||||
return mdcAdapter.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the the context identified by the <code>key</code> parameter using
|
||||
* the underlying system's MDC implementation. The <code>key</code> parameter
|
||||
* cannot be null. This method does nothing if there is no previous value
|
||||
* associated with <code>key</code>.
|
||||
*
|
||||
* @throws IllegalArgumentException in case the "key" parameter is null
|
||||
*/
|
||||
public static void remove(String key) throws IllegalArgumentException {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("key parameter cannot be null");
|
||||
}
|
||||
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also "
|
||||
+ NULL_MDCA_URL);
|
||||
}
|
||||
mdcAdapter.remove(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all entries in the MDC of the underlying implementation.
|
||||
*/
|
||||
public static void clear() {
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also "
|
||||
+ NULL_MDCA_URL);
|
||||
}
|
||||
mdcAdapter.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a copy of the current thread's context map, with keys and
|
||||
* values of type String. Returned value may be null.
|
||||
*
|
||||
* @return A copy of the current thread's context map. May be null.
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public static Map getCopyOfContextMap() {
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also "
|
||||
+ NULL_MDCA_URL);
|
||||
}
|
||||
return mdcAdapter.getCopyOfContextMap();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current thread's context map by first clearing any existing
|
||||
* map and then copying the map passed as parameter. The context map passed
|
||||
* as parameter must only contain keys and values of type String.
|
||||
*
|
||||
* @param contextMap must contain only keys and values of type String
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public static void setContextMap(Map contextMap) {
|
||||
if (mdcAdapter == null) {
|
||||
throw new IllegalStateException("MDCAdapter cannot be null. See also "
|
||||
+ NULL_MDCA_URL);
|
||||
}
|
||||
mdcAdapter.setContextMap(contextMap);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the MDCAdapter instance currently in use.
|
||||
*
|
||||
* @return the MDcAdapter instance currently in use.
|
||||
* @since 1.4.2
|
||||
*/
|
||||
public static MDCAdapter getMDCAdapter() {
|
||||
return mdcAdapter;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,143 +1,143 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Markers are named objects used to enrich log statements. Conforming logging
|
||||
* system Implementations of SLF4J determine how information conveyed by markers
|
||||
* are used, if at all. In particular, many conforming logging systems ignore
|
||||
* marker data.
|
||||
*
|
||||
* <p>
|
||||
* Markers can contain references to other markers, which in turn may contain
|
||||
* references of their own.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public interface Marker extends Serializable {
|
||||
|
||||
/**
|
||||
* This constant represents any marker, including a null marker.
|
||||
*/
|
||||
public final String ANY_MARKER = "*";
|
||||
|
||||
/**
|
||||
* This constant represents any non-null marker.
|
||||
*/
|
||||
public final String ANY_NON_NULL_MARKER = "+";
|
||||
|
||||
/**
|
||||
* Get the name of this Marker.
|
||||
*
|
||||
* @return name of marker
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Add a reference to another Marker.
|
||||
*
|
||||
* @param reference
|
||||
* a reference to another marker
|
||||
* @throws IllegalArgumentException
|
||||
* if 'reference' is null
|
||||
*/
|
||||
public void add(Marker reference);
|
||||
|
||||
/**
|
||||
* Remove a marker reference.
|
||||
*
|
||||
* @param reference
|
||||
* the marker reference to remove
|
||||
* @return true if reference could be found and removed, false otherwise.
|
||||
*/
|
||||
public boolean remove(Marker reference);
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #hasReferences()}.
|
||||
*/
|
||||
public boolean hasChildren();
|
||||
|
||||
/**
|
||||
* Does this marker have any references?
|
||||
*
|
||||
* @return true if this marker has one or more references, false otherwise.
|
||||
*/
|
||||
public boolean hasReferences();
|
||||
|
||||
/**
|
||||
* Returns an Iterator which can be used to iterate over the references of this
|
||||
* marker. An empty iterator is returned when this marker has no references.
|
||||
*
|
||||
* @return Iterator over the references of this marker
|
||||
*/
|
||||
public Iterator iterator();
|
||||
|
||||
/**
|
||||
* Does this marker contain a reference to the 'other' marker? Marker A is defined
|
||||
* to contain marker B, if A == B or if B is referenced by A, or if B is referenced
|
||||
* by any one of A's references (recursively).
|
||||
*
|
||||
* @param other
|
||||
* The marker to test for inclusion.
|
||||
* @throws IllegalArgumentException
|
||||
* if 'other' is null
|
||||
* @return Whether this marker contains the other marker.
|
||||
*/
|
||||
public boolean contains(Marker other);
|
||||
|
||||
/**
|
||||
* Does this marker contain the marker named 'name'?
|
||||
*
|
||||
* If 'name' is null the returned value is always false.
|
||||
*
|
||||
* @param other
|
||||
* The marker to test for inclusion.
|
||||
* @return Whether this marker contains the other marker.
|
||||
*/
|
||||
public boolean contains(String name);
|
||||
|
||||
/**
|
||||
* Markers are considered equal if they have the same name.
|
||||
*
|
||||
* @param o
|
||||
* @return true, if this.name equals o.name
|
||||
*
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public boolean equals(Object o);
|
||||
|
||||
/**
|
||||
* Compute the hash code based on the name of this marker.
|
||||
* Note that markers are considered equal if they have the same name.
|
||||
*
|
||||
* @return the computed hashCode
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public int hashCode();
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* Markers are named objects used to enrich log statements. Conforming logging
|
||||
* system Implementations of SLF4J determine how information conveyed by markers
|
||||
* are used, if at all. In particular, many conforming logging systems ignore
|
||||
* marker data.
|
||||
*
|
||||
* <p>
|
||||
* Markers can contain references to other markers, which in turn may contain
|
||||
* references of their own.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public interface Marker extends Serializable {
|
||||
|
||||
/**
|
||||
* This constant represents any marker, including a null marker.
|
||||
*/
|
||||
public final String ANY_MARKER = "*";
|
||||
|
||||
/**
|
||||
* This constant represents any non-null marker.
|
||||
*/
|
||||
public final String ANY_NON_NULL_MARKER = "+";
|
||||
|
||||
/**
|
||||
* Get the name of this Marker.
|
||||
*
|
||||
* @return name of marker
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Add a reference to another Marker.
|
||||
*
|
||||
* @param reference
|
||||
* a reference to another marker
|
||||
* @throws IllegalArgumentException
|
||||
* if 'reference' is null
|
||||
*/
|
||||
public void add(Marker reference);
|
||||
|
||||
/**
|
||||
* Remove a marker reference.
|
||||
*
|
||||
* @param reference
|
||||
* the marker reference to remove
|
||||
* @return true if reference could be found and removed, false otherwise.
|
||||
*/
|
||||
public boolean remove(Marker reference);
|
||||
|
||||
/**
|
||||
* @deprecated Replaced by {@link #hasReferences()}.
|
||||
*/
|
||||
public boolean hasChildren();
|
||||
|
||||
/**
|
||||
* Does this marker have any references?
|
||||
*
|
||||
* @return true if this marker has one or more references, false otherwise.
|
||||
*/
|
||||
public boolean hasReferences();
|
||||
|
||||
/**
|
||||
* Returns an Iterator which can be used to iterate over the references of this
|
||||
* marker. An empty iterator is returned when this marker has no references.
|
||||
*
|
||||
* @return Iterator over the references of this marker
|
||||
*/
|
||||
public Iterator iterator();
|
||||
|
||||
/**
|
||||
* Does this marker contain a reference to the 'other' marker? Marker A is defined
|
||||
* to contain marker B, if A == B or if B is referenced by A, or if B is referenced
|
||||
* by any one of A's references (recursively).
|
||||
*
|
||||
* @param other
|
||||
* The marker to test for inclusion.
|
||||
* @throws IllegalArgumentException
|
||||
* if 'other' is null
|
||||
* @return Whether this marker contains the other marker.
|
||||
*/
|
||||
public boolean contains(Marker other);
|
||||
|
||||
/**
|
||||
* Does this marker contain the marker named 'name'?
|
||||
*
|
||||
* If 'name' is null the returned value is always false.
|
||||
*
|
||||
* @param other
|
||||
* The marker to test for inclusion.
|
||||
* @return Whether this marker contains the other marker.
|
||||
*/
|
||||
public boolean contains(String name);
|
||||
|
||||
/**
|
||||
* Markers are considered equal if they have the same name.
|
||||
*
|
||||
* @param o
|
||||
* @return true, if this.name equals o.name
|
||||
*
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public boolean equals(Object o);
|
||||
|
||||
/**
|
||||
* Compute the hash code based on the name of this marker.
|
||||
* Note that markers are considered equal if they have the same name.
|
||||
*
|
||||
* @return the computed hashCode
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public int hashCode();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,92 +1,92 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import org.slf4j.helpers.Util;
|
||||
import org.slf4j.impl.StaticMarkerBinder;
|
||||
|
||||
/**
|
||||
* MarkerFactory is a utility class producing {@link Marker} instances as
|
||||
* appropriate for the logging system currently in use.
|
||||
*
|
||||
* <p>
|
||||
* This class is essentially implemented as a wrapper around an
|
||||
* {@link IMarkerFactory} instance bound at compile time.
|
||||
*
|
||||
* <p>
|
||||
* Please note that all methods in this class are static.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class MarkerFactory {
|
||||
static IMarkerFactory markerFactory;
|
||||
|
||||
private MarkerFactory() {
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
markerFactory = StaticMarkerBinder.SINGLETON.getMarkerFactory();
|
||||
} catch (Exception e) {
|
||||
// we should never get here
|
||||
Util.reportFailure("Could not instantiate instance of class ["
|
||||
+ StaticMarkerBinder.SINGLETON.getMarkerFactoryClassStr() + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a Marker instance as specified by the name parameter using the
|
||||
* previously bound {@link IMarkerFactory}instance.
|
||||
*
|
||||
* @param name
|
||||
* The name of the {@link Marker} object to return.
|
||||
* @return marker
|
||||
*/
|
||||
public static Marker getMarker(String name) {
|
||||
return markerFactory.getMarker(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a marker which is detached (even at birth) from the MarkerFactory.
|
||||
*
|
||||
* @return a dangling marker
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public static Marker getDetachedMarker(String name) {
|
||||
return markerFactory.getDetachedMarker(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link IMarkerFactory}instance in use.
|
||||
*
|
||||
* <p>The IMarkerFactory instance is usually bound with this class at
|
||||
* compile time.
|
||||
*
|
||||
* @return the IMarkerFactory instance in use
|
||||
*/
|
||||
public static IMarkerFactory getIMarkerFactory() {
|
||||
return markerFactory;
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import org.slf4j.helpers.Util;
|
||||
import org.slf4j.impl.StaticMarkerBinder;
|
||||
|
||||
/**
|
||||
* MarkerFactory is a utility class producing {@link Marker} instances as
|
||||
* appropriate for the logging system currently in use.
|
||||
*
|
||||
* <p>
|
||||
* This class is essentially implemented as a wrapper around an
|
||||
* {@link IMarkerFactory} instance bound at compile time.
|
||||
*
|
||||
* <p>
|
||||
* Please note that all methods in this class are static.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class MarkerFactory {
|
||||
static IMarkerFactory markerFactory;
|
||||
|
||||
private MarkerFactory() {
|
||||
}
|
||||
|
||||
static {
|
||||
try {
|
||||
markerFactory = StaticMarkerBinder.SINGLETON.getMarkerFactory();
|
||||
} catch (Exception e) {
|
||||
// we should never get here
|
||||
Util.reportFailure("Could not instantiate instance of class ["
|
||||
+ StaticMarkerBinder.SINGLETON.getMarkerFactoryClassStr() + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a Marker instance as specified by the name parameter using the
|
||||
* previously bound {@link IMarkerFactory}instance.
|
||||
*
|
||||
* @param name
|
||||
* The name of the {@link Marker} object to return.
|
||||
* @return marker
|
||||
*/
|
||||
public static Marker getMarker(String name) {
|
||||
return markerFactory.getMarker(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a marker which is detached (even at birth) from the MarkerFactory.
|
||||
*
|
||||
* @return a dangling marker
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public static Marker getDetachedMarker(String name) {
|
||||
return markerFactory.getDetachedMarker(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link IMarkerFactory}instance in use.
|
||||
*
|
||||
* <p>The IMarkerFactory instance is usually bound with this class at
|
||||
* compile time.
|
||||
*
|
||||
* @return the IMarkerFactory instance in use
|
||||
*/
|
||||
public static IMarkerFactory getIMarkerFactory() {
|
||||
return markerFactory;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,147 +1,147 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import org.slf4j.spi.MDCAdapter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Basic MDC implementation, which can be used with logging systems that lack
|
||||
* out-of-the-box MDC support.
|
||||
*
|
||||
* This code is largely based on logback's <a
|
||||
* href="http://svn.qos.ch/viewvc/logback/trunk/logback-classic/src/main/java/org/slf4j/impl/LogbackMDCAdapter.java">
|
||||
* LogbackMDCAdapter</a>.
|
||||
*
|
||||
* @author Ceki Gulcu
|
||||
* @author Maarten Bosteels
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public class BasicMDCAdapter implements MDCAdapter {
|
||||
|
||||
private InheritableThreadLocal inheritableThreadLocal = new InheritableThreadLocal();
|
||||
|
||||
/**
|
||||
* Put a context value (the <code>val</code> parameter) as identified with
|
||||
* the <code>key</code> parameter into the current thread's context map.
|
||||
* Note that contrary to log4j, the <code>val</code> parameter can be null.
|
||||
*
|
||||
* <p>
|
||||
* If the current thread does not have a context map it is created as a side
|
||||
* effect of this call.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* in case the "key" parameter is null
|
||||
*/
|
||||
public void put(String key, String val) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("key cannot be null");
|
||||
}
|
||||
HashMap map = (HashMap) inheritableThreadLocal.get();
|
||||
if (map == null) {
|
||||
map = new HashMap();
|
||||
inheritableThreadLocal.set(map);
|
||||
}
|
||||
map.put(key, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the context identified by the <code>key</code> parameter.
|
||||
*/
|
||||
public String get(String key) {
|
||||
HashMap hashMap = (HashMap) inheritableThreadLocal.get();
|
||||
if ((hashMap != null) && (key != null)) {
|
||||
return (String) hashMap.get(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the the context identified by the <code>key</code> parameter.
|
||||
*/
|
||||
public void remove(String key) {
|
||||
HashMap map = (HashMap) inheritableThreadLocal.get();
|
||||
if (map != null) {
|
||||
map.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all entries in the MDC.
|
||||
*/
|
||||
public void clear() {
|
||||
HashMap hashMap = (HashMap) inheritableThreadLocal.get();
|
||||
if (hashMap != null) {
|
||||
hashMap.clear();
|
||||
// the InheritableThreadLocal.remove method was introduced in JDK 1.5
|
||||
// Thus, invoking clear() on previous JDK's will fail
|
||||
inheritableThreadLocal.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the keys in the MDC as a {@link Set} of {@link String}s The
|
||||
* returned value can be null.
|
||||
*
|
||||
* @return the keys in the MDC
|
||||
*/
|
||||
public Set getKeys() {
|
||||
HashMap hashMap = (HashMap) inheritableThreadLocal.get();
|
||||
if (hashMap != null) {
|
||||
return hashMap.keySet();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Return a copy of the current thread's context map.
|
||||
* Returned value may be null.
|
||||
*
|
||||
*/
|
||||
public Map getCopyOfContextMap() {
|
||||
HashMap hashMap = (HashMap) inheritableThreadLocal.get();
|
||||
if (hashMap != null) {
|
||||
return new HashMap(hashMap);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setContextMap(Map contextMap) {
|
||||
HashMap hashMap = (HashMap) inheritableThreadLocal.get();
|
||||
if (hashMap != null) {
|
||||
hashMap.clear();
|
||||
hashMap.putAll(contextMap);
|
||||
} else {
|
||||
hashMap = new HashMap(contextMap);
|
||||
inheritableThreadLocal.set(hashMap);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import org.slf4j.spi.MDCAdapter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Basic MDC implementation, which can be used with logging systems that lack
|
||||
* out-of-the-box MDC support.
|
||||
*
|
||||
* This code is largely based on logback's <a
|
||||
* href="http://svn.qos.ch/viewvc/logback/trunk/logback-classic/src/main/java/org/slf4j/impl/LogbackMDCAdapter.java">
|
||||
* LogbackMDCAdapter</a>.
|
||||
*
|
||||
* @author Ceki Gulcu
|
||||
* @author Maarten Bosteels
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public class BasicMDCAdapter implements MDCAdapter {
|
||||
|
||||
private InheritableThreadLocal inheritableThreadLocal = new InheritableThreadLocal();
|
||||
|
||||
/**
|
||||
* Put a context value (the <code>val</code> parameter) as identified with
|
||||
* the <code>key</code> parameter into the current thread's context map.
|
||||
* Note that contrary to log4j, the <code>val</code> parameter can be null.
|
||||
*
|
||||
* <p>
|
||||
* If the current thread does not have a context map it is created as a side
|
||||
* effect of this call.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* in case the "key" parameter is null
|
||||
*/
|
||||
public void put(String key, String val) {
|
||||
if (key == null) {
|
||||
throw new IllegalArgumentException("key cannot be null");
|
||||
}
|
||||
HashMap map = (HashMap) inheritableThreadLocal.get();
|
||||
if (map == null) {
|
||||
map = new HashMap();
|
||||
inheritableThreadLocal.set(map);
|
||||
}
|
||||
map.put(key, val);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the context identified by the <code>key</code> parameter.
|
||||
*/
|
||||
public String get(String key) {
|
||||
HashMap hashMap = (HashMap) inheritableThreadLocal.get();
|
||||
if ((hashMap != null) && (key != null)) {
|
||||
return (String) hashMap.get(key);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the the context identified by the <code>key</code> parameter.
|
||||
*/
|
||||
public void remove(String key) {
|
||||
HashMap map = (HashMap) inheritableThreadLocal.get();
|
||||
if (map != null) {
|
||||
map.remove(key);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all entries in the MDC.
|
||||
*/
|
||||
public void clear() {
|
||||
HashMap hashMap = (HashMap) inheritableThreadLocal.get();
|
||||
if (hashMap != null) {
|
||||
hashMap.clear();
|
||||
// the InheritableThreadLocal.remove method was introduced in JDK 1.5
|
||||
// Thus, invoking clear() on previous JDK's will fail
|
||||
inheritableThreadLocal.remove();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the keys in the MDC as a {@link Set} of {@link String}s The
|
||||
* returned value can be null.
|
||||
*
|
||||
* @return the keys in the MDC
|
||||
*/
|
||||
public Set getKeys() {
|
||||
HashMap hashMap = (HashMap) inheritableThreadLocal.get();
|
||||
if (hashMap != null) {
|
||||
return hashMap.keySet();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Return a copy of the current thread's context map.
|
||||
* Returned value may be null.
|
||||
*
|
||||
*/
|
||||
public Map getCopyOfContextMap() {
|
||||
HashMap hashMap = (HashMap) inheritableThreadLocal.get();
|
||||
if (hashMap != null) {
|
||||
return new HashMap(hashMap);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void setContextMap(Map contextMap) {
|
||||
HashMap hashMap = (HashMap) inheritableThreadLocal.get();
|
||||
if (hashMap != null) {
|
||||
hashMap.clear();
|
||||
hashMap.putAll(contextMap);
|
||||
} else {
|
||||
hashMap = new HashMap(contextMap);
|
||||
inheritableThreadLocal.set(hashMap);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,196 +1,196 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.slf4j.Marker;
|
||||
|
||||
/**
|
||||
* A simple implementation of the {@link Marker} interface.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author Joern Huxhorn
|
||||
*/
|
||||
public class BasicMarker implements Marker {
|
||||
|
||||
private static final long serialVersionUID = 1803952589649545191L;
|
||||
|
||||
private final String name;
|
||||
private List refereceList;
|
||||
|
||||
BasicMarker(String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("A merker name cannot be null");
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public synchronized void add(Marker reference) {
|
||||
if (reference == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"A null value cannot be added to a Marker as reference.");
|
||||
}
|
||||
|
||||
// no point in adding the reference multiple times
|
||||
if (this.contains(reference)) {
|
||||
return;
|
||||
|
||||
} else if (reference.contains(this)) { // avoid recursion
|
||||
// a potential reference should not its future "parent" as a reference
|
||||
return;
|
||||
} else {
|
||||
// let's add the reference
|
||||
if (refereceList == null) {
|
||||
refereceList = new Vector();
|
||||
}
|
||||
refereceList.add(reference);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public synchronized boolean hasReferences() {
|
||||
return ((refereceList != null) && (refereceList.size() > 0));
|
||||
}
|
||||
|
||||
public boolean hasChildren() {
|
||||
return hasReferences();
|
||||
}
|
||||
|
||||
public synchronized Iterator iterator() {
|
||||
if (refereceList != null) {
|
||||
return refereceList.iterator();
|
||||
} else {
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean remove(Marker referenceToRemove) {
|
||||
if (refereceList == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int size = refereceList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
Marker m = (Marker) refereceList.get(i);
|
||||
if (referenceToRemove.equals(m)) {
|
||||
refereceList.remove(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(Marker other) {
|
||||
if (other == null) {
|
||||
throw new IllegalArgumentException("Other cannot be null");
|
||||
}
|
||||
|
||||
if (this.equals(other)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasReferences()) {
|
||||
for (int i = 0; i < refereceList.size(); i++) {
|
||||
Marker ref = (Marker) refereceList.get(i);
|
||||
if (ref.contains(other)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is mainly used with Expression Evaluators.
|
||||
*/
|
||||
public boolean contains(String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Other cannot be null");
|
||||
}
|
||||
|
||||
if (this.name.equals(name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasReferences()) {
|
||||
for (int i = 0; i < refereceList.size(); i++) {
|
||||
Marker ref = (Marker) refereceList.get(i);
|
||||
if (ref.contains(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String OPEN = "[ ";
|
||||
private static String CLOSE = " ]";
|
||||
private static String SEP = ", ";
|
||||
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (!(obj instanceof Marker))
|
||||
return false;
|
||||
|
||||
final Marker other = (Marker) obj;
|
||||
return name.equals(other.getName());
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (!this.hasReferences()) {
|
||||
return this.getName();
|
||||
}
|
||||
Iterator it = this.iterator();
|
||||
Marker reference;
|
||||
StringBuffer sb = new StringBuffer(this.getName());
|
||||
sb.append(' ').append(OPEN);
|
||||
while (it.hasNext()) {
|
||||
reference = (Marker) it.next();
|
||||
sb.append(reference.getName());
|
||||
if (it.hasNext()) {
|
||||
sb.append(SEP);
|
||||
}
|
||||
}
|
||||
sb.append(CLOSE);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Vector;
|
||||
|
||||
import org.slf4j.Marker;
|
||||
|
||||
/**
|
||||
* A simple implementation of the {@link Marker} interface.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author Joern Huxhorn
|
||||
*/
|
||||
public class BasicMarker implements Marker {
|
||||
|
||||
private static final long serialVersionUID = 1803952589649545191L;
|
||||
|
||||
private final String name;
|
||||
private List refereceList;
|
||||
|
||||
BasicMarker(String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("A merker name cannot be null");
|
||||
}
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public synchronized void add(Marker reference) {
|
||||
if (reference == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"A null value cannot be added to a Marker as reference.");
|
||||
}
|
||||
|
||||
// no point in adding the reference multiple times
|
||||
if (this.contains(reference)) {
|
||||
return;
|
||||
|
||||
} else if (reference.contains(this)) { // avoid recursion
|
||||
// a potential reference should not its future "parent" as a reference
|
||||
return;
|
||||
} else {
|
||||
// let's add the reference
|
||||
if (refereceList == null) {
|
||||
refereceList = new Vector();
|
||||
}
|
||||
refereceList.add(reference);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public synchronized boolean hasReferences() {
|
||||
return ((refereceList != null) && (refereceList.size() > 0));
|
||||
}
|
||||
|
||||
public boolean hasChildren() {
|
||||
return hasReferences();
|
||||
}
|
||||
|
||||
public synchronized Iterator iterator() {
|
||||
if (refereceList != null) {
|
||||
return refereceList.iterator();
|
||||
} else {
|
||||
return Collections.EMPTY_LIST.iterator();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean remove(Marker referenceToRemove) {
|
||||
if (refereceList == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int size = refereceList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
Marker m = (Marker) refereceList.get(i);
|
||||
if (referenceToRemove.equals(m)) {
|
||||
refereceList.remove(i);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean contains(Marker other) {
|
||||
if (other == null) {
|
||||
throw new IllegalArgumentException("Other cannot be null");
|
||||
}
|
||||
|
||||
if (this.equals(other)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasReferences()) {
|
||||
for (int i = 0; i < refereceList.size(); i++) {
|
||||
Marker ref = (Marker) refereceList.get(i);
|
||||
if (ref.contains(other)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is mainly used with Expression Evaluators.
|
||||
*/
|
||||
public boolean contains(String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Other cannot be null");
|
||||
}
|
||||
|
||||
if (this.name.equals(name)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (hasReferences()) {
|
||||
for (int i = 0; i < refereceList.size(); i++) {
|
||||
Marker ref = (Marker) refereceList.get(i);
|
||||
if (ref.contains(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String OPEN = "[ ";
|
||||
private static String CLOSE = " ]";
|
||||
private static String SEP = ", ";
|
||||
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (!(obj instanceof Marker))
|
||||
return false;
|
||||
|
||||
final Marker other = (Marker) obj;
|
||||
return name.equals(other.getName());
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
if (!this.hasReferences()) {
|
||||
return this.getName();
|
||||
}
|
||||
Iterator it = this.iterator();
|
||||
Marker reference;
|
||||
StringBuffer sb = new StringBuffer(this.getName());
|
||||
sb.append(' ').append(OPEN);
|
||||
while (it.hasNext()) {
|
||||
reference = (Marker) it.next();
|
||||
sb.append(reference.getName());
|
||||
if (it.hasNext()) {
|
||||
sb.append(SEP);
|
||||
}
|
||||
}
|
||||
sb.append(CLOSE);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,99 +1,99 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.IMarkerFactory;
|
||||
import org.slf4j.Marker;
|
||||
|
||||
/**
|
||||
* An almost trivial implementation of the {@link IMarkerFactory}
|
||||
* interface which creates {@link BasicMarker} instances.
|
||||
*
|
||||
* <p>Simple logging systems can conform to the SLF4J API by binding
|
||||
* {@link org.slf4j.MarkerFactory} with an instance of this class.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class BasicMarkerFactory implements IMarkerFactory {
|
||||
|
||||
Map markerMap = new HashMap();
|
||||
|
||||
/**
|
||||
* Regular users should <em>not</em> create
|
||||
* <code>BasicMarkerFactory</code> instances. <code>Marker</code>
|
||||
* instances can be obtained using the static {@link
|
||||
* org.slf4j.MarkerFactory#getMarker} method.
|
||||
*/
|
||||
public BasicMarkerFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Manufacture a {@link BasicMarker} instance by name. If the instance has been
|
||||
* created earlier, return the previously created instance.
|
||||
*
|
||||
* @param name the name of the marker to be created
|
||||
* @return a Marker instance
|
||||
*/
|
||||
public synchronized Marker getMarker(String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Marker name cannot be null");
|
||||
}
|
||||
|
||||
Marker marker = (Marker) markerMap.get(name);
|
||||
if (marker == null) {
|
||||
marker = new BasicMarker(name);
|
||||
markerMap.put(name, marker);
|
||||
}
|
||||
return marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the name marked already exist?
|
||||
*/
|
||||
public synchronized boolean exists(String name) {
|
||||
if (name == null) {
|
||||
return false;
|
||||
}
|
||||
return markerMap.containsKey(name);
|
||||
}
|
||||
|
||||
public boolean detachMarker(String name) {
|
||||
if(name == null) {
|
||||
return false;
|
||||
}
|
||||
return (markerMap.remove(name) != null);
|
||||
}
|
||||
|
||||
|
||||
public Marker getDetachedMarker(String name) {
|
||||
return new BasicMarker(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.IMarkerFactory;
|
||||
import org.slf4j.Marker;
|
||||
|
||||
/**
|
||||
* An almost trivial implementation of the {@link IMarkerFactory}
|
||||
* interface which creates {@link BasicMarker} instances.
|
||||
*
|
||||
* <p>Simple logging systems can conform to the SLF4J API by binding
|
||||
* {@link org.slf4j.MarkerFactory} with an instance of this class.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class BasicMarkerFactory implements IMarkerFactory {
|
||||
|
||||
Map markerMap = new HashMap();
|
||||
|
||||
/**
|
||||
* Regular users should <em>not</em> create
|
||||
* <code>BasicMarkerFactory</code> instances. <code>Marker</code>
|
||||
* instances can be obtained using the static {@link
|
||||
* org.slf4j.MarkerFactory#getMarker} method.
|
||||
*/
|
||||
public BasicMarkerFactory() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Manufacture a {@link BasicMarker} instance by name. If the instance has been
|
||||
* created earlier, return the previously created instance.
|
||||
*
|
||||
* @param name the name of the marker to be created
|
||||
* @return a Marker instance
|
||||
*/
|
||||
public synchronized Marker getMarker(String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Marker name cannot be null");
|
||||
}
|
||||
|
||||
Marker marker = (Marker) markerMap.get(name);
|
||||
if (marker == null) {
|
||||
marker = new BasicMarker(name);
|
||||
markerMap.put(name, marker);
|
||||
}
|
||||
return marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* Does the name marked already exist?
|
||||
*/
|
||||
public synchronized boolean exists(String name) {
|
||||
if (name == null) {
|
||||
return false;
|
||||
}
|
||||
return markerMap.containsKey(name);
|
||||
}
|
||||
|
||||
public boolean detachMarker(String name) {
|
||||
if(name == null) {
|
||||
return false;
|
||||
}
|
||||
return (markerMap.remove(name) != null);
|
||||
}
|
||||
|
||||
|
||||
public Marker getDetachedMarker(String name) {
|
||||
return new BasicMarker(name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,168 +1,168 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.Marker;
|
||||
|
||||
|
||||
/**
|
||||
* This class serves as base for adapters or native implementations of logging systems
|
||||
* lacking Marker support. In this implementation, methods taking marker data
|
||||
* simply invoke the corresponding method without the Marker argument, discarding
|
||||
* any marker data passed as argument.
|
||||
*
|
||||
* @author Ceki Gulcu
|
||||
*/
|
||||
public abstract class MarkerIgnoringBase extends NamedLoggerBase implements Logger {
|
||||
|
||||
private static final long serialVersionUID = 9044267456635152283L;
|
||||
|
||||
public boolean isTraceEnabled(Marker marker) {
|
||||
return isTraceEnabled();
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String msg) {
|
||||
trace(msg);
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String format, Object arg) {
|
||||
trace(format, arg);
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String format, Object arg1, Object arg2) {
|
||||
trace(format, arg1, arg2);
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String format, Object[] argArray) {
|
||||
trace(format, argArray);
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String msg, Throwable t) {
|
||||
trace(msg, t);
|
||||
}
|
||||
|
||||
public boolean isDebugEnabled(Marker marker) {
|
||||
return isDebugEnabled();
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String msg) {
|
||||
debug(msg);
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String format, Object arg) {
|
||||
debug(format, arg);
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String format, Object arg1, Object arg2) {
|
||||
debug(format, arg1, arg2);
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String format, Object[] argArray) {
|
||||
debug(format, argArray);
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String msg, Throwable t) {
|
||||
debug(msg, t);
|
||||
}
|
||||
|
||||
public boolean isInfoEnabled(Marker marker) {
|
||||
return isInfoEnabled();
|
||||
}
|
||||
|
||||
public void info(Marker marker, String msg) {
|
||||
info(msg);
|
||||
}
|
||||
|
||||
public void info(Marker marker, String format, Object arg) {
|
||||
info(format, arg);
|
||||
}
|
||||
|
||||
public void info(Marker marker, String format, Object arg1, Object arg2) {
|
||||
info(format, arg1, arg2);
|
||||
}
|
||||
|
||||
public void info(Marker marker, String format, Object[] argArray) {
|
||||
info(format, argArray);
|
||||
}
|
||||
|
||||
public void info(Marker marker, String msg, Throwable t) {
|
||||
info(msg, t);
|
||||
}
|
||||
|
||||
public boolean isWarnEnabled(Marker marker) {
|
||||
return isWarnEnabled();
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String msg) {
|
||||
warn(msg);
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String format, Object arg) {
|
||||
warn(format, arg);
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String format, Object arg1, Object arg2) {
|
||||
warn(format, arg1, arg2);
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String format, Object[] argArray) {
|
||||
warn(format, argArray);
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String msg, Throwable t) {
|
||||
warn(msg, t);
|
||||
}
|
||||
|
||||
|
||||
public boolean isErrorEnabled(Marker marker) {
|
||||
return isErrorEnabled();
|
||||
}
|
||||
|
||||
public void error(Marker marker, String msg) {
|
||||
error(msg);
|
||||
}
|
||||
|
||||
public void error(Marker marker, String format, Object arg) {
|
||||
error(format, arg);
|
||||
}
|
||||
|
||||
public void error(Marker marker, String format, Object arg1, Object arg2) {
|
||||
error(format, arg1, arg2);
|
||||
}
|
||||
|
||||
public void error(Marker marker, String format, Object[] argArray) {
|
||||
error(format, argArray);
|
||||
}
|
||||
|
||||
public void error(Marker marker, String msg, Throwable t) {
|
||||
error(msg, t);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.getClass().getName()+"("+getName()+")";
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.Marker;
|
||||
|
||||
|
||||
/**
|
||||
* This class serves as base for adapters or native implementations of logging systems
|
||||
* lacking Marker support. In this implementation, methods taking marker data
|
||||
* simply invoke the corresponding method without the Marker argument, discarding
|
||||
* any marker data passed as argument.
|
||||
*
|
||||
* @author Ceki Gulcu
|
||||
*/
|
||||
public abstract class MarkerIgnoringBase extends NamedLoggerBase implements Logger {
|
||||
|
||||
private static final long serialVersionUID = 9044267456635152283L;
|
||||
|
||||
public boolean isTraceEnabled(Marker marker) {
|
||||
return isTraceEnabled();
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String msg) {
|
||||
trace(msg);
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String format, Object arg) {
|
||||
trace(format, arg);
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String format, Object arg1, Object arg2) {
|
||||
trace(format, arg1, arg2);
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String format, Object[] argArray) {
|
||||
trace(format, argArray);
|
||||
}
|
||||
|
||||
public void trace(Marker marker, String msg, Throwable t) {
|
||||
trace(msg, t);
|
||||
}
|
||||
|
||||
public boolean isDebugEnabled(Marker marker) {
|
||||
return isDebugEnabled();
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String msg) {
|
||||
debug(msg);
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String format, Object arg) {
|
||||
debug(format, arg);
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String format, Object arg1, Object arg2) {
|
||||
debug(format, arg1, arg2);
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String format, Object[] argArray) {
|
||||
debug(format, argArray);
|
||||
}
|
||||
|
||||
public void debug(Marker marker, String msg, Throwable t) {
|
||||
debug(msg, t);
|
||||
}
|
||||
|
||||
public boolean isInfoEnabled(Marker marker) {
|
||||
return isInfoEnabled();
|
||||
}
|
||||
|
||||
public void info(Marker marker, String msg) {
|
||||
info(msg);
|
||||
}
|
||||
|
||||
public void info(Marker marker, String format, Object arg) {
|
||||
info(format, arg);
|
||||
}
|
||||
|
||||
public void info(Marker marker, String format, Object arg1, Object arg2) {
|
||||
info(format, arg1, arg2);
|
||||
}
|
||||
|
||||
public void info(Marker marker, String format, Object[] argArray) {
|
||||
info(format, argArray);
|
||||
}
|
||||
|
||||
public void info(Marker marker, String msg, Throwable t) {
|
||||
info(msg, t);
|
||||
}
|
||||
|
||||
public boolean isWarnEnabled(Marker marker) {
|
||||
return isWarnEnabled();
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String msg) {
|
||||
warn(msg);
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String format, Object arg) {
|
||||
warn(format, arg);
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String format, Object arg1, Object arg2) {
|
||||
warn(format, arg1, arg2);
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String format, Object[] argArray) {
|
||||
warn(format, argArray);
|
||||
}
|
||||
|
||||
public void warn(Marker marker, String msg, Throwable t) {
|
||||
warn(msg, t);
|
||||
}
|
||||
|
||||
|
||||
public boolean isErrorEnabled(Marker marker) {
|
||||
return isErrorEnabled();
|
||||
}
|
||||
|
||||
public void error(Marker marker, String msg) {
|
||||
error(msg);
|
||||
}
|
||||
|
||||
public void error(Marker marker, String format, Object arg) {
|
||||
error(format, arg);
|
||||
}
|
||||
|
||||
public void error(Marker marker, String format, Object arg1, Object arg2) {
|
||||
error(format, arg1, arg2);
|
||||
}
|
||||
|
||||
public void error(Marker marker, String format, Object[] argArray) {
|
||||
error(format, argArray);
|
||||
}
|
||||
|
||||
public void error(Marker marker, String msg, Throwable t) {
|
||||
error(msg, t);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.getClass().getName()+"("+getName()+")";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,394 +1,394 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
// contributors: lizongbo: proposed special treatment of array parameter values
|
||||
// Jörn Huxhorn: pointed out double[] omission, suggested deep array copy
|
||||
/**
|
||||
* Formats messages according to very simple substitution rules. Substitutions
|
||||
* can be made 1, 2 or more arguments.
|
||||
*
|
||||
* <p>
|
||||
* For example,
|
||||
*
|
||||
* <pre>
|
||||
* MessageFormatter.format("Hi {}.", "there")
|
||||
* </pre>
|
||||
*
|
||||
* will return the string "Hi there.".
|
||||
* <p>
|
||||
* The {} pair is called the <em>formatting anchor</em>. It serves to designate
|
||||
* the location where arguments need to be substituted within the message
|
||||
* pattern.
|
||||
* <p>
|
||||
* In case your message contains the '{' or the '}' character, you do not have
|
||||
* to do anything special unless the '}' character immediately follows '{'. For
|
||||
* example,
|
||||
*
|
||||
* <pre>
|
||||
* MessageFormatter.format("Set {1,2,3} is not equal to {}.", "1,2");
|
||||
* </pre>
|
||||
*
|
||||
* will return the string "Set {1,2,3} is not equal to 1,2.".
|
||||
*
|
||||
* <p>
|
||||
* If for whatever reason you need to place the string "{}" in the message
|
||||
* without its <em>formatting anchor</em> meaning, then you need to escape the
|
||||
* '{' character with '\', that is the backslash character. Only the '{'
|
||||
* character should be escaped. There is no need to escape the '}' character.
|
||||
* For example,
|
||||
*
|
||||
* <pre>MessageFormatter.format("Set \\{} is not equal to {}.", "1,2");</pre>
|
||||
*
|
||||
* will return the string "Set {} is not equal to 1,2.".
|
||||
*
|
||||
* <p>
|
||||
* The escaping behavior just described can be overridden by escaping the escape
|
||||
* character '\'. Calling
|
||||
* <pre>
|
||||
* MessageFormatter.format("File name is C:\\\\{}.", "file.zip");
|
||||
* </pre>
|
||||
*
|
||||
* will return the string "File name is C:\file.zip".
|
||||
*
|
||||
* <p>
|
||||
* The formatting conventions are different than those of {@link MessageFormat}
|
||||
* which ships with the Java platform. This is justified by the fact that
|
||||
* SLF4J's implementation is 10 times faster than that of {@link MessageFormat}.
|
||||
* This local performance difference is both measurable and significant in the
|
||||
* larger context of the complete logging processing chain.
|
||||
*
|
||||
* <p>
|
||||
* See also {@link #format(String, Object)},
|
||||
* {@link #format(String, Object, Object)} and
|
||||
* {@link #arrayFormat(String, Object[])} methods for more details.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
final public class MessageFormatter {
|
||||
static final char DELIM_START = '{';
|
||||
static final char DELIM_STOP = '}';
|
||||
static final String DELIM_STR = "{}";
|
||||
private static final char ESCAPE_CHAR = '\\';
|
||||
|
||||
/**
|
||||
* Performs single argument substitution for the 'messagePattern' passed as
|
||||
* parameter.
|
||||
* <p>
|
||||
* For example,
|
||||
*
|
||||
* <pre>
|
||||
* MessageFormatter.format("Hi {}.", "there");
|
||||
* </pre>
|
||||
*
|
||||
* will return the string "Hi there.".
|
||||
* <p>
|
||||
*
|
||||
* @param messagePattern
|
||||
* The message pattern which will be parsed and formatted
|
||||
* @param argument
|
||||
* The argument to be substituted in place of the formatting anchor
|
||||
* @return The formatted message
|
||||
*/
|
||||
final public static String format(String messagePattern, Object arg) {
|
||||
return arrayFormat(messagePattern, new Object[] { arg });
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Performs a two argument substitution for the 'messagePattern' passed as
|
||||
* parameter.
|
||||
* <p>
|
||||
* For example,
|
||||
*
|
||||
* <pre>
|
||||
* MessageFormatter.format("Hi {}. My name is {}.", "Alice", "Bob");
|
||||
* </pre>
|
||||
*
|
||||
* will return the string "Hi Alice. My name is Bob.".
|
||||
*
|
||||
* @param messagePattern
|
||||
* The message pattern which will be parsed and formatted
|
||||
* @param arg1
|
||||
* The argument to be substituted in place of the first formatting
|
||||
* anchor
|
||||
* @param arg2
|
||||
* The argument to be substituted in place of the second formatting
|
||||
* anchor
|
||||
* @return The formatted message
|
||||
*/
|
||||
final public static String format(final String messagePattern, Object arg1,
|
||||
Object arg2) {
|
||||
return arrayFormat(messagePattern, new Object[] { arg1, arg2 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Same principle as the {@link #format(String, Object)} and
|
||||
* {@link #format(String, Object, Object)} methods except that any number of
|
||||
* arguments can be passed in an array.
|
||||
*
|
||||
* @param messagePattern
|
||||
* The message pattern which will be parsed and formatted
|
||||
* @param argArray
|
||||
* An array of arguments to be substituted in place of formatting
|
||||
* anchors
|
||||
* @return The formatted message
|
||||
*/
|
||||
final public static String arrayFormat(final String messagePattern,
|
||||
final Object[] argArray) {
|
||||
if (messagePattern == null) {
|
||||
return null;
|
||||
}
|
||||
if (argArray == null) {
|
||||
return messagePattern;
|
||||
}
|
||||
int i = 0;
|
||||
int j;
|
||||
StringBuffer sbuf = new StringBuffer(messagePattern.length() + 50);
|
||||
|
||||
for (int L = 0; L < argArray.length; L++) {
|
||||
|
||||
j = messagePattern.indexOf(DELIM_STR, i);
|
||||
|
||||
if (j == -1) {
|
||||
// no more variables
|
||||
if (i == 0) { // this is a simple string
|
||||
return messagePattern;
|
||||
} else { // add the tail string which contains no variables and return
|
||||
// the result.
|
||||
sbuf.append(messagePattern.substring(i, messagePattern.length()));
|
||||
return sbuf.toString();
|
||||
}
|
||||
} else {
|
||||
if (isEscapedDelimeter(messagePattern, j)) {
|
||||
if (!isDoubleEscaped(messagePattern, j)) {
|
||||
L--; // DELIM_START was escaped, thus should not be incremented
|
||||
sbuf.append(messagePattern.substring(i, j - 1));
|
||||
sbuf.append(DELIM_START);
|
||||
i = j + 1;
|
||||
} else {
|
||||
// The escape character preceding the delimiter start is
|
||||
// itself escaped: "abc x:\\{}"
|
||||
// we have to consume one backward slash
|
||||
sbuf.append(messagePattern.substring(i, j - 1));
|
||||
deeplyAppendParameter(sbuf, argArray[L], new HashMap());
|
||||
i = j + 2;
|
||||
}
|
||||
} else {
|
||||
// normal case
|
||||
sbuf.append(messagePattern.substring(i, j));
|
||||
deeplyAppendParameter(sbuf, argArray[L], new HashMap());
|
||||
i = j + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
// append the characters following the last {} pair.
|
||||
sbuf.append(messagePattern.substring(i, messagePattern.length()));
|
||||
return sbuf.toString();
|
||||
}
|
||||
|
||||
final static boolean isEscapedDelimeter(String messagePattern,
|
||||
int delimeterStartIndex) {
|
||||
|
||||
if (delimeterStartIndex == 0) {
|
||||
return false;
|
||||
}
|
||||
char potentialEscape = messagePattern.charAt(delimeterStartIndex - 1);
|
||||
if (potentialEscape == ESCAPE_CHAR) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final static boolean isDoubleEscaped(String messagePattern,
|
||||
int delimeterStartIndex) {
|
||||
if (delimeterStartIndex >= 2
|
||||
&& messagePattern.charAt(delimeterStartIndex - 2) == ESCAPE_CHAR) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// special treatment of array values was suggested by 'lizongbo'
|
||||
private static void deeplyAppendParameter(StringBuffer sbuf, Object o,
|
||||
Map seenMap) {
|
||||
if (o == null) {
|
||||
sbuf.append("null");
|
||||
return;
|
||||
}
|
||||
if (!o.getClass().isArray()) {
|
||||
safeObjectAppend(sbuf, o);
|
||||
} else {
|
||||
// check for primitive array types because they
|
||||
// unfortunately cannot be cast to Object[]
|
||||
if (o instanceof boolean[]) {
|
||||
booleanArrayAppend(sbuf, (boolean[]) o);
|
||||
} else if (o instanceof byte[]) {
|
||||
byteArrayAppend(sbuf, (byte[]) o);
|
||||
} else if (o instanceof char[]) {
|
||||
charArrayAppend(sbuf, (char[]) o);
|
||||
} else if (o instanceof short[]) {
|
||||
shortArrayAppend(sbuf, (short[]) o);
|
||||
} else if (o instanceof int[]) {
|
||||
intArrayAppend(sbuf, (int[]) o);
|
||||
} else if (o instanceof long[]) {
|
||||
longArrayAppend(sbuf, (long[]) o);
|
||||
} else if (o instanceof float[]) {
|
||||
floatArrayAppend(sbuf, (float[]) o);
|
||||
} else if (o instanceof double[]) {
|
||||
doubleArrayAppend(sbuf, (double[]) o);
|
||||
} else {
|
||||
objectArrayAppend(sbuf, (Object[]) o, seenMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void safeObjectAppend(StringBuffer sbuf, Object o) {
|
||||
try {
|
||||
String oAsString = o.toString();
|
||||
sbuf.append(oAsString);
|
||||
} catch (Throwable t) {
|
||||
System.err
|
||||
.println("SLF4J: Failed toString() invocation on an object of type ["
|
||||
+ o.getClass().getName() + "]");
|
||||
t.printStackTrace();
|
||||
sbuf.append("[FAILED toString()]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void objectArrayAppend(StringBuffer sbuf, Object[] a,
|
||||
Map seenMap) {
|
||||
sbuf.append('[');
|
||||
if (!seenMap.containsKey(a)) {
|
||||
seenMap.put(a, null);
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
deeplyAppendParameter(sbuf, a[i], seenMap);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
// allow repeats in siblings
|
||||
seenMap.remove(a);
|
||||
} else {
|
||||
sbuf.append("...");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void booleanArrayAppend(StringBuffer sbuf, boolean[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void byteArrayAppend(StringBuffer sbuf, byte[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void charArrayAppend(StringBuffer sbuf, char[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void shortArrayAppend(StringBuffer sbuf, short[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void intArrayAppend(StringBuffer sbuf, int[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void longArrayAppend(StringBuffer sbuf, long[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void floatArrayAppend(StringBuffer sbuf, float[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void doubleArrayAppend(StringBuffer sbuf, double[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
// contributors: lizongbo: proposed special treatment of array parameter values
|
||||
// Jörn Huxhorn: pointed out double[] omission, suggested deep array copy
|
||||
/**
|
||||
* Formats messages according to very simple substitution rules. Substitutions
|
||||
* can be made 1, 2 or more arguments.
|
||||
*
|
||||
* <p>
|
||||
* For example,
|
||||
*
|
||||
* <pre>
|
||||
* MessageFormatter.format("Hi {}.", "there")
|
||||
* </pre>
|
||||
*
|
||||
* will return the string "Hi there.".
|
||||
* <p>
|
||||
* The {} pair is called the <em>formatting anchor</em>. It serves to designate
|
||||
* the location where arguments need to be substituted within the message
|
||||
* pattern.
|
||||
* <p>
|
||||
* In case your message contains the '{' or the '}' character, you do not have
|
||||
* to do anything special unless the '}' character immediately follows '{'. For
|
||||
* example,
|
||||
*
|
||||
* <pre>
|
||||
* MessageFormatter.format("Set {1,2,3} is not equal to {}.", "1,2");
|
||||
* </pre>
|
||||
*
|
||||
* will return the string "Set {1,2,3} is not equal to 1,2.".
|
||||
*
|
||||
* <p>
|
||||
* If for whatever reason you need to place the string "{}" in the message
|
||||
* without its <em>formatting anchor</em> meaning, then you need to escape the
|
||||
* '{' character with '\', that is the backslash character. Only the '{'
|
||||
* character should be escaped. There is no need to escape the '}' character.
|
||||
* For example,
|
||||
*
|
||||
* <pre>MessageFormatter.format("Set \\{} is not equal to {}.", "1,2");</pre>
|
||||
*
|
||||
* will return the string "Set {} is not equal to 1,2.".
|
||||
*
|
||||
* <p>
|
||||
* The escaping behavior just described can be overridden by escaping the escape
|
||||
* character '\'. Calling
|
||||
* <pre>
|
||||
* MessageFormatter.format("File name is C:\\\\{}.", "file.zip");
|
||||
* </pre>
|
||||
*
|
||||
* will return the string "File name is C:\file.zip".
|
||||
*
|
||||
* <p>
|
||||
* The formatting conventions are different than those of {@link MessageFormat}
|
||||
* which ships with the Java platform. This is justified by the fact that
|
||||
* SLF4J's implementation is 10 times faster than that of {@link MessageFormat}.
|
||||
* This local performance difference is both measurable and significant in the
|
||||
* larger context of the complete logging processing chain.
|
||||
*
|
||||
* <p>
|
||||
* See also {@link #format(String, Object)},
|
||||
* {@link #format(String, Object, Object)} and
|
||||
* {@link #arrayFormat(String, Object[])} methods for more details.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
final public class MessageFormatter {
|
||||
static final char DELIM_START = '{';
|
||||
static final char DELIM_STOP = '}';
|
||||
static final String DELIM_STR = "{}";
|
||||
private static final char ESCAPE_CHAR = '\\';
|
||||
|
||||
/**
|
||||
* Performs single argument substitution for the 'messagePattern' passed as
|
||||
* parameter.
|
||||
* <p>
|
||||
* For example,
|
||||
*
|
||||
* <pre>
|
||||
* MessageFormatter.format("Hi {}.", "there");
|
||||
* </pre>
|
||||
*
|
||||
* will return the string "Hi there.".
|
||||
* <p>
|
||||
*
|
||||
* @param messagePattern
|
||||
* The message pattern which will be parsed and formatted
|
||||
* @param argument
|
||||
* The argument to be substituted in place of the formatting anchor
|
||||
* @return The formatted message
|
||||
*/
|
||||
final public static String format(String messagePattern, Object arg) {
|
||||
return arrayFormat(messagePattern, new Object[] { arg });
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Performs a two argument substitution for the 'messagePattern' passed as
|
||||
* parameter.
|
||||
* <p>
|
||||
* For example,
|
||||
*
|
||||
* <pre>
|
||||
* MessageFormatter.format("Hi {}. My name is {}.", "Alice", "Bob");
|
||||
* </pre>
|
||||
*
|
||||
* will return the string "Hi Alice. My name is Bob.".
|
||||
*
|
||||
* @param messagePattern
|
||||
* The message pattern which will be parsed and formatted
|
||||
* @param arg1
|
||||
* The argument to be substituted in place of the first formatting
|
||||
* anchor
|
||||
* @param arg2
|
||||
* The argument to be substituted in place of the second formatting
|
||||
* anchor
|
||||
* @return The formatted message
|
||||
*/
|
||||
final public static String format(final String messagePattern, Object arg1,
|
||||
Object arg2) {
|
||||
return arrayFormat(messagePattern, new Object[] { arg1, arg2 });
|
||||
}
|
||||
|
||||
/**
|
||||
* Same principle as the {@link #format(String, Object)} and
|
||||
* {@link #format(String, Object, Object)} methods except that any number of
|
||||
* arguments can be passed in an array.
|
||||
*
|
||||
* @param messagePattern
|
||||
* The message pattern which will be parsed and formatted
|
||||
* @param argArray
|
||||
* An array of arguments to be substituted in place of formatting
|
||||
* anchors
|
||||
* @return The formatted message
|
||||
*/
|
||||
final public static String arrayFormat(final String messagePattern,
|
||||
final Object[] argArray) {
|
||||
if (messagePattern == null) {
|
||||
return null;
|
||||
}
|
||||
if (argArray == null) {
|
||||
return messagePattern;
|
||||
}
|
||||
int i = 0;
|
||||
int j;
|
||||
StringBuffer sbuf = new StringBuffer(messagePattern.length() + 50);
|
||||
|
||||
for (int L = 0; L < argArray.length; L++) {
|
||||
|
||||
j = messagePattern.indexOf(DELIM_STR, i);
|
||||
|
||||
if (j == -1) {
|
||||
// no more variables
|
||||
if (i == 0) { // this is a simple string
|
||||
return messagePattern;
|
||||
} else { // add the tail string which contains no variables and return
|
||||
// the result.
|
||||
sbuf.append(messagePattern.substring(i, messagePattern.length()));
|
||||
return sbuf.toString();
|
||||
}
|
||||
} else {
|
||||
if (isEscapedDelimeter(messagePattern, j)) {
|
||||
if (!isDoubleEscaped(messagePattern, j)) {
|
||||
L--; // DELIM_START was escaped, thus should not be incremented
|
||||
sbuf.append(messagePattern.substring(i, j - 1));
|
||||
sbuf.append(DELIM_START);
|
||||
i = j + 1;
|
||||
} else {
|
||||
// The escape character preceding the delimiter start is
|
||||
// itself escaped: "abc x:\\{}"
|
||||
// we have to consume one backward slash
|
||||
sbuf.append(messagePattern.substring(i, j - 1));
|
||||
deeplyAppendParameter(sbuf, argArray[L], new HashMap());
|
||||
i = j + 2;
|
||||
}
|
||||
} else {
|
||||
// normal case
|
||||
sbuf.append(messagePattern.substring(i, j));
|
||||
deeplyAppendParameter(sbuf, argArray[L], new HashMap());
|
||||
i = j + 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
// append the characters following the last {} pair.
|
||||
sbuf.append(messagePattern.substring(i, messagePattern.length()));
|
||||
return sbuf.toString();
|
||||
}
|
||||
|
||||
final static boolean isEscapedDelimeter(String messagePattern,
|
||||
int delimeterStartIndex) {
|
||||
|
||||
if (delimeterStartIndex == 0) {
|
||||
return false;
|
||||
}
|
||||
char potentialEscape = messagePattern.charAt(delimeterStartIndex - 1);
|
||||
if (potentialEscape == ESCAPE_CHAR) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
final static boolean isDoubleEscaped(String messagePattern,
|
||||
int delimeterStartIndex) {
|
||||
if (delimeterStartIndex >= 2
|
||||
&& messagePattern.charAt(delimeterStartIndex - 2) == ESCAPE_CHAR) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// special treatment of array values was suggested by 'lizongbo'
|
||||
private static void deeplyAppendParameter(StringBuffer sbuf, Object o,
|
||||
Map seenMap) {
|
||||
if (o == null) {
|
||||
sbuf.append("null");
|
||||
return;
|
||||
}
|
||||
if (!o.getClass().isArray()) {
|
||||
safeObjectAppend(sbuf, o);
|
||||
} else {
|
||||
// check for primitive array types because they
|
||||
// unfortunately cannot be cast to Object[]
|
||||
if (o instanceof boolean[]) {
|
||||
booleanArrayAppend(sbuf, (boolean[]) o);
|
||||
} else if (o instanceof byte[]) {
|
||||
byteArrayAppend(sbuf, (byte[]) o);
|
||||
} else if (o instanceof char[]) {
|
||||
charArrayAppend(sbuf, (char[]) o);
|
||||
} else if (o instanceof short[]) {
|
||||
shortArrayAppend(sbuf, (short[]) o);
|
||||
} else if (o instanceof int[]) {
|
||||
intArrayAppend(sbuf, (int[]) o);
|
||||
} else if (o instanceof long[]) {
|
||||
longArrayAppend(sbuf, (long[]) o);
|
||||
} else if (o instanceof float[]) {
|
||||
floatArrayAppend(sbuf, (float[]) o);
|
||||
} else if (o instanceof double[]) {
|
||||
doubleArrayAppend(sbuf, (double[]) o);
|
||||
} else {
|
||||
objectArrayAppend(sbuf, (Object[]) o, seenMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void safeObjectAppend(StringBuffer sbuf, Object o) {
|
||||
try {
|
||||
String oAsString = o.toString();
|
||||
sbuf.append(oAsString);
|
||||
} catch (Throwable t) {
|
||||
System.err
|
||||
.println("SLF4J: Failed toString() invocation on an object of type ["
|
||||
+ o.getClass().getName() + "]");
|
||||
t.printStackTrace();
|
||||
sbuf.append("[FAILED toString()]");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void objectArrayAppend(StringBuffer sbuf, Object[] a,
|
||||
Map seenMap) {
|
||||
sbuf.append('[');
|
||||
if (!seenMap.containsKey(a)) {
|
||||
seenMap.put(a, null);
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
deeplyAppendParameter(sbuf, a[i], seenMap);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
// allow repeats in siblings
|
||||
seenMap.remove(a);
|
||||
} else {
|
||||
sbuf.append("...");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void booleanArrayAppend(StringBuffer sbuf, boolean[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void byteArrayAppend(StringBuffer sbuf, byte[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void charArrayAppend(StringBuffer sbuf, char[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void shortArrayAppend(StringBuffer sbuf, short[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void intArrayAppend(StringBuffer sbuf, int[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void longArrayAppend(StringBuffer sbuf, long[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void floatArrayAppend(StringBuffer sbuf, float[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
|
||||
private static void doubleArrayAppend(StringBuffer sbuf, double[] a) {
|
||||
sbuf.append('[');
|
||||
final int len = a.length;
|
||||
for (int i = 0; i < len; i++) {
|
||||
sbuf.append(a[i]);
|
||||
if (i != len - 1)
|
||||
sbuf.append(", ");
|
||||
}
|
||||
sbuf.append(']');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,238 +1,238 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2005 SLF4J.ORG
|
||||
* Copyright (c) 2004-2005 QOS.ch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.helpers.MarkerIgnoringBase;
|
||||
|
||||
|
||||
/**
|
||||
* A direct NOP (no operation) implementation of {@link Logger}.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class NOPLogger extends MarkerIgnoringBase {
|
||||
|
||||
private static final long serialVersionUID = -517220405410904473L;
|
||||
|
||||
/**
|
||||
* The unique instance of NOPLogger.
|
||||
*/
|
||||
public static final NOPLogger NOP_LOGGER = new NOPLogger();
|
||||
|
||||
/**
|
||||
* There is no point in creating multiple instances of NOPLOgger,
|
||||
* except by derived classes, hence the protected access for the constructor.
|
||||
*/
|
||||
protected NOPLogger() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns the string value "NOP".
|
||||
*/
|
||||
public String getName() {
|
||||
return "NOP";
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns false.
|
||||
* @return always false
|
||||
*/
|
||||
final public boolean isTraceEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void trace(String msg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void trace(String format, Object arg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void trace(String format, Object arg1, Object arg2) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void trace(String format, Object[] argArray) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void trace(String msg, Throwable t) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns false.
|
||||
* @return always false
|
||||
*/
|
||||
final public boolean isDebugEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void debug(String msg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void debug(String format, Object arg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void debug(String format, Object arg1, Object arg2) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void debug(String format, Object[] argArray) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void debug(String msg, Throwable t) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns false.
|
||||
* @return always false
|
||||
*/
|
||||
final public boolean isInfoEnabled() {
|
||||
// NOP
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void info(String msg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void info(String format, Object arg1) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void info(String format, Object arg1, Object arg2) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void info(String format, Object[] argArray) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void info(String msg, Throwable t) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Always returns false.
|
||||
* @return always false
|
||||
*/
|
||||
final public boolean isWarnEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void warn(String msg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void warn(String format, Object arg1) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void warn(String format, Object arg1, Object arg2) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void warn(String format, Object[] argArray) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void warn(String msg, Throwable t) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public boolean isErrorEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void error(String msg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void error(String format, Object arg1) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void error(String format, Object arg1, Object arg2) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void error(String format, Object[] argArray) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void error(String msg, Throwable t) {
|
||||
// NOP
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2005 SLF4J.ORG
|
||||
* Copyright (c) 2004-2005 QOS.ch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.helpers.MarkerIgnoringBase;
|
||||
|
||||
|
||||
/**
|
||||
* A direct NOP (no operation) implementation of {@link Logger}.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class NOPLogger extends MarkerIgnoringBase {
|
||||
|
||||
private static final long serialVersionUID = -517220405410904473L;
|
||||
|
||||
/**
|
||||
* The unique instance of NOPLogger.
|
||||
*/
|
||||
public static final NOPLogger NOP_LOGGER = new NOPLogger();
|
||||
|
||||
/**
|
||||
* There is no point in creating multiple instances of NOPLOgger,
|
||||
* except by derived classes, hence the protected access for the constructor.
|
||||
*/
|
||||
protected NOPLogger() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns the string value "NOP".
|
||||
*/
|
||||
public String getName() {
|
||||
return "NOP";
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns false.
|
||||
* @return always false
|
||||
*/
|
||||
final public boolean isTraceEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void trace(String msg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void trace(String format, Object arg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void trace(String format, Object arg1, Object arg2) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void trace(String format, Object[] argArray) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void trace(String msg, Throwable t) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns false.
|
||||
* @return always false
|
||||
*/
|
||||
final public boolean isDebugEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void debug(String msg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void debug(String format, Object arg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void debug(String format, Object arg1, Object arg2) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void debug(String format, Object[] argArray) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void debug(String msg, Throwable t) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/**
|
||||
* Always returns false.
|
||||
* @return always false
|
||||
*/
|
||||
final public boolean isInfoEnabled() {
|
||||
// NOP
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void info(String msg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void info(String format, Object arg1) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void info(String format, Object arg1, Object arg2) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void info(String format, Object[] argArray) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void info(String msg, Throwable t) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Always returns false.
|
||||
* @return always false
|
||||
*/
|
||||
final public boolean isWarnEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void warn(String msg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void warn(String format, Object arg1) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void warn(String format, Object arg1, Object arg2) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void warn(String format, Object[] argArray) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void warn(String msg, Throwable t) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public boolean isErrorEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void error(String msg) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void error(String format, Object arg1) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void error(String format, Object arg1, Object arg2) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
/** A NOP implementation. */
|
||||
public final void error(String format, Object[] argArray) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
|
||||
/** A NOP implementation. */
|
||||
final public void error(String msg, Throwable t) {
|
||||
// NOP
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,39 +1,39 @@
|
|||
package org.slf4j.helpers;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.spi.MDCAdapter;
|
||||
|
||||
/**
|
||||
* This adapter is an empty implementation of the {@link MDCAdapter} interface.
|
||||
* It is used for all logging systems which do not support mapped
|
||||
* diagnostic contexts such as JDK14, simple and NOP.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*
|
||||
* @since 1.4.1
|
||||
*/
|
||||
public class NOPMakerAdapter implements MDCAdapter {
|
||||
|
||||
public void clear() {
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void put(String key, String val) {
|
||||
}
|
||||
|
||||
public void remove(String key) {
|
||||
}
|
||||
|
||||
public Map getCopyOfContextMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setContextMap(Map contextMap) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
}
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.slf4j.spi.MDCAdapter;
|
||||
|
||||
/**
|
||||
* This adapter is an empty implementation of the {@link MDCAdapter} interface.
|
||||
* It is used for all logging systems which do not support mapped
|
||||
* diagnostic contexts such as JDK14, simple and NOP.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*
|
||||
* @since 1.4.1
|
||||
*/
|
||||
public class NOPMakerAdapter implements MDCAdapter {
|
||||
|
||||
public void clear() {
|
||||
}
|
||||
|
||||
public String get(String key) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void put(String key, String val) {
|
||||
}
|
||||
|
||||
public void remove(String key) {
|
||||
}
|
||||
|
||||
public Map getCopyOfContextMap() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setContextMap(Map contextMap) {
|
||||
// NOP
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,46 +1,46 @@
|
|||
package org.slf4j.helpers;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Serves as base class for named logger implementation. More significantly, this
|
||||
* class establishes deserialization behavior. See @see #readResolve.
|
||||
*
|
||||
* @author Ceki Gulcu
|
||||
* @since 1.5.3
|
||||
*/
|
||||
abstract class NamedLoggerBase implements Logger, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7535258609338176893L;
|
||||
|
||||
protected String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace this instance with a homonymous (same name) logger returned
|
||||
* by LoggerFactory. Note that this method is only called during
|
||||
* deserialization.
|
||||
*
|
||||
* <p>
|
||||
* This approach will work well if the desired ILoggerFactory is the one
|
||||
* references by LoggerFactory. However, if the user manages its logger hierarchy
|
||||
* through a different (non-static) mechanism, e.g. dependency injection, then
|
||||
* this approach would be mostly counterproductive.
|
||||
*
|
||||
* @return logger with same name as returned by LoggerFactory
|
||||
* @throws ObjectStreamException
|
||||
*/
|
||||
protected Object readResolve() throws ObjectStreamException {
|
||||
// using getName() instead of this.name works even for
|
||||
// NOPLogger
|
||||
return LoggerFactory.getLogger(getName());
|
||||
}
|
||||
|
||||
}
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import java.io.ObjectStreamException;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Serves as base class for named logger implementation. More significantly, this
|
||||
* class establishes deserialization behavior. See @see #readResolve.
|
||||
*
|
||||
* @author Ceki Gulcu
|
||||
* @since 1.5.3
|
||||
*/
|
||||
abstract class NamedLoggerBase implements Logger, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 7535258609338176893L;
|
||||
|
||||
protected String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace this instance with a homonymous (same name) logger returned
|
||||
* by LoggerFactory. Note that this method is only called during
|
||||
* deserialization.
|
||||
*
|
||||
* <p>
|
||||
* This approach will work well if the desired ILoggerFactory is the one
|
||||
* references by LoggerFactory. However, if the user manages its logger hierarchy
|
||||
* through a different (non-static) mechanism, e.g. dependency injection, then
|
||||
* this approach would be mostly counterproductive.
|
||||
*
|
||||
* @return logger with same name as returned by LoggerFactory
|
||||
* @throws ObjectStreamException
|
||||
*/
|
||||
protected Object readResolve() throws ObjectStreamException {
|
||||
// using getName() instead of this.name works even for
|
||||
// NOPLogger
|
||||
return LoggerFactory.getLogger(getName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,67 +1,67 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2005 SLF4J.ORG
|
||||
* Copyright (c) 2004-2005 QOS.ch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.ILoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
* SubstituteLoggerFactory is an trivial implementation of {@link
|
||||
* ILoggerFactory} which always returns the unique instance of NOPLogger.
|
||||
*
|
||||
* <p>
|
||||
* It used as a temporary substitute for the real ILoggerFactory during its
|
||||
* auto-configuration which may re-enter LoggerFactory to obtain logger
|
||||
* instances. See also http://bugzilla.slf4j.org/show_bug.cgi?id=106
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class SubstituteLoggerFactory implements ILoggerFactory {
|
||||
|
||||
// keep a record of requested logger names
|
||||
final List loggerNameList = new ArrayList();
|
||||
|
||||
public Logger getLogger(String name) {
|
||||
loggerNameList.add(name);
|
||||
return NOPLogger.NOP_LOGGER;
|
||||
}
|
||||
|
||||
public List getLoggerNameList() {
|
||||
return loggerNameList;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2005 SLF4J.ORG
|
||||
* Copyright (c) 2004-2005 QOS.ch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.ILoggerFactory;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
/**
|
||||
* SubstituteLoggerFactory is an trivial implementation of {@link
|
||||
* ILoggerFactory} which always returns the unique instance of NOPLogger.
|
||||
*
|
||||
* <p>
|
||||
* It used as a temporary substitute for the real ILoggerFactory during its
|
||||
* auto-configuration which may re-enter LoggerFactory to obtain logger
|
||||
* instances. See also http://bugzilla.slf4j.org/show_bug.cgi?id=106
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class SubstituteLoggerFactory implements ILoggerFactory {
|
||||
|
||||
// keep a record of requested logger names
|
||||
final List loggerNameList = new ArrayList();
|
||||
|
||||
public Logger getLogger(String name) {
|
||||
loggerNameList.add(name);
|
||||
return NOPLogger.NOP_LOGGER;
|
||||
}
|
||||
|
||||
public List getLoggerNameList() {
|
||||
return loggerNameList;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,45 +1,45 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* An internal utility class.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class Util {
|
||||
|
||||
static final public void reportFailure(String msg, Throwable t) {
|
||||
System.err.println(msg);
|
||||
System.err.println("Reported exception:");
|
||||
t.printStackTrace();
|
||||
}
|
||||
|
||||
static final public void reportFailure(String msg) {
|
||||
System.err.println("SLF4J: " +msg);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* An internal utility class.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class Util {
|
||||
|
||||
static final public void reportFailure(String msg, Throwable t) {
|
||||
System.err.println(msg);
|
||||
System.err.println("Reported exception:");
|
||||
t.printStackTrace();
|
||||
}
|
||||
|
||||
static final public void reportFailure(String msg) {
|
||||
System.err.println("SLF4J: " +msg);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<p>Helper classes.</p>
|
||||
|
||||
<hr/>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<p>Helper classes.</p>
|
||||
|
||||
<hr/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,77 +1,77 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.impl;
|
||||
|
||||
import org.slf4j.ILoggerFactory;
|
||||
|
||||
/**
|
||||
* The binding of {@link LoggerFactory} class with an actual instance of
|
||||
* {@link ILoggerFactory} is performed using information returned by this class.
|
||||
*
|
||||
* This class is meant to provide a dummy StaticLoggerBinder to the slf4j-api module.
|
||||
* Real implementations are found in each SLF4J binding project, e.g. slf4j-nop,
|
||||
* slf4j-log4j12 etc.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class StaticLoggerBinder {
|
||||
|
||||
/**
|
||||
* The unique instance of this class.
|
||||
*
|
||||
* @deprecated Please use the {@link #getSingleton()} method instead of
|
||||
* accessing this field directly. In future versions, this field
|
||||
* will become private.
|
||||
*/
|
||||
public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
|
||||
|
||||
/**
|
||||
* Return the singleton of this class.
|
||||
*
|
||||
* @return the StaticLoggerBinder singleton
|
||||
*/
|
||||
public static final StaticLoggerBinder getSingleton() {
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declare the version of the SLF4J API this implementation is compiled against.
|
||||
* The value of this field is usually modified with each release.
|
||||
*/
|
||||
// to avoid constant folding by the compiler, this field must *not* be final
|
||||
public static String REQUESTED_API_VERSION = "1.5.10"; // !final
|
||||
|
||||
private StaticLoggerBinder() {
|
||||
throw new UnsupportedOperationException("This code should have never made it into the jar");
|
||||
}
|
||||
|
||||
public ILoggerFactory getLoggerFactory() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
|
||||
public String getLoggerFactoryClassStr() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.impl;
|
||||
|
||||
import org.slf4j.ILoggerFactory;
|
||||
|
||||
/**
|
||||
* The binding of {@link LoggerFactory} class with an actual instance of
|
||||
* {@link ILoggerFactory} is performed using information returned by this class.
|
||||
*
|
||||
* This class is meant to provide a dummy StaticLoggerBinder to the slf4j-api module.
|
||||
* Real implementations are found in each SLF4J binding project, e.g. slf4j-nop,
|
||||
* slf4j-log4j12 etc.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class StaticLoggerBinder {
|
||||
|
||||
/**
|
||||
* The unique instance of this class.
|
||||
*
|
||||
* @deprecated Please use the {@link #getSingleton()} method instead of
|
||||
* accessing this field directly. In future versions, this field
|
||||
* will become private.
|
||||
*/
|
||||
public static final StaticLoggerBinder SINGLETON = new StaticLoggerBinder();
|
||||
|
||||
/**
|
||||
* Return the singleton of this class.
|
||||
*
|
||||
* @return the StaticLoggerBinder singleton
|
||||
*/
|
||||
public static final StaticLoggerBinder getSingleton() {
|
||||
return SINGLETON;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declare the version of the SLF4J API this implementation is compiled against.
|
||||
* The value of this field is usually modified with each release.
|
||||
*/
|
||||
// to avoid constant folding by the compiler, this field must *not* be final
|
||||
public static String REQUESTED_API_VERSION = "1.5.10"; // !final
|
||||
|
||||
private StaticLoggerBinder() {
|
||||
throw new UnsupportedOperationException("This code should have never made it into the jar");
|
||||
}
|
||||
|
||||
public ILoggerFactory getLoggerFactory() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
|
||||
public String getLoggerFactoryClassStr() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +1,35 @@
|
|||
package org.slf4j.impl;
|
||||
|
||||
import org.slf4j.spi.MDCAdapter;
|
||||
|
||||
|
||||
/**
|
||||
* This class is only a stub. Real implementations are found in
|
||||
* each SLF4J binding project, e.g. slf4j-nop, slf4j-log4j12 etc.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class StaticMDCBinder {
|
||||
|
||||
|
||||
/**
|
||||
* The unique instance of this class.
|
||||
*/
|
||||
public static final StaticMDCBinder SINGLETON = new StaticMDCBinder();
|
||||
|
||||
private StaticMDCBinder() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently this method always returns an instance of
|
||||
* {@link StaticMDCBinder}.
|
||||
*/
|
||||
public MDCAdapter getMDCA() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
|
||||
public String getMDCAdapterClassStr() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
}
|
||||
package org.slf4j.impl;
|
||||
|
||||
import org.slf4j.spi.MDCAdapter;
|
||||
|
||||
|
||||
/**
|
||||
* This class is only a stub. Real implementations are found in
|
||||
* each SLF4J binding project, e.g. slf4j-nop, slf4j-log4j12 etc.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class StaticMDCBinder {
|
||||
|
||||
|
||||
/**
|
||||
* The unique instance of this class.
|
||||
*/
|
||||
public static final StaticMDCBinder SINGLETON = new StaticMDCBinder();
|
||||
|
||||
private StaticMDCBinder() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently this method always returns an instance of
|
||||
* {@link StaticMDCBinder}.
|
||||
*/
|
||||
public MDCAdapter getMDCA() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
|
||||
public String getMDCAdapterClassStr() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,71 +1,71 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.impl;
|
||||
|
||||
import org.slf4j.IMarkerFactory;
|
||||
import org.slf4j.MarkerFactory;
|
||||
import org.slf4j.helpers.BasicMarkerFactory;
|
||||
import org.slf4j.spi.MarkerFactoryBinder;
|
||||
|
||||
/**
|
||||
*
|
||||
* The binding of {@link MarkerFactory} class with an actual instance of
|
||||
* {@link IMarkerFactory} is performed using information returned by this class.
|
||||
*
|
||||
* This class is meant to provide a *dummy* StaticMarkerBinder to the slf4j-api module.
|
||||
* Real implementations are found in each SLF4J binding project, e.g. slf4j-nop,
|
||||
* slf4j-simple, slf4j-log4j12 etc.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class StaticMarkerBinder implements MarkerFactoryBinder {
|
||||
|
||||
/**
|
||||
* The unique instance of this class.
|
||||
*/
|
||||
public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
|
||||
|
||||
private StaticMarkerBinder() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently this method always returns an instance of
|
||||
* {@link BasicMarkerFactory}.
|
||||
*/
|
||||
public IMarkerFactory getMarkerFactory() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently, this method returns the class name of
|
||||
* {@link BasicMarkerFactory}.
|
||||
*/
|
||||
public String getMarkerFactoryClassStr() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.impl;
|
||||
|
||||
import org.slf4j.IMarkerFactory;
|
||||
import org.slf4j.MarkerFactory;
|
||||
import org.slf4j.helpers.BasicMarkerFactory;
|
||||
import org.slf4j.spi.MarkerFactoryBinder;
|
||||
|
||||
/**
|
||||
*
|
||||
* The binding of {@link MarkerFactory} class with an actual instance of
|
||||
* {@link IMarkerFactory} is performed using information returned by this class.
|
||||
*
|
||||
* This class is meant to provide a *dummy* StaticMarkerBinder to the slf4j-api module.
|
||||
* Real implementations are found in each SLF4J binding project, e.g. slf4j-nop,
|
||||
* slf4j-simple, slf4j-log4j12 etc.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class StaticMarkerBinder implements MarkerFactoryBinder {
|
||||
|
||||
/**
|
||||
* The unique instance of this class.
|
||||
*/
|
||||
public static final StaticMarkerBinder SINGLETON = new StaticMarkerBinder();
|
||||
|
||||
private StaticMarkerBinder() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently this method always returns an instance of
|
||||
* {@link BasicMarkerFactory}.
|
||||
*/
|
||||
public IMarkerFactory getMarkerFactory() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
|
||||
/**
|
||||
* Currently, this method returns the class name of
|
||||
* {@link BasicMarkerFactory}.
|
||||
*/
|
||||
public String getMarkerFactoryClassStr() {
|
||||
throw new UnsupportedOperationException("This code should never make it into the jar");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<p>Implementations of core logging interfaces defined in the {@link
|
||||
org.slf4j} package.</p>
|
||||
|
||||
<hr/>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<p>Implementations of core logging interfaces defined in the {@link
|
||||
org.slf4j} package.</p>
|
||||
|
||||
<hr/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<p>Core logging interfaces.</p>
|
||||
|
||||
<hr/>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
|
||||
<p>Core logging interfaces.</p>
|
||||
|
||||
<hr/>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,60 +1,60 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.spi;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.Marker;
|
||||
|
||||
/**
|
||||
* An <b>optional</b> interface helping integration with logging systems capable of
|
||||
* extracting location information. This interface is mainly used by SLF4J bridges
|
||||
* such as jcl104-over-slf4j which need to provide hints so that the underlying logging
|
||||
* system can extract the correct location information (method name, line number, etc.).
|
||||
*
|
||||
*
|
||||
* @author Ceki Gulcu
|
||||
* @since 1.3
|
||||
*/
|
||||
public interface LocationAwareLogger extends Logger {
|
||||
|
||||
final public int TRACE_INT = 00;
|
||||
final public int DEBUG_INT = 10;
|
||||
final public int INFO_INT = 20;
|
||||
final public int WARN_INT = 30;
|
||||
final public int ERROR_INT = 40;
|
||||
|
||||
|
||||
/**
|
||||
* Printing method with support for location information.
|
||||
*
|
||||
* @param marker
|
||||
* @param fqcn The fully qualified class name of the <b>caller</b>
|
||||
* @param level
|
||||
* @param message
|
||||
* @param t
|
||||
*/
|
||||
public void log(Marker marker, String fqcn, int level, String message, Throwable t);
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.spi;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.Marker;
|
||||
|
||||
/**
|
||||
* An <b>optional</b> interface helping integration with logging systems capable of
|
||||
* extracting location information. This interface is mainly used by SLF4J bridges
|
||||
* such as jcl104-over-slf4j which need to provide hints so that the underlying logging
|
||||
* system can extract the correct location information (method name, line number, etc.).
|
||||
*
|
||||
*
|
||||
* @author Ceki Gulcu
|
||||
* @since 1.3
|
||||
*/
|
||||
public interface LocationAwareLogger extends Logger {
|
||||
|
||||
final public int TRACE_INT = 00;
|
||||
final public int DEBUG_INT = 10;
|
||||
final public int INFO_INT = 20;
|
||||
final public int WARN_INT = 30;
|
||||
final public int ERROR_INT = 40;
|
||||
|
||||
|
||||
/**
|
||||
* Printing method with support for location information.
|
||||
*
|
||||
* @param marker
|
||||
* @param fqcn The fully qualified class name of the <b>caller</b>
|
||||
* @param level
|
||||
* @param message
|
||||
* @param t
|
||||
*/
|
||||
public void log(Marker marker, String fqcn, int level, String message, Throwable t);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,66 +1,66 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2005 SLF4J.ORG
|
||||
* Copyright (c) 2004-2005 QOS.ch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.slf4j.spi;
|
||||
|
||||
import org.slf4j.ILoggerFactory;
|
||||
|
||||
/**
|
||||
* An internal interface which helps the static {@link org.slf4j.LoggerFactory}
|
||||
* class bind with the appropriate {@link ILoggerFactory} instance.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public interface LoggerFactoryBinder {
|
||||
|
||||
/**
|
||||
* Return the instance of {@link ILoggerFactory} that
|
||||
* {@link org.slf4j.LoggerFactory} class should bind to.
|
||||
*
|
||||
* @return the instance of {@link ILoggerFactory} that
|
||||
* {@link org.slf4j.LoggerFactory} class should bind to.
|
||||
*/
|
||||
public ILoggerFactory getLoggerFactory();
|
||||
|
||||
/**
|
||||
* The String form of the {@link ILoggerFactory} object that this
|
||||
* <code>LoggerFactoryBinder</code> instance is <em>intended</em> to return.
|
||||
*
|
||||
* <p>This method allows the developer to intterogate this binder's intention
|
||||
* which may be different from the {@link ILoggerFactory} instance it is able to
|
||||
* yield in practice. The discrepency should only occur in case of errors.
|
||||
*
|
||||
* @return the class name of the intended {@link ILoggerFactory} instance
|
||||
*/
|
||||
public String getLoggerFactoryClassStr();
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2005 SLF4J.ORG
|
||||
* Copyright (c) 2004-2005 QOS.ch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.slf4j.spi;
|
||||
|
||||
import org.slf4j.ILoggerFactory;
|
||||
|
||||
/**
|
||||
* An internal interface which helps the static {@link org.slf4j.LoggerFactory}
|
||||
* class bind with the appropriate {@link ILoggerFactory} instance.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public interface LoggerFactoryBinder {
|
||||
|
||||
/**
|
||||
* Return the instance of {@link ILoggerFactory} that
|
||||
* {@link org.slf4j.LoggerFactory} class should bind to.
|
||||
*
|
||||
* @return the instance of {@link ILoggerFactory} that
|
||||
* {@link org.slf4j.LoggerFactory} class should bind to.
|
||||
*/
|
||||
public ILoggerFactory getLoggerFactory();
|
||||
|
||||
/**
|
||||
* The String form of the {@link ILoggerFactory} object that this
|
||||
* <code>LoggerFactoryBinder</code> instance is <em>intended</em> to return.
|
||||
*
|
||||
* <p>This method allows the developer to intterogate this binder's intention
|
||||
* which may be different from the {@link ILoggerFactory} instance it is able to
|
||||
* yield in practice. The discrepency should only occur in case of errors.
|
||||
*
|
||||
* @return the class name of the intended {@link ILoggerFactory} instance
|
||||
*/
|
||||
public String getLoggerFactoryClassStr();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,91 +1,91 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.spi;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This interface abstracts the service offered by various MDC
|
||||
* implementations.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @since 1.4.1
|
||||
*/
|
||||
public interface MDCAdapter {
|
||||
|
||||
/**
|
||||
* Put a context value (the <code>val</code> parameter) as identified with
|
||||
* the <code>key</code> parameter into the current thread's context map.
|
||||
* The <code>key</code> parameter cannot be null. The code>val</code> parameter
|
||||
* can be null only if the underlying implementation supports it.
|
||||
*
|
||||
* <p>If the current thread does not have a context map it is created as a side
|
||||
* effect of this call.
|
||||
*/
|
||||
public void put(String key, String val);
|
||||
|
||||
/**
|
||||
* Get the context identified by the <code>key</code> parameter.
|
||||
* The <code>key</code> parameter cannot be null.
|
||||
*
|
||||
* @return the string value identified by the <code>key</code> parameter.
|
||||
*/
|
||||
public String get(String key);
|
||||
|
||||
/**
|
||||
* Remove the the context identified by the <code>key</code> parameter.
|
||||
* The <code>key</code> parameter cannot be null.
|
||||
*
|
||||
* <p>
|
||||
* This method does nothing if there is no previous value
|
||||
* associated with <code>key</code>.
|
||||
*/
|
||||
public void remove(String key);
|
||||
|
||||
/**
|
||||
* Clear all entries in the MDC.
|
||||
*/
|
||||
public void clear();
|
||||
|
||||
/**
|
||||
* Return a copy of the current thread's context map, with keys and
|
||||
* values of type String. Returned value may be null.
|
||||
*
|
||||
* @return A copy of the current thread's context map. May be null.
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public Map getCopyOfContextMap();
|
||||
|
||||
/**
|
||||
* Set the current thread's context map by first clearing any existing
|
||||
* map and then copying the map passed as parameter. The context map
|
||||
* parameter must only contain keys and values of type String.
|
||||
*
|
||||
* @param contextMap must contain only keys and values of type String
|
||||
*
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public void setContextMap(Map contextMap);
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2007 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.spi;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This interface abstracts the service offered by various MDC
|
||||
* implementations.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @since 1.4.1
|
||||
*/
|
||||
public interface MDCAdapter {
|
||||
|
||||
/**
|
||||
* Put a context value (the <code>val</code> parameter) as identified with
|
||||
* the <code>key</code> parameter into the current thread's context map.
|
||||
* The <code>key</code> parameter cannot be null. The code>val</code> parameter
|
||||
* can be null only if the underlying implementation supports it.
|
||||
*
|
||||
* <p>If the current thread does not have a context map it is created as a side
|
||||
* effect of this call.
|
||||
*/
|
||||
public void put(String key, String val);
|
||||
|
||||
/**
|
||||
* Get the context identified by the <code>key</code> parameter.
|
||||
* The <code>key</code> parameter cannot be null.
|
||||
*
|
||||
* @return the string value identified by the <code>key</code> parameter.
|
||||
*/
|
||||
public String get(String key);
|
||||
|
||||
/**
|
||||
* Remove the the context identified by the <code>key</code> parameter.
|
||||
* The <code>key</code> parameter cannot be null.
|
||||
*
|
||||
* <p>
|
||||
* This method does nothing if there is no previous value
|
||||
* associated with <code>key</code>.
|
||||
*/
|
||||
public void remove(String key);
|
||||
|
||||
/**
|
||||
* Clear all entries in the MDC.
|
||||
*/
|
||||
public void clear();
|
||||
|
||||
/**
|
||||
* Return a copy of the current thread's context map, with keys and
|
||||
* values of type String. Returned value may be null.
|
||||
*
|
||||
* @return A copy of the current thread's context map. May be null.
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public Map getCopyOfContextMap();
|
||||
|
||||
/**
|
||||
* Set the current thread's context map by first clearing any existing
|
||||
* map and then copying the map passed as parameter. The context map
|
||||
* parameter must only contain keys and values of type String.
|
||||
*
|
||||
* @param contextMap must contain only keys and values of type String
|
||||
*
|
||||
* @since 1.5.1
|
||||
*/
|
||||
public void setContextMap(Map contextMap);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,67 +1,67 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2005 SLF4J.ORG
|
||||
* Copyright (c) 2004-2005 QOS.ch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.slf4j.spi;
|
||||
|
||||
import org.slf4j.IMarkerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* An internal interface which helps the static {@link org.slf4j.MarkerFactory}
|
||||
* class bind with the appropriate {@link IMarkerFactory} instance.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public interface MarkerFactoryBinder {
|
||||
|
||||
/**
|
||||
* Return the instance of {@link IMarkerFactory} that
|
||||
* {@link org.slf4j.MarkerFactory} class should bind to.
|
||||
*
|
||||
* @return the instance of {@link IMarkerFactory} that
|
||||
* {@link org.slf4j.MarkerFactory} class should bind to.
|
||||
*/
|
||||
public IMarkerFactory getMarkerFactory();
|
||||
|
||||
/**
|
||||
* The String form of the {@link IMarkerFactory} object that this
|
||||
* <code>MarkerFactoryBinder</code> instance is <em>intended</em> to return.
|
||||
*
|
||||
* <p>This method allows the developer to intterogate this binder's intention
|
||||
* which may be different from the {@link IMarkerFactory} instance it is able to
|
||||
* return. Such a discrepency should only occur in case of errors.
|
||||
*
|
||||
* @return the class name of the intended {@link IMarkerFactory} instance
|
||||
*/
|
||||
public String getMarkerFactoryClassStr();
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2005 SLF4J.ORG
|
||||
* Copyright (c) 2004-2005 QOS.ch
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.slf4j.spi;
|
||||
|
||||
import org.slf4j.IMarkerFactory;
|
||||
|
||||
|
||||
/**
|
||||
* An internal interface which helps the static {@link org.slf4j.MarkerFactory}
|
||||
* class bind with the appropriate {@link IMarkerFactory} instance.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public interface MarkerFactoryBinder {
|
||||
|
||||
/**
|
||||
* Return the instance of {@link IMarkerFactory} that
|
||||
* {@link org.slf4j.MarkerFactory} class should bind to.
|
||||
*
|
||||
* @return the instance of {@link IMarkerFactory} that
|
||||
* {@link org.slf4j.MarkerFactory} class should bind to.
|
||||
*/
|
||||
public IMarkerFactory getMarkerFactory();
|
||||
|
||||
/**
|
||||
* The String form of the {@link IMarkerFactory} object that this
|
||||
* <code>MarkerFactoryBinder</code> instance is <em>intended</em> to return.
|
||||
*
|
||||
* <p>This method allows the developer to intterogate this binder's intention
|
||||
* which may be different from the {@link IMarkerFactory} instance it is able to
|
||||
* return. Such a discrepency should only occur in case of errors.
|
||||
*
|
||||
* @return the class name of the intended {@link IMarkerFactory} instance
|
||||
*/
|
||||
public String getMarkerFactoryClassStr();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
<body>
|
||||
|
||||
|
||||
Classes and interfaces which are internal to SLF4J. Under most
|
||||
circumstances SLF4J users should be oblivious even to the existence of
|
||||
this package.
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
Classes and interfaces which are internal to SLF4J. Under most
|
||||
circumstances SLF4J users should be oblivious even to the existence of
|
||||
this package.
|
||||
</body>
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
Implementation-Title: slf4j-api
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-SymbolicName: slf4j.api
|
||||
Bundle-Name: slf4j-api
|
||||
Bundle-Vendor: SLF4J.ORG
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.3
|
||||
Export-Package: org.slf4j;version=${parsedVersion.osgiVersion}, org.slf4j.spi;version=${parsedVersion.osgiVersion}, org.slf4j.helpers;version=${parsedVersion.osgiVersion}
|
||||
Import-Package: org.slf4j.impl;version=${slf4j.api.minimum.compatible.version}
|
||||
Implementation-Title: slf4j-api
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-SymbolicName: slf4j.api
|
||||
Bundle-Name: slf4j-api
|
||||
Bundle-Vendor: SLF4J.ORG
|
||||
Bundle-RequiredExecutionEnvironment: J2SE-1.3
|
||||
Export-Package: org.slf4j;version=${parsedVersion.osgiVersion}, org.slf4j.spi;version=${parsedVersion.osgiVersion}, org.slf4j.helpers;version=${parsedVersion.osgiVersion}
|
||||
Import-Package: org.slf4j.impl;version=${slf4j.api.minimum.compatible.version}
|
||||
|
|
|
|||
|
|
@ -1,196 +1,196 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.slf4j.helpers.BasicMarkerFactory;
|
||||
|
||||
/**
|
||||
* Unit test BasicMarker
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author Joern Huxhorn
|
||||
*/
|
||||
public class BasicMarkerTest extends TestCase {
|
||||
static final String BLUE_STR = "BLUE";
|
||||
static final String RED_STR = "RED";
|
||||
static final String GREEN_STR = "GREEN";
|
||||
static final String COMP_STR = "COMP";
|
||||
static final String MULTI_COMP_STR = "MULTI_COMP";
|
||||
static final String PARENT_MARKER_STR = "PARENT_MARKER";
|
||||
static final String CHILD_MARKER_STR = "CHILD_MARKER";
|
||||
static final String NOT_CONTAINED_MARKER_STR = "NOT_CONTAINED";
|
||||
|
||||
final IMarkerFactory factory;
|
||||
final Marker blue;
|
||||
final Marker red;
|
||||
final Marker green;
|
||||
final Marker comp;
|
||||
final Marker multiComp;
|
||||
|
||||
short diff = Differentiator.getDiffentiator();
|
||||
|
||||
public BasicMarkerTest() {
|
||||
factory = new BasicMarkerFactory();
|
||||
|
||||
blue = factory.getMarker(BLUE_STR);
|
||||
red = factory.getMarker(RED_STR);
|
||||
green = factory.getMarker(GREEN_STR);
|
||||
comp = factory.getMarker(COMP_STR);
|
||||
comp.add(blue);
|
||||
|
||||
multiComp = factory.getMarker(MULTI_COMP_STR);
|
||||
multiComp.add(green);
|
||||
multiComp.add(comp);
|
||||
}
|
||||
|
||||
public void testPrimitive() {
|
||||
assertEquals(BLUE_STR, blue.getName());
|
||||
assertTrue(blue.contains(blue));
|
||||
|
||||
Marker blue2 = factory.getMarker(BLUE_STR);
|
||||
assertEquals(BLUE_STR, blue2.getName());
|
||||
assertEquals(blue, blue2);
|
||||
assertTrue(blue.contains(blue2));
|
||||
assertTrue(blue2.contains(blue));
|
||||
}
|
||||
|
||||
public void testPrimitiveByName() {
|
||||
assertTrue(blue.contains(BLUE_STR));
|
||||
}
|
||||
|
||||
public void testComposite() {
|
||||
assertTrue(comp.contains(comp));
|
||||
assertTrue(comp.contains(blue));
|
||||
}
|
||||
|
||||
public void testCompositeByName() {
|
||||
assertTrue(comp.contains(COMP_STR));
|
||||
assertTrue(comp.contains(BLUE_STR));
|
||||
}
|
||||
|
||||
public void testMultiComposite() {
|
||||
assertTrue(multiComp.contains(comp));
|
||||
assertTrue(multiComp.contains(blue));
|
||||
assertTrue(multiComp.contains(green));
|
||||
assertFalse(multiComp.contains(red));
|
||||
}
|
||||
|
||||
public void testMultiCompositeByName() {
|
||||
assertTrue(multiComp.contains(COMP_STR));
|
||||
assertTrue(multiComp.contains(BLUE_STR));
|
||||
assertTrue(multiComp.contains(GREEN_STR));
|
||||
assertFalse(multiComp.contains(RED_STR));
|
||||
}
|
||||
|
||||
public void testMultiAdd() {
|
||||
Marker parent = factory.getMarker(PARENT_MARKER_STR);
|
||||
Marker child = factory.getMarker(CHILD_MARKER_STR);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
parent.add(child);
|
||||
}
|
||||
|
||||
// check that the child was added once and only once
|
||||
Iterator iterator = parent.iterator();
|
||||
assertTrue(iterator.hasNext());
|
||||
assertEquals(CHILD_MARKER_STR, iterator.next().toString());
|
||||
assertFalse(iterator.hasNext());
|
||||
}
|
||||
|
||||
public void testAddRemove() {
|
||||
final String NEW_PREFIX = "NEW_";
|
||||
Marker parent = factory.getMarker(NEW_PREFIX + PARENT_MARKER_STR);
|
||||
Marker child = factory.getMarker(NEW_PREFIX + CHILD_MARKER_STR);
|
||||
assertFalse(parent.contains(child));
|
||||
assertFalse(parent.contains(NEW_PREFIX + CHILD_MARKER_STR));
|
||||
assertFalse(parent.remove(child));
|
||||
|
||||
parent.add(child);
|
||||
|
||||
assertTrue(parent.contains(child));
|
||||
assertTrue(parent.contains(NEW_PREFIX + CHILD_MARKER_STR));
|
||||
|
||||
assertTrue(parent.remove(child));
|
||||
|
||||
assertFalse(parent.contains(child));
|
||||
assertFalse(parent.contains(NEW_PREFIX + CHILD_MARKER_STR));
|
||||
assertFalse(parent.remove(child));
|
||||
}
|
||||
|
||||
public void testSelfRecursion() {
|
||||
final String diffPrefix = "NEW_"+diff;
|
||||
final String PARENT_NAME = diffPrefix + PARENT_MARKER_STR;
|
||||
final String NOT_CONTAINED_NAME = diffPrefix + NOT_CONTAINED_MARKER_STR;
|
||||
Marker parent = factory.getMarker(PARENT_NAME);
|
||||
Marker notContained = factory.getMarker(NOT_CONTAINED_NAME);
|
||||
parent.add(parent);
|
||||
assertTrue(parent.contains(parent));
|
||||
assertTrue(parent.contains(PARENT_NAME));
|
||||
assertFalse(parent.contains(notContained));
|
||||
assertFalse(parent.contains(NOT_CONTAINED_MARKER_STR));
|
||||
}
|
||||
|
||||
public void testIndirectRecursion() {
|
||||
final String diffPrefix = "NEW_"+diff;
|
||||
final String PARENT_NAME=diffPrefix+PARENT_MARKER_STR;
|
||||
final String CHILD_NAME=diffPrefix+CHILD_MARKER_STR;
|
||||
final String NOT_CONTAINED_NAME=diffPrefix+NOT_CONTAINED_MARKER_STR;
|
||||
|
||||
Marker parent = factory.getMarker(PARENT_NAME);
|
||||
Marker child = factory.getMarker(CHILD_NAME);
|
||||
Marker notContained = factory.getMarker(NOT_CONTAINED_NAME);
|
||||
|
||||
parent.add(child);
|
||||
child.add(parent);
|
||||
assertTrue(parent.contains(parent));
|
||||
assertTrue(parent.contains(child));
|
||||
assertTrue(parent.contains(PARENT_NAME));
|
||||
assertTrue(parent.contains(CHILD_NAME));
|
||||
assertFalse(parent.contains(notContained));
|
||||
assertFalse(parent.contains(NOT_CONTAINED_MARKER_STR));
|
||||
}
|
||||
|
||||
public void testHomonyms() {
|
||||
final String diffPrefix = "homonym"+diff;
|
||||
final String PARENT_NAME=diffPrefix+PARENT_MARKER_STR;
|
||||
final String CHILD_NAME=diffPrefix+CHILD_MARKER_STR;
|
||||
Marker parent = factory.getMarker(PARENT_NAME);
|
||||
Marker child = factory.getMarker(CHILD_NAME);
|
||||
parent.add(child);
|
||||
|
||||
IMarkerFactory otherFactory = new BasicMarkerFactory();
|
||||
Marker otherParent = otherFactory.getMarker(PARENT_NAME);
|
||||
Marker otherChild = otherFactory.getMarker(CHILD_NAME);
|
||||
|
||||
assertTrue(parent.contains(otherParent));
|
||||
assertTrue(parent.contains(otherChild));
|
||||
|
||||
assertTrue(parent.remove(otherChild));
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.slf4j.helpers.BasicMarkerFactory;
|
||||
|
||||
/**
|
||||
* Unit test BasicMarker
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
* @author Joern Huxhorn
|
||||
*/
|
||||
public class BasicMarkerTest extends TestCase {
|
||||
static final String BLUE_STR = "BLUE";
|
||||
static final String RED_STR = "RED";
|
||||
static final String GREEN_STR = "GREEN";
|
||||
static final String COMP_STR = "COMP";
|
||||
static final String MULTI_COMP_STR = "MULTI_COMP";
|
||||
static final String PARENT_MARKER_STR = "PARENT_MARKER";
|
||||
static final String CHILD_MARKER_STR = "CHILD_MARKER";
|
||||
static final String NOT_CONTAINED_MARKER_STR = "NOT_CONTAINED";
|
||||
|
||||
final IMarkerFactory factory;
|
||||
final Marker blue;
|
||||
final Marker red;
|
||||
final Marker green;
|
||||
final Marker comp;
|
||||
final Marker multiComp;
|
||||
|
||||
short diff = Differentiator.getDiffentiator();
|
||||
|
||||
public BasicMarkerTest() {
|
||||
factory = new BasicMarkerFactory();
|
||||
|
||||
blue = factory.getMarker(BLUE_STR);
|
||||
red = factory.getMarker(RED_STR);
|
||||
green = factory.getMarker(GREEN_STR);
|
||||
comp = factory.getMarker(COMP_STR);
|
||||
comp.add(blue);
|
||||
|
||||
multiComp = factory.getMarker(MULTI_COMP_STR);
|
||||
multiComp.add(green);
|
||||
multiComp.add(comp);
|
||||
}
|
||||
|
||||
public void testPrimitive() {
|
||||
assertEquals(BLUE_STR, blue.getName());
|
||||
assertTrue(blue.contains(blue));
|
||||
|
||||
Marker blue2 = factory.getMarker(BLUE_STR);
|
||||
assertEquals(BLUE_STR, blue2.getName());
|
||||
assertEquals(blue, blue2);
|
||||
assertTrue(blue.contains(blue2));
|
||||
assertTrue(blue2.contains(blue));
|
||||
}
|
||||
|
||||
public void testPrimitiveByName() {
|
||||
assertTrue(blue.contains(BLUE_STR));
|
||||
}
|
||||
|
||||
public void testComposite() {
|
||||
assertTrue(comp.contains(comp));
|
||||
assertTrue(comp.contains(blue));
|
||||
}
|
||||
|
||||
public void testCompositeByName() {
|
||||
assertTrue(comp.contains(COMP_STR));
|
||||
assertTrue(comp.contains(BLUE_STR));
|
||||
}
|
||||
|
||||
public void testMultiComposite() {
|
||||
assertTrue(multiComp.contains(comp));
|
||||
assertTrue(multiComp.contains(blue));
|
||||
assertTrue(multiComp.contains(green));
|
||||
assertFalse(multiComp.contains(red));
|
||||
}
|
||||
|
||||
public void testMultiCompositeByName() {
|
||||
assertTrue(multiComp.contains(COMP_STR));
|
||||
assertTrue(multiComp.contains(BLUE_STR));
|
||||
assertTrue(multiComp.contains(GREEN_STR));
|
||||
assertFalse(multiComp.contains(RED_STR));
|
||||
}
|
||||
|
||||
public void testMultiAdd() {
|
||||
Marker parent = factory.getMarker(PARENT_MARKER_STR);
|
||||
Marker child = factory.getMarker(CHILD_MARKER_STR);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
parent.add(child);
|
||||
}
|
||||
|
||||
// check that the child was added once and only once
|
||||
Iterator iterator = parent.iterator();
|
||||
assertTrue(iterator.hasNext());
|
||||
assertEquals(CHILD_MARKER_STR, iterator.next().toString());
|
||||
assertFalse(iterator.hasNext());
|
||||
}
|
||||
|
||||
public void testAddRemove() {
|
||||
final String NEW_PREFIX = "NEW_";
|
||||
Marker parent = factory.getMarker(NEW_PREFIX + PARENT_MARKER_STR);
|
||||
Marker child = factory.getMarker(NEW_PREFIX + CHILD_MARKER_STR);
|
||||
assertFalse(parent.contains(child));
|
||||
assertFalse(parent.contains(NEW_PREFIX + CHILD_MARKER_STR));
|
||||
assertFalse(parent.remove(child));
|
||||
|
||||
parent.add(child);
|
||||
|
||||
assertTrue(parent.contains(child));
|
||||
assertTrue(parent.contains(NEW_PREFIX + CHILD_MARKER_STR));
|
||||
|
||||
assertTrue(parent.remove(child));
|
||||
|
||||
assertFalse(parent.contains(child));
|
||||
assertFalse(parent.contains(NEW_PREFIX + CHILD_MARKER_STR));
|
||||
assertFalse(parent.remove(child));
|
||||
}
|
||||
|
||||
public void testSelfRecursion() {
|
||||
final String diffPrefix = "NEW_"+diff;
|
||||
final String PARENT_NAME = diffPrefix + PARENT_MARKER_STR;
|
||||
final String NOT_CONTAINED_NAME = diffPrefix + NOT_CONTAINED_MARKER_STR;
|
||||
Marker parent = factory.getMarker(PARENT_NAME);
|
||||
Marker notContained = factory.getMarker(NOT_CONTAINED_NAME);
|
||||
parent.add(parent);
|
||||
assertTrue(parent.contains(parent));
|
||||
assertTrue(parent.contains(PARENT_NAME));
|
||||
assertFalse(parent.contains(notContained));
|
||||
assertFalse(parent.contains(NOT_CONTAINED_MARKER_STR));
|
||||
}
|
||||
|
||||
public void testIndirectRecursion() {
|
||||
final String diffPrefix = "NEW_"+diff;
|
||||
final String PARENT_NAME=diffPrefix+PARENT_MARKER_STR;
|
||||
final String CHILD_NAME=diffPrefix+CHILD_MARKER_STR;
|
||||
final String NOT_CONTAINED_NAME=diffPrefix+NOT_CONTAINED_MARKER_STR;
|
||||
|
||||
Marker parent = factory.getMarker(PARENT_NAME);
|
||||
Marker child = factory.getMarker(CHILD_NAME);
|
||||
Marker notContained = factory.getMarker(NOT_CONTAINED_NAME);
|
||||
|
||||
parent.add(child);
|
||||
child.add(parent);
|
||||
assertTrue(parent.contains(parent));
|
||||
assertTrue(parent.contains(child));
|
||||
assertTrue(parent.contains(PARENT_NAME));
|
||||
assertTrue(parent.contains(CHILD_NAME));
|
||||
assertFalse(parent.contains(notContained));
|
||||
assertFalse(parent.contains(NOT_CONTAINED_MARKER_STR));
|
||||
}
|
||||
|
||||
public void testHomonyms() {
|
||||
final String diffPrefix = "homonym"+diff;
|
||||
final String PARENT_NAME=diffPrefix+PARENT_MARKER_STR;
|
||||
final String CHILD_NAME=diffPrefix+CHILD_MARKER_STR;
|
||||
Marker parent = factory.getMarker(PARENT_NAME);
|
||||
Marker child = factory.getMarker(CHILD_NAME);
|
||||
parent.add(child);
|
||||
|
||||
IMarkerFactory otherFactory = new BasicMarkerFactory();
|
||||
Marker otherParent = otherFactory.getMarker(PARENT_NAME);
|
||||
Marker otherChild = otherFactory.getMarker(CHILD_NAME);
|
||||
|
||||
assertTrue(parent.contains(otherParent));
|
||||
assertTrue(parent.contains(otherChild));
|
||||
|
||||
assertTrue(parent.remove(otherChild));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +1,37 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Differentiator {
|
||||
|
||||
static Random random = new Random(System.currentTimeMillis());
|
||||
|
||||
static public short getDiffentiator() {
|
||||
return (short) random.nextInt(Short.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
package org.slf4j;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Differentiator {
|
||||
|
||||
static Random random = new Random(System.currentTimeMillis());
|
||||
|
||||
static public short getDiffentiator() {
|
||||
return (short) random.nextInt(Short.MAX_VALUE);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,25 +1,25 @@
|
|||
package org.slf4j;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class NoBindingTest extends TestCase {
|
||||
|
||||
public void testLogger() {
|
||||
try {
|
||||
Logger logger = LoggerFactory.getLogger(NoBindingTest.class);
|
||||
logger.debug("hello");
|
||||
fail("slf4j-api does not ship with a binding");
|
||||
} catch (NoClassDefFoundError e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void testMDC() {
|
||||
try {
|
||||
MDC.put("k", "v");
|
||||
fail("slf4j-api does not ship with a binding");
|
||||
} catch (NoClassDefFoundError e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
package org.slf4j;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class NoBindingTest extends TestCase {
|
||||
|
||||
public void testLogger() {
|
||||
try {
|
||||
Logger logger = LoggerFactory.getLogger(NoBindingTest.class);
|
||||
logger.debug("hello");
|
||||
fail("slf4j-api does not ship with a binding");
|
||||
} catch (NoClassDefFoundError e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void testMDC() {
|
||||
try {
|
||||
MDC.put("k", "v");
|
||||
fail("slf4j-api does not ship with a binding");
|
||||
} catch (NoClassDefFoundError e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,159 +1,159 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
/**
|
||||
* BogoPerf is used to check that the time required to perform a certain
|
||||
* operation does not deteriorate over time. BogoPerf adjusts to the CPU speed
|
||||
* and capabilities of the host.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*
|
||||
*/
|
||||
public class BogoPerf {
|
||||
|
||||
private static long NANOS_IN_ONE_SECOND = 1000 * 1000 * 1000;
|
||||
private static int INITIAL_N = 1000;
|
||||
private static int LAST_N = 100;
|
||||
private static int SLACK_FACTOR = 3;
|
||||
|
||||
static {
|
||||
// let the JIT warm up
|
||||
computeBogoIPS(INITIAL_N);
|
||||
double bogo_ips = computeBogoIPS(INITIAL_N);
|
||||
System.out.println("Host runs at " + bogo_ips + " BIPS");
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute bogoInstructions per second
|
||||
* <p>
|
||||
* on a 3.2 Ghz Pentium D CPU (around 2007), we obtain about 9'000 bogoIPS.
|
||||
*
|
||||
* @param N
|
||||
* number of bogoInstructions to average over in order to
|
||||
* compute the result
|
||||
* @return bogo Instructions Per Second
|
||||
*/
|
||||
private static double computeBogoIPS(int N) {
|
||||
long begin = System.nanoTime();
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
bogoInstruction();
|
||||
}
|
||||
long end = System.nanoTime();
|
||||
|
||||
// duration
|
||||
double D = end - begin;
|
||||
// average duration per instruction
|
||||
double avgDPIS = D / N;
|
||||
// System.out.println(D + " nanos for " + N + " instructions");
|
||||
// System.out.println(avgD + " nanos per instruction");
|
||||
|
||||
double bogoIPS = NANOS_IN_ONE_SECOND / avgDPIS;
|
||||
// System.out.println(bogoIPS + " bogoIPS");
|
||||
|
||||
return bogoIPS;
|
||||
}
|
||||
|
||||
private static void bogoInstruction() {
|
||||
// use our own random number generator, independent of the host JDK
|
||||
MyRandom myRandom = new MyRandom(100);
|
||||
int len = 150;
|
||||
int[] intArray = new int[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
intArray[i] = myRandom.nextInt();
|
||||
}
|
||||
// use our own sort algorithm, independent of the host JDK
|
||||
BubbleSort.sort(intArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computed the BogoIPS for this host CPU.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static double currentBIPS() {
|
||||
return computeBogoIPS(LAST_N);
|
||||
}
|
||||
|
||||
static double min(double a, double b) {
|
||||
return (a <= b) ? a : b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assertion used for values that <b>decrease</b> with faster CPUs, typically
|
||||
* the time (duration) needed to perform a task.
|
||||
*
|
||||
* @param currentDuration
|
||||
* @param referenceDuration
|
||||
* @param referenceBIPS
|
||||
* @throws AssertionFailedError
|
||||
*/
|
||||
public static void assertDuration(double currentDuration,
|
||||
long referenceDuration, double referenceBIPS) throws AssertionFailedError {
|
||||
double ajustedDuration = adjustExpectedDuration(referenceDuration,
|
||||
referenceBIPS);
|
||||
if (currentDuration > ajustedDuration * SLACK_FACTOR) {
|
||||
throw new AssertionFailedError("current duration " + currentDuration
|
||||
+ " exceeded expected " + ajustedDuration + " (adjusted reference), "
|
||||
+ referenceDuration + " (raw reference)");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assertion used for values that <b>increase<b> with faster CPUs, typically
|
||||
* the number of operations accomplished per unit of time.
|
||||
*
|
||||
* @param currentPerformance
|
||||
* @param referencePerformance
|
||||
* @param referenceBIPS
|
||||
* @throws AssertionFailedError
|
||||
*/
|
||||
public static void assertPerformance(double currentPerformance,
|
||||
long referencePerformance, double referenceBIPS)
|
||||
throws AssertionFailedError {
|
||||
double ajustedPerf = adjustExpectedPerformance(referencePerformance,
|
||||
referenceBIPS);
|
||||
if (currentPerformance * SLACK_FACTOR < ajustedPerf) {
|
||||
throw new AssertionFailedError(currentPerformance + " below expected "
|
||||
+ ajustedPerf + " (adjusted), " + referencePerformance + " (raw)");
|
||||
}
|
||||
}
|
||||
|
||||
private static double adjustExpectedPerformance(long referenceDuration,
|
||||
double referenceBIPS) {
|
||||
double currentBIPS = currentBIPS();
|
||||
return referenceDuration * (currentBIPS / referenceBIPS);
|
||||
}
|
||||
|
||||
private static double adjustExpectedDuration(long referenceDuration,
|
||||
double referenceBIPS) {
|
||||
double currentBIPS = currentBIPS();
|
||||
System.out.println("currentBIPS=" + currentBIPS + " BIPS");
|
||||
return referenceDuration * (referenceBIPS / currentBIPS);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
/**
|
||||
* BogoPerf is used to check that the time required to perform a certain
|
||||
* operation does not deteriorate over time. BogoPerf adjusts to the CPU speed
|
||||
* and capabilities of the host.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*
|
||||
*/
|
||||
public class BogoPerf {
|
||||
|
||||
private static long NANOS_IN_ONE_SECOND = 1000 * 1000 * 1000;
|
||||
private static int INITIAL_N = 1000;
|
||||
private static int LAST_N = 100;
|
||||
private static int SLACK_FACTOR = 3;
|
||||
|
||||
static {
|
||||
// let the JIT warm up
|
||||
computeBogoIPS(INITIAL_N);
|
||||
double bogo_ips = computeBogoIPS(INITIAL_N);
|
||||
System.out.println("Host runs at " + bogo_ips + " BIPS");
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute bogoInstructions per second
|
||||
* <p>
|
||||
* on a 3.2 Ghz Pentium D CPU (around 2007), we obtain about 9'000 bogoIPS.
|
||||
*
|
||||
* @param N
|
||||
* number of bogoInstructions to average over in order to
|
||||
* compute the result
|
||||
* @return bogo Instructions Per Second
|
||||
*/
|
||||
private static double computeBogoIPS(int N) {
|
||||
long begin = System.nanoTime();
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
bogoInstruction();
|
||||
}
|
||||
long end = System.nanoTime();
|
||||
|
||||
// duration
|
||||
double D = end - begin;
|
||||
// average duration per instruction
|
||||
double avgDPIS = D / N;
|
||||
// System.out.println(D + " nanos for " + N + " instructions");
|
||||
// System.out.println(avgD + " nanos per instruction");
|
||||
|
||||
double bogoIPS = NANOS_IN_ONE_SECOND / avgDPIS;
|
||||
// System.out.println(bogoIPS + " bogoIPS");
|
||||
|
||||
return bogoIPS;
|
||||
}
|
||||
|
||||
private static void bogoInstruction() {
|
||||
// use our own random number generator, independent of the host JDK
|
||||
MyRandom myRandom = new MyRandom(100);
|
||||
int len = 150;
|
||||
int[] intArray = new int[len];
|
||||
for (int i = 0; i < len; i++) {
|
||||
intArray[i] = myRandom.nextInt();
|
||||
}
|
||||
// use our own sort algorithm, independent of the host JDK
|
||||
BubbleSort.sort(intArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* Computed the BogoIPS for this host CPU.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static double currentBIPS() {
|
||||
return computeBogoIPS(LAST_N);
|
||||
}
|
||||
|
||||
static double min(double a, double b) {
|
||||
return (a <= b) ? a : b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assertion used for values that <b>decrease</b> with faster CPUs, typically
|
||||
* the time (duration) needed to perform a task.
|
||||
*
|
||||
* @param currentDuration
|
||||
* @param referenceDuration
|
||||
* @param referenceBIPS
|
||||
* @throws AssertionFailedError
|
||||
*/
|
||||
public static void assertDuration(double currentDuration,
|
||||
long referenceDuration, double referenceBIPS) throws AssertionFailedError {
|
||||
double ajustedDuration = adjustExpectedDuration(referenceDuration,
|
||||
referenceBIPS);
|
||||
if (currentDuration > ajustedDuration * SLACK_FACTOR) {
|
||||
throw new AssertionFailedError("current duration " + currentDuration
|
||||
+ " exceeded expected " + ajustedDuration + " (adjusted reference), "
|
||||
+ referenceDuration + " (raw reference)");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assertion used for values that <b>increase<b> with faster CPUs, typically
|
||||
* the number of operations accomplished per unit of time.
|
||||
*
|
||||
* @param currentPerformance
|
||||
* @param referencePerformance
|
||||
* @param referenceBIPS
|
||||
* @throws AssertionFailedError
|
||||
*/
|
||||
public static void assertPerformance(double currentPerformance,
|
||||
long referencePerformance, double referenceBIPS)
|
||||
throws AssertionFailedError {
|
||||
double ajustedPerf = adjustExpectedPerformance(referencePerformance,
|
||||
referenceBIPS);
|
||||
if (currentPerformance * SLACK_FACTOR < ajustedPerf) {
|
||||
throw new AssertionFailedError(currentPerformance + " below expected "
|
||||
+ ajustedPerf + " (adjusted), " + referencePerformance + " (raw)");
|
||||
}
|
||||
}
|
||||
|
||||
private static double adjustExpectedPerformance(long referenceDuration,
|
||||
double referenceBIPS) {
|
||||
double currentBIPS = currentBIPS();
|
||||
return referenceDuration * (currentBIPS / referenceBIPS);
|
||||
}
|
||||
|
||||
private static double adjustExpectedDuration(long referenceDuration,
|
||||
double referenceBIPS) {
|
||||
double currentBIPS = currentBIPS();
|
||||
System.out.println("currentBIPS=" + currentBIPS + " BIPS");
|
||||
return referenceDuration * (referenceBIPS / currentBIPS);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,50 +1,50 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
/**
|
||||
* This class is used internally by BogoPerf, hence the package private
|
||||
* (default) access.
|
||||
*
|
||||
* @author Ceki
|
||||
*/
|
||||
class BubbleSort {
|
||||
|
||||
static void sort(int[] a) {
|
||||
int len = a.length;
|
||||
for (int i = 0; i < len - 1; i++) {
|
||||
for (int j = 0; j < len - 1 - i; j++) {
|
||||
if (a[j] > a[j + 1]) {
|
||||
swap(a, j, j + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void swap(int[] a, int i, int j) {
|
||||
int t = a[i];
|
||||
a[i] = a[j];
|
||||
a[j] = t;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
/**
|
||||
* This class is used internally by BogoPerf, hence the package private
|
||||
* (default) access.
|
||||
*
|
||||
* @author Ceki
|
||||
*/
|
||||
class BubbleSort {
|
||||
|
||||
static void sort(int[] a) {
|
||||
int len = a.length;
|
||||
for (int i = 0; i < len - 1; i++) {
|
||||
for (int j = 0; j < len - 1 - i; j++) {
|
||||
if (a[j] > a[j + 1]) {
|
||||
swap(a, j, j + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static void swap(int[] a, int i, int j) {
|
||||
int t = a[i];
|
||||
a[i] = a[j];
|
||||
a[j] = t;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,101 +1,101 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Test that our BubbleSort algorithm is correctly implemented.
|
||||
*
|
||||
* @author Ceki
|
||||
*
|
||||
*/
|
||||
public class BubbleSortTest extends TestCase {
|
||||
|
||||
public void testSmoke() {
|
||||
int[] a = new int[] {5,3,2,7};
|
||||
BubbleSort.sort(a);
|
||||
int i = 0;
|
||||
assertEquals(2, a[i++]);
|
||||
assertEquals(3, a[i++]);
|
||||
assertEquals(5, a[i++]);
|
||||
assertEquals(7, a[i++]);
|
||||
}
|
||||
|
||||
public void testEmpty() {
|
||||
int[] a = new int[] {};
|
||||
BubbleSort.sort(a);
|
||||
}
|
||||
|
||||
public void testSorted() {
|
||||
int[] a = new int[] {3,30,300,3000};
|
||||
BubbleSort.sort(a);
|
||||
int i = 0;
|
||||
assertEquals(3, a[i++]);
|
||||
assertEquals(30, a[i++]);
|
||||
assertEquals(300, a[i++]);
|
||||
assertEquals(3000, a[i++]);
|
||||
}
|
||||
|
||||
public void testInverted() {
|
||||
int[] a = new int[] {3000,300,30,3};
|
||||
BubbleSort.sort(a);
|
||||
int i = 0;
|
||||
assertEquals(3, a[i++]);
|
||||
assertEquals(30, a[i++]);
|
||||
assertEquals(300, a[i++]);
|
||||
assertEquals(3000, a[i++]);
|
||||
}
|
||||
|
||||
public void testWithSameEntry() {
|
||||
int[] a = new int[] {10,20,10,20};
|
||||
BubbleSort.sort(a);
|
||||
int i = 0;
|
||||
assertEquals(10, a[i++]);
|
||||
assertEquals(10, a[i++]);
|
||||
assertEquals(20, a[i++]);
|
||||
assertEquals(20, a[i++]);
|
||||
}
|
||||
|
||||
|
||||
public void testRandom() {
|
||||
int len = 100;
|
||||
Random random = new Random(156);
|
||||
int[] a = new int[len];
|
||||
int[] witness = new int[len];
|
||||
for(int i = 0; i < len; i++) {
|
||||
int r = random.nextInt();
|
||||
a[i] = r;
|
||||
witness[i] = r;
|
||||
}
|
||||
BubbleSort.sort(a);
|
||||
Arrays.sort(witness);
|
||||
assertTrue(Arrays.equals(witness, a));
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* Test that our BubbleSort algorithm is correctly implemented.
|
||||
*
|
||||
* @author Ceki
|
||||
*
|
||||
*/
|
||||
public class BubbleSortTest extends TestCase {
|
||||
|
||||
public void testSmoke() {
|
||||
int[] a = new int[] {5,3,2,7};
|
||||
BubbleSort.sort(a);
|
||||
int i = 0;
|
||||
assertEquals(2, a[i++]);
|
||||
assertEquals(3, a[i++]);
|
||||
assertEquals(5, a[i++]);
|
||||
assertEquals(7, a[i++]);
|
||||
}
|
||||
|
||||
public void testEmpty() {
|
||||
int[] a = new int[] {};
|
||||
BubbleSort.sort(a);
|
||||
}
|
||||
|
||||
public void testSorted() {
|
||||
int[] a = new int[] {3,30,300,3000};
|
||||
BubbleSort.sort(a);
|
||||
int i = 0;
|
||||
assertEquals(3, a[i++]);
|
||||
assertEquals(30, a[i++]);
|
||||
assertEquals(300, a[i++]);
|
||||
assertEquals(3000, a[i++]);
|
||||
}
|
||||
|
||||
public void testInverted() {
|
||||
int[] a = new int[] {3000,300,30,3};
|
||||
BubbleSort.sort(a);
|
||||
int i = 0;
|
||||
assertEquals(3, a[i++]);
|
||||
assertEquals(30, a[i++]);
|
||||
assertEquals(300, a[i++]);
|
||||
assertEquals(3000, a[i++]);
|
||||
}
|
||||
|
||||
public void testWithSameEntry() {
|
||||
int[] a = new int[] {10,20,10,20};
|
||||
BubbleSort.sort(a);
|
||||
int i = 0;
|
||||
assertEquals(10, a[i++]);
|
||||
assertEquals(10, a[i++]);
|
||||
assertEquals(20, a[i++]);
|
||||
assertEquals(20, a[i++]);
|
||||
}
|
||||
|
||||
|
||||
public void testRandom() {
|
||||
int len = 100;
|
||||
Random random = new Random(156);
|
||||
int[] a = new int[len];
|
||||
int[] witness = new int[len];
|
||||
for(int i = 0; i < len; i++) {
|
||||
int r = random.nextInt();
|
||||
a[i] = r;
|
||||
witness[i] = r;
|
||||
}
|
||||
BubbleSort.sort(a);
|
||||
Arrays.sort(witness);
|
||||
assertTrue(Arrays.equals(witness, a));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,58 +1,58 @@
|
|||
package org.slf4j.helpers;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class MessageFormatterPerfTest extends TestCase {
|
||||
|
||||
Integer i1 = new Integer(1);
|
||||
static long RUN_LENGTH = 100000;
|
||||
static long REFERENCE_BIPS = 9000;
|
||||
|
||||
public MessageFormatterPerfTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
public void XtestJDKFormatterPerf() {
|
||||
jdkMessageFormatter(RUN_LENGTH);
|
||||
double duration = jdkMessageFormatter(RUN_LENGTH);
|
||||
System.out.println("jdk duration = "+duration+" nanos");
|
||||
}
|
||||
|
||||
public void testSLF4JPerf() {
|
||||
slf4jMessageFormatter(RUN_LENGTH);
|
||||
double duration = slf4jMessageFormatter(RUN_LENGTH);
|
||||
long referencePerf = 140;
|
||||
BogoPerf.assertDuration(duration, referencePerf, REFERENCE_BIPS);
|
||||
}
|
||||
|
||||
public double slf4jMessageFormatter(long len) {
|
||||
String s = "";
|
||||
s += ""; // keep compiler happy
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < len; i++) {
|
||||
s = MessageFormatter.format("This is some rather short message {} ", i1);
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
return (1.0*end - start);
|
||||
}
|
||||
public double jdkMessageFormatter(long len) {
|
||||
String s = "";
|
||||
s += ""; // keep compiler happy
|
||||
long start = System.currentTimeMillis();
|
||||
Object[] oa = new Object[] {i1};
|
||||
for (int i = 0; i < len; i++) {
|
||||
s = MessageFormat.format("This is some rather short message {0}", oa);
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
return (1.0*end - start);
|
||||
}
|
||||
|
||||
}
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
public class MessageFormatterPerfTest extends TestCase {
|
||||
|
||||
Integer i1 = new Integer(1);
|
||||
static long RUN_LENGTH = 100000;
|
||||
static long REFERENCE_BIPS = 9000;
|
||||
|
||||
public MessageFormatterPerfTest(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
public void XtestJDKFormatterPerf() {
|
||||
jdkMessageFormatter(RUN_LENGTH);
|
||||
double duration = jdkMessageFormatter(RUN_LENGTH);
|
||||
System.out.println("jdk duration = "+duration+" nanos");
|
||||
}
|
||||
|
||||
public void testSLF4JPerf() {
|
||||
slf4jMessageFormatter(RUN_LENGTH);
|
||||
double duration = slf4jMessageFormatter(RUN_LENGTH);
|
||||
long referencePerf = 140;
|
||||
BogoPerf.assertDuration(duration, referencePerf, REFERENCE_BIPS);
|
||||
}
|
||||
|
||||
public double slf4jMessageFormatter(long len) {
|
||||
String s = "";
|
||||
s += ""; // keep compiler happy
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < len; i++) {
|
||||
s = MessageFormatter.format("This is some rather short message {} ", i1);
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
return (1.0*end - start);
|
||||
}
|
||||
public double jdkMessageFormatter(long len) {
|
||||
String s = "";
|
||||
s += ""; // keep compiler happy
|
||||
long start = System.currentTimeMillis();
|
||||
Object[] oa = new Object[] {i1};
|
||||
for (int i = 0; i < len; i++) {
|
||||
s = MessageFormat.format("This is some rather short message {0}", oa);
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
return (1.0*end - start);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,286 +1,286 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2005 SLF4J.ORG
|
||||
* Copyright (c) 2004-2005 QOS.CH
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Ceki Gulcu
|
||||
*
|
||||
*/
|
||||
public class MessageFormatterTest extends TestCase {
|
||||
|
||||
Integer i1 = new Integer(1);
|
||||
Integer i2 = new Integer(2);
|
||||
Integer i3 = new Integer(3);
|
||||
Integer[] ia0 = new Integer[] { i1, i2, i3 };
|
||||
Integer[] ia1 = new Integer[] { new Integer(10), new Integer(20),
|
||||
new Integer(30) };
|
||||
|
||||
String result;
|
||||
|
||||
|
||||
public void testNull() {
|
||||
result = MessageFormatter.format(null, i1);
|
||||
assertEquals(null, result);
|
||||
}
|
||||
|
||||
public void testNullParam() {
|
||||
result = MessageFormatter.format("Value is {}.", null);
|
||||
assertEquals("Value is null.", result);
|
||||
|
||||
result = MessageFormatter.format("Val1 is {}, val2 is {}.", null, null);
|
||||
assertEquals("Val1 is null, val2 is null.", result);
|
||||
|
||||
result = MessageFormatter.format("Val1 is {}, val2 is {}.", i1, null);
|
||||
assertEquals("Val1 is 1, val2 is null.", result);
|
||||
|
||||
result = MessageFormatter.format("Val1 is {}, val2 is {}.", null, i2);
|
||||
assertEquals("Val1 is null, val2 is 2.", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Val1 is {}, val2 is {}, val3 is {}",
|
||||
new Integer[] { null, null, null });
|
||||
assertEquals("Val1 is null, val2 is null, val3 is null", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Val1 is {}, val2 is {}, val3 is {}",
|
||||
new Integer[] { null, i2, i3 });
|
||||
assertEquals("Val1 is null, val2 is 2, val3 is 3", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Val1 is {}, val2 is {}, val3 is {}",
|
||||
new Integer[] { null, null, i3 });
|
||||
assertEquals("Val1 is null, val2 is null, val3 is 3", result);
|
||||
}
|
||||
|
||||
public void testOneParameter() {
|
||||
result = MessageFormatter.format("Value is {}.", i3);
|
||||
assertEquals("Value is 3.", result);
|
||||
|
||||
result = MessageFormatter.format("Value is {", i3);
|
||||
assertEquals("Value is {", result);
|
||||
|
||||
result = MessageFormatter.format("{} is larger than 2.", i3);
|
||||
assertEquals("3 is larger than 2.", result);
|
||||
|
||||
result = MessageFormatter.format("No subst", i3);
|
||||
assertEquals("No subst", result);
|
||||
|
||||
result = MessageFormatter.format("Incorrect {subst", i3);
|
||||
assertEquals("Incorrect {subst", result);
|
||||
|
||||
result = MessageFormatter.format("Value is {bla} {}", i3);
|
||||
assertEquals("Value is {bla} 3", result);
|
||||
|
||||
result = MessageFormatter.format("Escaped \\{} subst", i3);
|
||||
assertEquals("Escaped {} subst", result);
|
||||
|
||||
result = MessageFormatter.format("{Escaped", i3);
|
||||
assertEquals("{Escaped", result);
|
||||
|
||||
result = MessageFormatter.format("\\{}Escaped", i3);
|
||||
assertEquals("{}Escaped", result);
|
||||
|
||||
result = MessageFormatter.format("File name is {{}}.", "App folder.zip");
|
||||
assertEquals("File name is {App folder.zip}.", result);
|
||||
|
||||
// escaping the escape character
|
||||
result = MessageFormatter
|
||||
.format("File name is C:\\\\{}.", "App folder.zip");
|
||||
assertEquals("File name is C:\\App folder.zip.", result);
|
||||
}
|
||||
|
||||
public void testTwoParameters() {
|
||||
result = MessageFormatter.format("Value {} is smaller than {}.", i1, i2);
|
||||
assertEquals("Value 1 is smaller than 2.", result);
|
||||
|
||||
result = MessageFormatter.format("Value {} is smaller than {}", i1, i2);
|
||||
assertEquals("Value 1 is smaller than 2", result);
|
||||
|
||||
result = MessageFormatter.format("{}{}", i1, i2);
|
||||
assertEquals("12", result);
|
||||
|
||||
result = MessageFormatter.format("Val1={}, Val2={", i1, i2);
|
||||
assertEquals("Val1=1, Val2={", result);
|
||||
|
||||
result = MessageFormatter.format("Value {} is smaller than \\{}", i1, i2);
|
||||
assertEquals("Value 1 is smaller than {}", result);
|
||||
|
||||
result = MessageFormatter.format("Value {} is smaller than \\{} tail", i1,
|
||||
i2);
|
||||
assertEquals("Value 1 is smaller than {} tail", result);
|
||||
|
||||
result = MessageFormatter.format("Value {} is smaller than \\{", i1, i2);
|
||||
assertEquals("Value 1 is smaller than \\{", result);
|
||||
|
||||
result = MessageFormatter
|
||||
.format("Value {} is smaller than {tail", i1, i2);
|
||||
assertEquals("Value 1 is smaller than {tail", result);
|
||||
|
||||
result = MessageFormatter.format("Value \\{} is smaller than {}", i1, i2);
|
||||
assertEquals("Value {} is smaller than 1", result);
|
||||
}
|
||||
|
||||
|
||||
public void testExceptionInToString() {
|
||||
Object o = new Object() {
|
||||
public String toString() {
|
||||
throw new IllegalStateException("a");
|
||||
}
|
||||
};
|
||||
result = MessageFormatter.format("Troublesome object {}", o);
|
||||
assertEquals("Troublesome object [FAILED toString()]", result);
|
||||
|
||||
}
|
||||
|
||||
public void testNullArray() {
|
||||
String msg0 = "msg0";
|
||||
String msg1 = "msg1 {}";
|
||||
String msg2 = "msg2 {} {}";
|
||||
String msg3 = "msg3 {} {} {}";
|
||||
|
||||
Object[] args = null;
|
||||
|
||||
result = MessageFormatter.arrayFormat(msg0, args);
|
||||
assertEquals(msg0, result);
|
||||
|
||||
result = MessageFormatter.arrayFormat(msg1, args);
|
||||
assertEquals(msg1, result);
|
||||
|
||||
result = MessageFormatter.arrayFormat(msg2, args);
|
||||
assertEquals(msg2, result);
|
||||
|
||||
result = MessageFormatter.arrayFormat(msg3, args);
|
||||
assertEquals(msg3, result);
|
||||
}
|
||||
|
||||
// tests the case when the parameters are supplied in a single array
|
||||
public void testArrayFormat() {
|
||||
result = MessageFormatter.arrayFormat(
|
||||
"Value {} is smaller than {} and {}.", ia0);
|
||||
assertEquals("Value 1 is smaller than 2 and 3.", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("{}{}{}", ia0);
|
||||
assertEquals("123", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Value {} is smaller than {}.", ia0);
|
||||
assertEquals("Value 1 is smaller than 2.", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Value {} is smaller than {}", ia0);
|
||||
assertEquals("Value 1 is smaller than 2", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Val={}, {, Val={}", ia0);
|
||||
assertEquals("Val=1, {, Val=2", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Val={}, {, Val={}", ia0);
|
||||
assertEquals("Val=1, {, Val=2", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Val1={}, Val2={", ia0);
|
||||
assertEquals("Val1=1, Val2={", result);
|
||||
}
|
||||
|
||||
public void testArrayValues() {
|
||||
Integer p0 = i1;
|
||||
Integer[] p1 = new Integer[] { i2, i3 };
|
||||
|
||||
result = MessageFormatter.format("{}{}", p0, p1);
|
||||
assertEquals("1[2, 3]", result);
|
||||
|
||||
// Integer[]
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a", p1 });
|
||||
assertEquals("a[2, 3]", result);
|
||||
|
||||
// byte[]
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a",
|
||||
new byte[] { 1, 2 } });
|
||||
assertEquals("a[1, 2]", result);
|
||||
|
||||
// int[]
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a",
|
||||
new int[] { 1, 2 } });
|
||||
assertEquals("a[1, 2]", result);
|
||||
|
||||
// float[]
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a",
|
||||
new float[] { 1, 2 } });
|
||||
assertEquals("a[1.0, 2.0]", result);
|
||||
|
||||
// double[]
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a",
|
||||
new double[] { 1, 2 } });
|
||||
assertEquals("a[1.0, 2.0]", result);
|
||||
|
||||
}
|
||||
|
||||
public void testMultiDimensionalArrayValues() {
|
||||
Integer[][] multiIntegerA = new Integer[][] { ia0, ia1 };
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a",
|
||||
multiIntegerA });
|
||||
assertEquals("a[[1, 2, 3], [10, 20, 30]]", result);
|
||||
|
||||
int[][] multiIntA = new int[][] { { 1, 2 }, { 10, 20 } };
|
||||
result = MessageFormatter.arrayFormat("{}{}",
|
||||
new Object[] { "a", multiIntA });
|
||||
assertEquals("a[[1, 2], [10, 20]]", result);
|
||||
|
||||
float[][] multiFloatA = new float[][] { { 1, 2 }, { 10, 20 } };
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a",
|
||||
multiFloatA });
|
||||
assertEquals("a[[1.0, 2.0], [10.0, 20.0]]", result);
|
||||
|
||||
Object[][] multiOA = new Object[][] { ia0, ia1 };
|
||||
result = MessageFormatter
|
||||
.arrayFormat("{}{}", new Object[] { "a", multiOA });
|
||||
assertEquals("a[[1, 2, 3], [10, 20, 30]]", result);
|
||||
|
||||
Object[][][] _3DOA = new Object[][][] { multiOA, multiOA };
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a", _3DOA });
|
||||
assertEquals("a[[[1, 2, 3], [10, 20, 30]], [[1, 2, 3], [10, 20, 30]]]",
|
||||
result);
|
||||
}
|
||||
|
||||
public void testCyclicArrays() {
|
||||
{
|
||||
Object[] cyclicA = new Object[1];
|
||||
cyclicA[0] = cyclicA;
|
||||
assertEquals("[[...]]", MessageFormatter.arrayFormat("{}", cyclicA));
|
||||
}
|
||||
{
|
||||
Object[] a = new Object[2];
|
||||
a[0] = i1;
|
||||
Object[] c = new Object[] {i3, a};
|
||||
Object[] b = new Object[] {i2, c};
|
||||
a[1] = b;
|
||||
assertEquals("1[2, [3, [1, [...]]]]", MessageFormatter.arrayFormat("{}{}", a));
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2005 SLF4J.ORG
|
||||
* Copyright (c) 2004-2005 QOS.CH
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons
|
||||
* to whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||
* OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY
|
||||
* SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER
|
||||
* RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
|
||||
* CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*
|
||||
* Except as contained in this notice, the name of a copyright holder
|
||||
* shall not be used in advertising or otherwise to promote the sale, use
|
||||
* or other dealings in this Software without prior written authorization
|
||||
* of the copyright holder.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* @author Ceki Gulcu
|
||||
*
|
||||
*/
|
||||
public class MessageFormatterTest extends TestCase {
|
||||
|
||||
Integer i1 = new Integer(1);
|
||||
Integer i2 = new Integer(2);
|
||||
Integer i3 = new Integer(3);
|
||||
Integer[] ia0 = new Integer[] { i1, i2, i3 };
|
||||
Integer[] ia1 = new Integer[] { new Integer(10), new Integer(20),
|
||||
new Integer(30) };
|
||||
|
||||
String result;
|
||||
|
||||
|
||||
public void testNull() {
|
||||
result = MessageFormatter.format(null, i1);
|
||||
assertEquals(null, result);
|
||||
}
|
||||
|
||||
public void testNullParam() {
|
||||
result = MessageFormatter.format("Value is {}.", null);
|
||||
assertEquals("Value is null.", result);
|
||||
|
||||
result = MessageFormatter.format("Val1 is {}, val2 is {}.", null, null);
|
||||
assertEquals("Val1 is null, val2 is null.", result);
|
||||
|
||||
result = MessageFormatter.format("Val1 is {}, val2 is {}.", i1, null);
|
||||
assertEquals("Val1 is 1, val2 is null.", result);
|
||||
|
||||
result = MessageFormatter.format("Val1 is {}, val2 is {}.", null, i2);
|
||||
assertEquals("Val1 is null, val2 is 2.", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Val1 is {}, val2 is {}, val3 is {}",
|
||||
new Integer[] { null, null, null });
|
||||
assertEquals("Val1 is null, val2 is null, val3 is null", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Val1 is {}, val2 is {}, val3 is {}",
|
||||
new Integer[] { null, i2, i3 });
|
||||
assertEquals("Val1 is null, val2 is 2, val3 is 3", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Val1 is {}, val2 is {}, val3 is {}",
|
||||
new Integer[] { null, null, i3 });
|
||||
assertEquals("Val1 is null, val2 is null, val3 is 3", result);
|
||||
}
|
||||
|
||||
public void testOneParameter() {
|
||||
result = MessageFormatter.format("Value is {}.", i3);
|
||||
assertEquals("Value is 3.", result);
|
||||
|
||||
result = MessageFormatter.format("Value is {", i3);
|
||||
assertEquals("Value is {", result);
|
||||
|
||||
result = MessageFormatter.format("{} is larger than 2.", i3);
|
||||
assertEquals("3 is larger than 2.", result);
|
||||
|
||||
result = MessageFormatter.format("No subst", i3);
|
||||
assertEquals("No subst", result);
|
||||
|
||||
result = MessageFormatter.format("Incorrect {subst", i3);
|
||||
assertEquals("Incorrect {subst", result);
|
||||
|
||||
result = MessageFormatter.format("Value is {bla} {}", i3);
|
||||
assertEquals("Value is {bla} 3", result);
|
||||
|
||||
result = MessageFormatter.format("Escaped \\{} subst", i3);
|
||||
assertEquals("Escaped {} subst", result);
|
||||
|
||||
result = MessageFormatter.format("{Escaped", i3);
|
||||
assertEquals("{Escaped", result);
|
||||
|
||||
result = MessageFormatter.format("\\{}Escaped", i3);
|
||||
assertEquals("{}Escaped", result);
|
||||
|
||||
result = MessageFormatter.format("File name is {{}}.", "App folder.zip");
|
||||
assertEquals("File name is {App folder.zip}.", result);
|
||||
|
||||
// escaping the escape character
|
||||
result = MessageFormatter
|
||||
.format("File name is C:\\\\{}.", "App folder.zip");
|
||||
assertEquals("File name is C:\\App folder.zip.", result);
|
||||
}
|
||||
|
||||
public void testTwoParameters() {
|
||||
result = MessageFormatter.format("Value {} is smaller than {}.", i1, i2);
|
||||
assertEquals("Value 1 is smaller than 2.", result);
|
||||
|
||||
result = MessageFormatter.format("Value {} is smaller than {}", i1, i2);
|
||||
assertEquals("Value 1 is smaller than 2", result);
|
||||
|
||||
result = MessageFormatter.format("{}{}", i1, i2);
|
||||
assertEquals("12", result);
|
||||
|
||||
result = MessageFormatter.format("Val1={}, Val2={", i1, i2);
|
||||
assertEquals("Val1=1, Val2={", result);
|
||||
|
||||
result = MessageFormatter.format("Value {} is smaller than \\{}", i1, i2);
|
||||
assertEquals("Value 1 is smaller than {}", result);
|
||||
|
||||
result = MessageFormatter.format("Value {} is smaller than \\{} tail", i1,
|
||||
i2);
|
||||
assertEquals("Value 1 is smaller than {} tail", result);
|
||||
|
||||
result = MessageFormatter.format("Value {} is smaller than \\{", i1, i2);
|
||||
assertEquals("Value 1 is smaller than \\{", result);
|
||||
|
||||
result = MessageFormatter
|
||||
.format("Value {} is smaller than {tail", i1, i2);
|
||||
assertEquals("Value 1 is smaller than {tail", result);
|
||||
|
||||
result = MessageFormatter.format("Value \\{} is smaller than {}", i1, i2);
|
||||
assertEquals("Value {} is smaller than 1", result);
|
||||
}
|
||||
|
||||
|
||||
public void testExceptionInToString() {
|
||||
Object o = new Object() {
|
||||
public String toString() {
|
||||
throw new IllegalStateException("a");
|
||||
}
|
||||
};
|
||||
result = MessageFormatter.format("Troublesome object {}", o);
|
||||
assertEquals("Troublesome object [FAILED toString()]", result);
|
||||
|
||||
}
|
||||
|
||||
public void testNullArray() {
|
||||
String msg0 = "msg0";
|
||||
String msg1 = "msg1 {}";
|
||||
String msg2 = "msg2 {} {}";
|
||||
String msg3 = "msg3 {} {} {}";
|
||||
|
||||
Object[] args = null;
|
||||
|
||||
result = MessageFormatter.arrayFormat(msg0, args);
|
||||
assertEquals(msg0, result);
|
||||
|
||||
result = MessageFormatter.arrayFormat(msg1, args);
|
||||
assertEquals(msg1, result);
|
||||
|
||||
result = MessageFormatter.arrayFormat(msg2, args);
|
||||
assertEquals(msg2, result);
|
||||
|
||||
result = MessageFormatter.arrayFormat(msg3, args);
|
||||
assertEquals(msg3, result);
|
||||
}
|
||||
|
||||
// tests the case when the parameters are supplied in a single array
|
||||
public void testArrayFormat() {
|
||||
result = MessageFormatter.arrayFormat(
|
||||
"Value {} is smaller than {} and {}.", ia0);
|
||||
assertEquals("Value 1 is smaller than 2 and 3.", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("{}{}{}", ia0);
|
||||
assertEquals("123", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Value {} is smaller than {}.", ia0);
|
||||
assertEquals("Value 1 is smaller than 2.", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Value {} is smaller than {}", ia0);
|
||||
assertEquals("Value 1 is smaller than 2", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Val={}, {, Val={}", ia0);
|
||||
assertEquals("Val=1, {, Val=2", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Val={}, {, Val={}", ia0);
|
||||
assertEquals("Val=1, {, Val=2", result);
|
||||
|
||||
result = MessageFormatter.arrayFormat("Val1={}, Val2={", ia0);
|
||||
assertEquals("Val1=1, Val2={", result);
|
||||
}
|
||||
|
||||
public void testArrayValues() {
|
||||
Integer p0 = i1;
|
||||
Integer[] p1 = new Integer[] { i2, i3 };
|
||||
|
||||
result = MessageFormatter.format("{}{}", p0, p1);
|
||||
assertEquals("1[2, 3]", result);
|
||||
|
||||
// Integer[]
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a", p1 });
|
||||
assertEquals("a[2, 3]", result);
|
||||
|
||||
// byte[]
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a",
|
||||
new byte[] { 1, 2 } });
|
||||
assertEquals("a[1, 2]", result);
|
||||
|
||||
// int[]
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a",
|
||||
new int[] { 1, 2 } });
|
||||
assertEquals("a[1, 2]", result);
|
||||
|
||||
// float[]
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a",
|
||||
new float[] { 1, 2 } });
|
||||
assertEquals("a[1.0, 2.0]", result);
|
||||
|
||||
// double[]
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a",
|
||||
new double[] { 1, 2 } });
|
||||
assertEquals("a[1.0, 2.0]", result);
|
||||
|
||||
}
|
||||
|
||||
public void testMultiDimensionalArrayValues() {
|
||||
Integer[][] multiIntegerA = new Integer[][] { ia0, ia1 };
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a",
|
||||
multiIntegerA });
|
||||
assertEquals("a[[1, 2, 3], [10, 20, 30]]", result);
|
||||
|
||||
int[][] multiIntA = new int[][] { { 1, 2 }, { 10, 20 } };
|
||||
result = MessageFormatter.arrayFormat("{}{}",
|
||||
new Object[] { "a", multiIntA });
|
||||
assertEquals("a[[1, 2], [10, 20]]", result);
|
||||
|
||||
float[][] multiFloatA = new float[][] { { 1, 2 }, { 10, 20 } };
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a",
|
||||
multiFloatA });
|
||||
assertEquals("a[[1.0, 2.0], [10.0, 20.0]]", result);
|
||||
|
||||
Object[][] multiOA = new Object[][] { ia0, ia1 };
|
||||
result = MessageFormatter
|
||||
.arrayFormat("{}{}", new Object[] { "a", multiOA });
|
||||
assertEquals("a[[1, 2, 3], [10, 20, 30]]", result);
|
||||
|
||||
Object[][][] _3DOA = new Object[][][] { multiOA, multiOA };
|
||||
result = MessageFormatter.arrayFormat("{}{}", new Object[] { "a", _3DOA });
|
||||
assertEquals("a[[[1, 2, 3], [10, 20, 30]], [[1, 2, 3], [10, 20, 30]]]",
|
||||
result);
|
||||
}
|
||||
|
||||
public void testCyclicArrays() {
|
||||
{
|
||||
Object[] cyclicA = new Object[1];
|
||||
cyclicA[0] = cyclicA;
|
||||
assertEquals("[[...]]", MessageFormatter.arrayFormat("{}", cyclicA));
|
||||
}
|
||||
{
|
||||
Object[] a = new Object[2];
|
||||
a[0] = i1;
|
||||
Object[] c = new Object[] {i3, a};
|
||||
Object[] b = new Object[] {i2, c};
|
||||
a[1] = b;
|
||||
assertEquals("1[2, [3, [1, [...]]]]", MessageFormatter.arrayFormat("{}{}", a));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,56 +1,56 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
|
||||
class MyRandom {
|
||||
|
||||
private static final long serialVersionUID = -907426287094698288L;
|
||||
|
||||
private final static long m = 200000000041L; // a prime number
|
||||
private final static long a = 2000000011L; // a prime number
|
||||
|
||||
long y;
|
||||
long unused;
|
||||
int bits = 32;
|
||||
|
||||
public MyRandom() {
|
||||
this(System.nanoTime());
|
||||
}
|
||||
|
||||
|
||||
public MyRandom(long seed) {
|
||||
this.y = seed;
|
||||
}
|
||||
|
||||
|
||||
int nextInt() {
|
||||
// we don't really care about the randomness of this
|
||||
// generator
|
||||
y = (a*y + 1) % m;
|
||||
unused = y >>> (48-bits); // just exercise the >>> operator
|
||||
return (int)(y);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2008 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
package org.slf4j.helpers;
|
||||
|
||||
|
||||
class MyRandom {
|
||||
|
||||
private static final long serialVersionUID = -907426287094698288L;
|
||||
|
||||
private final static long m = 200000000041L; // a prime number
|
||||
private final static long a = 2000000011L; // a prime number
|
||||
|
||||
long y;
|
||||
long unused;
|
||||
int bits = 32;
|
||||
|
||||
public MyRandom() {
|
||||
this(System.nanoTime());
|
||||
}
|
||||
|
||||
|
||||
public MyRandom(long seed) {
|
||||
this.y = seed;
|
||||
}
|
||||
|
||||
|
||||
int nextInt() {
|
||||
// we don't really care about the randomness of this
|
||||
// generator
|
||||
y = (a*y + 1) % m;
|
||||
unused = y >>> (48-bits); // just exercise the >>> operator
|
||||
return (int)(y);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,105 +1,105 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-ext</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>SLF4J Extensions Module</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
<description>Extensions to the SLF4J API</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>${parent.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.cal10n</groupId>
|
||||
<artifactId>cal10n-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
<version>3.4.GA</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.4</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html -->
|
||||
<printSummary>false</printSummary>
|
||||
<forkMode>once</forkMode>
|
||||
<reportFormat>plain</reportFormat>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
<excludes>
|
||||
<exclude>**/AllTest.java</exclude>
|
||||
<exclude>**/PackageTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
|
||||
<Bundle-Description>${project.description}</Bundle-Description>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
<Premain-Class>org.slf4j.agent.AgentPremain</Premain-Class>
|
||||
<!-- what is the proper way to specify the maven full name? /ravn -->
|
||||
<Boot-Class-Path>../../../../javassist/javassist/3.4.GA/javassist-3.4.GA.jar javassist-3.4.GA.jar javassist.jar</Boot-Class-Path>
|
||||
</manifestEntries>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-parent</artifactId>
|
||||
<version>1.5.10</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-ext</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>SLF4J Extensions Module</name>
|
||||
|
||||
<url>http://www.slf4j.org</url>
|
||||
<description>Extensions to the SLF4J API</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>${parent.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.cal10n</groupId>
|
||||
<artifactId>cal10n-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javassist</groupId>
|
||||
<artifactId>javassist</artifactId>
|
||||
<version>3.4.GA</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>2.4</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.5</source>
|
||||
<target>1.5</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html -->
|
||||
<printSummary>false</printSummary>
|
||||
<forkMode>once</forkMode>
|
||||
<reportFormat>plain</reportFormat>
|
||||
<trimStackTrace>false</trimStackTrace>
|
||||
<excludes>
|
||||
<exclude>**/AllTest.java</exclude>
|
||||
<exclude>**/PackageTest.java</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifestEntries>
|
||||
<Bundle-Version>${parsedVersion.osgiVersion}</Bundle-Version>
|
||||
<Bundle-Description>${project.description}</Bundle-Description>
|
||||
<Implementation-Version>${project.version}</Implementation-Version>
|
||||
<Premain-Class>org.slf4j.agent.AgentPremain</Premain-Class>
|
||||
<!-- what is the proper way to specify the maven full name? /ravn -->
|
||||
<Boot-Class-Path>../../../../javassist/javassist/3.4.GA/javassist-3.4.GA.jar javassist-3.4.GA.jar javassist.jar</Boot-Class-Path>
|
||||
</manifestEntries>
|
||||
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<reporting>
|
||||
<plugins>
|
||||
|
||||
</plugins>
|
||||
</reporting>
|
||||
|
||||
</project>
|
||||
|
|
@ -1,61 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.slf4j;
|
||||
|
||||
import org.slf4j.MDC;
|
||||
|
||||
public class NDC {
|
||||
public final static String PREFIX = "NDC";
|
||||
|
||||
private static int size() {
|
||||
int i = 0;
|
||||
while (true) {
|
||||
String val = MDC.get(PREFIX + i);
|
||||
if (val != null) {
|
||||
i++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static void push(String val) {
|
||||
int next = size();
|
||||
MDC.put(PREFIX + next, val);
|
||||
}
|
||||
|
||||
public static String pop() {
|
||||
int next = size();
|
||||
if(next == 0) {
|
||||
return "";
|
||||
}
|
||||
int last = next-1;
|
||||
String key = PREFIX+last;
|
||||
String val = MDC.get(key);
|
||||
MDC.remove(key);
|
||||
return val;
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
package org.slf4j;
|
||||
|
||||
import org.slf4j.MDC;
|
||||
|
||||
public class NDC {
|
||||
public final static String PREFIX = "NDC";
|
||||
|
||||
private static int size() {
|
||||
int i = 0;
|
||||
while (true) {
|
||||
String val = MDC.get(PREFIX + i);
|
||||
if (val != null) {
|
||||
i++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public static void push(String val) {
|
||||
int next = size();
|
||||
MDC.put(PREFIX + next, val);
|
||||
}
|
||||
|
||||
public static String pop() {
|
||||
int next = size();
|
||||
if(next == 0) {
|
||||
return "";
|
||||
}
|
||||
int last = next-1;
|
||||
String key = PREFIX+last;
|
||||
String val = MDC.get(key);
|
||||
MDC.remove(key);
|
||||
return val;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,33 +1,33 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<p>"-javaagent" routines for SLF4J.</p>
|
||||
<p>The "-javaagent" flag provided in Java 5+ allows for writing
|
||||
agents in Java, which previously was possible in native code only. The
|
||||
full details are available at <a
|
||||
href="http://java.sun.com/javase/6/docs/api/java/lang/instrument/package-summary.html">http://java.sun.com/javase/6/docs/api/java/lang/instrument/package-summary.html</a>.
|
||||
|
||||
|
||||
Please notice that code made available to the java agent is also
|
||||
available to the actual program executed.</p>
|
||||
<p>The slf4j-ext-X.Y.Z.jar file provides such a java agent, which is
|
||||
implemented in AgentPremain.java. It is used by adding a -javaagent flag to the Java command line:
|
||||
|
||||
E.g.
|
||||
<pre><code>java HelloWorld</code></pre>
|
||||
is changed to
|
||||
<pre><code>java -javaagent:/path/to/slf4j-ext-X.Y.Z.jar=<em>OPTIONS</em> HelloWorld</code></pre>
|
||||
|
||||
What is actually done, depends on the <em>OPTIONS</em> passed to the agent. These are listed in AgentOptions.java.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
</head>
|
||||
|
||||
|
||||
<body>
|
||||
<p>"-javaagent" routines for SLF4J.</p>
|
||||
<p>The "-javaagent" flag provided in Java 5+ allows for writing
|
||||
agents in Java, which previously was possible in native code only. The
|
||||
full details are available at <a
|
||||
href="http://java.sun.com/javase/6/docs/api/java/lang/instrument/package-summary.html">http://java.sun.com/javase/6/docs/api/java/lang/instrument/package-summary.html</a>.
|
||||
|
||||
|
||||
Please notice that code made available to the java agent is also
|
||||
available to the actual program executed.</p>
|
||||
<p>The slf4j-ext-X.Y.Z.jar file provides such a java agent, which is
|
||||
implemented in AgentPremain.java. It is used by adding a -javaagent flag to the Java command line:
|
||||
|
||||
E.g.
|
||||
<pre><code>java HelloWorld</code></pre>
|
||||
is changed to
|
||||
<pre><code>java -javaagent:/path/to/slf4j-ext-X.Y.Z.jar=<em>OPTIONS</em> HelloWorld</code></pre>
|
||||
|
||||
What is actually done, depends on the <em>OPTIONS</em> passed to the agent. These are listed in AgentOptions.java.
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,175 +1,175 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package org.slf4j.cal10n;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.Marker;
|
||||
import org.slf4j.MarkerFactory;
|
||||
import org.slf4j.ext.LoggerWrapper;
|
||||
import org.slf4j.spi.LocationAwareLogger;
|
||||
|
||||
import ch.qos.cal10n.IMessageConveyor;
|
||||
import ch.qos.cal10n.MessageParameterObj;
|
||||
|
||||
/**
|
||||
* A logger specialized in localized logging. Localization is based in the <a
|
||||
* href="http://cal10n.qos.ch">CAL10N project</p>.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class LocLogger extends LoggerWrapper implements Logger {
|
||||
|
||||
private static final String FQCN = LocLogger.class.getName();
|
||||
|
||||
/**
|
||||
* Every localized message logged by a LocLogger will bear this marker. It
|
||||
* allows marker-aware implementations to perform additional processing on
|
||||
* localized messages.
|
||||
*/
|
||||
static Marker LOCALIZED = MarkerFactory.getMarker("LOCALIZED");
|
||||
|
||||
final IMessageConveyor imc;
|
||||
|
||||
public LocLogger(Logger logger, IMessageConveyor imc) {
|
||||
super(logger, LoggerWrapper.class.getName());
|
||||
if(imc == null) {
|
||||
throw new IllegalArgumentException("IMessageConveyor cannot be null");
|
||||
}
|
||||
this.imc = imc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a localized message at the TRACE level.
|
||||
*
|
||||
* @param key
|
||||
* the key used for localization
|
||||
* @param args
|
||||
* optional arguments
|
||||
*/
|
||||
public void trace(Enum<?> key, Object... args) {
|
||||
if (!logger.isTraceEnabled()) {
|
||||
return;
|
||||
}
|
||||
String translatedMsg = imc.getMessage(key, args);
|
||||
MessageParameterObj mpo = new MessageParameterObj(key, args);
|
||||
|
||||
if (instanceofLAL) {
|
||||
((LocationAwareLogger) logger).log(LOCALIZED, FQCN,
|
||||
LocationAwareLogger.TRACE_INT, translatedMsg, null);
|
||||
} else {
|
||||
logger.trace(LOCALIZED, translatedMsg, mpo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a localized message at the DEBUG level.
|
||||
*
|
||||
* @param key
|
||||
* the key used for localization
|
||||
* @param args
|
||||
* optional arguments
|
||||
*/
|
||||
public void debug(Enum<?> key, Object... args) {
|
||||
if (!logger.isDebugEnabled()) {
|
||||
return;
|
||||
}
|
||||
String translatedMsg = imc.getMessage(key, args);
|
||||
MessageParameterObj mpo = new MessageParameterObj(key, args);
|
||||
|
||||
if (instanceofLAL) {
|
||||
((LocationAwareLogger) logger).log(LOCALIZED, FQCN,
|
||||
LocationAwareLogger.DEBUG_INT, translatedMsg, null);
|
||||
} else {
|
||||
logger.debug(LOCALIZED, translatedMsg, mpo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a localized message at the INFO level.
|
||||
*
|
||||
* @param key
|
||||
* the key used for localization
|
||||
* @param args
|
||||
* optional arguments
|
||||
*/
|
||||
public void info(Enum<?> key, Object... args) {
|
||||
if (!logger.isInfoEnabled()) {
|
||||
return;
|
||||
}
|
||||
String translatedMsg = imc.getMessage(key, args);
|
||||
MessageParameterObj mpo = new MessageParameterObj(key, args);
|
||||
|
||||
if (instanceofLAL) {
|
||||
((LocationAwareLogger) logger).log(LOCALIZED, FQCN,
|
||||
LocationAwareLogger.INFO_INT, translatedMsg, null);
|
||||
} else {
|
||||
logger.info(LOCALIZED, translatedMsg, mpo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a localized message at the WARN level.
|
||||
*
|
||||
* @param key
|
||||
* the key used for localization
|
||||
* @param args
|
||||
* optional arguments
|
||||
*/
|
||||
public void warn(Enum<?> key, Object... args) {
|
||||
if (!logger.isWarnEnabled()) {
|
||||
return;
|
||||
}
|
||||
String translatedMsg = imc.getMessage(key, args);
|
||||
MessageParameterObj mpo = new MessageParameterObj(key, args);
|
||||
|
||||
if (instanceofLAL) {
|
||||
((LocationAwareLogger) logger).log(LOCALIZED, FQCN,
|
||||
LocationAwareLogger.WARN_INT, translatedMsg, null);
|
||||
} else {
|
||||
logger.warn(LOCALIZED, translatedMsg, mpo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a localized message at the ERROR level.
|
||||
*
|
||||
* @param key
|
||||
* the key used for localization
|
||||
* @param args
|
||||
* optional arguments
|
||||
*/
|
||||
public void error(Enum<?> key, Object... args) {
|
||||
if (!logger.isErrorEnabled()) {
|
||||
return;
|
||||
}
|
||||
String translatedMsg = imc.getMessage(key, args);
|
||||
MessageParameterObj mpo = new MessageParameterObj(key, args);
|
||||
|
||||
if (instanceofLAL) {
|
||||
((LocationAwareLogger) logger).log(LOCALIZED, FQCN,
|
||||
LocationAwareLogger.ERROR_INT, translatedMsg, null);
|
||||
} else {
|
||||
logger.error(LOCALIZED, translatedMsg, mpo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2009 QOS.ch All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
package org.slf4j.cal10n;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.Marker;
|
||||
import org.slf4j.MarkerFactory;
|
||||
import org.slf4j.ext.LoggerWrapper;
|
||||
import org.slf4j.spi.LocationAwareLogger;
|
||||
|
||||
import ch.qos.cal10n.IMessageConveyor;
|
||||
import ch.qos.cal10n.MessageParameterObj;
|
||||
|
||||
/**
|
||||
* A logger specialized in localized logging. Localization is based in the <a
|
||||
* href="http://cal10n.qos.ch">CAL10N project</p>.
|
||||
*
|
||||
* @author Ceki Gülcü
|
||||
*/
|
||||
public class LocLogger extends LoggerWrapper implements Logger {
|
||||
|
||||
private static final String FQCN = LocLogger.class.getName();
|
||||
|
||||
/**
|
||||
* Every localized message logged by a LocLogger will bear this marker. It
|
||||
* allows marker-aware implementations to perform additional processing on
|
||||
* localized messages.
|
||||
*/
|
||||
static Marker LOCALIZED = MarkerFactory.getMarker("LOCALIZED");
|
||||
|
||||
final IMessageConveyor imc;
|
||||
|
||||
public LocLogger(Logger logger, IMessageConveyor imc) {
|
||||
super(logger, LoggerWrapper.class.getName());
|
||||
if(imc == null) {
|
||||
throw new IllegalArgumentException("IMessageConveyor cannot be null");
|
||||
}
|
||||
this.imc = imc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a localized message at the TRACE level.
|
||||
*
|
||||
* @param key
|
||||
* the key used for localization
|
||||
* @param args
|
||||
* optional arguments
|
||||
*/
|
||||
public void trace(Enum<?> key, Object... args) {
|
||||
if (!logger.isTraceEnabled()) {
|
||||
return;
|
||||
}
|
||||
String translatedMsg = imc.getMessage(key, args);
|
||||
MessageParameterObj mpo = new MessageParameterObj(key, args);
|
||||
|
||||
if (instanceofLAL) {
|
||||
((LocationAwareLogger) logger).log(LOCALIZED, FQCN,
|
||||
LocationAwareLogger.TRACE_INT, translatedMsg, null);
|
||||
} else {
|
||||
logger.trace(LOCALIZED, translatedMsg, mpo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a localized message at the DEBUG level.
|
||||
*
|
||||
* @param key
|
||||
* the key used for localization
|
||||
* @param args
|
||||
* optional arguments
|
||||
*/
|
||||
public void debug(Enum<?> key, Object... args) {
|
||||
if (!logger.isDebugEnabled()) {
|
||||
return;
|
||||
}
|
||||
String translatedMsg = imc.getMessage(key, args);
|
||||
MessageParameterObj mpo = new MessageParameterObj(key, args);
|
||||
|
||||
if (instanceofLAL) {
|
||||
((LocationAwareLogger) logger).log(LOCALIZED, FQCN,
|
||||
LocationAwareLogger.DEBUG_INT, translatedMsg, null);
|
||||
} else {
|
||||
logger.debug(LOCALIZED, translatedMsg, mpo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a localized message at the INFO level.
|
||||
*
|
||||
* @param key
|
||||
* the key used for localization
|
||||
* @param args
|
||||
* optional arguments
|
||||
*/
|
||||
public void info(Enum<?> key, Object... args) {
|
||||
if (!logger.isInfoEnabled()) {
|
||||
return;
|
||||
}
|
||||
String translatedMsg = imc.getMessage(key, args);
|
||||
MessageParameterObj mpo = new MessageParameterObj(key, args);
|
||||
|
||||
if (instanceofLAL) {
|
||||
((LocationAwareLogger) logger).log(LOCALIZED, FQCN,
|
||||
LocationAwareLogger.INFO_INT, translatedMsg, null);
|
||||
} else {
|
||||
logger.info(LOCALIZED, translatedMsg, mpo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a localized message at the WARN level.
|
||||
*
|
||||
* @param key
|
||||
* the key used for localization
|
||||
* @param args
|
||||
* optional arguments
|
||||
*/
|
||||
public void warn(Enum<?> key, Object... args) {
|
||||
if (!logger.isWarnEnabled()) {
|
||||
return;
|
||||
}
|
||||
String translatedMsg = imc.getMessage(key, args);
|
||||
MessageParameterObj mpo = new MessageParameterObj(key, args);
|
||||
|
||||
if (instanceofLAL) {
|
||||
((LocationAwareLogger) logger).log(LOCALIZED, FQCN,
|
||||
LocationAwareLogger.WARN_INT, translatedMsg, null);
|
||||
} else {
|
||||
logger.warn(LOCALIZED, translatedMsg, mpo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a localized message at the ERROR level.
|
||||
*
|
||||
* @param key
|
||||
* the key used for localization
|
||||
* @param args
|
||||
* optional arguments
|
||||
*/
|
||||
public void error(Enum<?> key, Object... args) {
|
||||
if (!logger.isErrorEnabled()) {
|
||||
return;
|
||||
}
|
||||
String translatedMsg = imc.getMessage(key, args);
|
||||
MessageParameterObj mpo = new MessageParameterObj(key, args);
|
||||
|
||||
if (instanceofLAL) {
|
||||
((LocationAwareLogger) logger).log(LOCALIZED, FQCN,
|
||||
LocationAwareLogger.ERROR_INT, translatedMsg, null);
|
||||
} else {
|
||||
logger.error(LOCALIZED, translatedMsg, mpo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue