You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Matt Sicker <bo...@gmail.com> on 2016/02/22 18:42:35 UTC
Fwd: [1/2] logging-log4j2 git commit: LOG4J2-1293 StringBuilderFormattable
initial version
Could this be weakened to use Appendable instead of StringBuilder?
---------- Forwarded message ----------
From: <rp...@apache.org>
Date: 21 February 2016 at 23:58
Subject: [1/2] logging-log4j2 git commit: LOG4J2-1293
StringBuilderFormattable initial version
To: commits@logging.apache.org
Repository: logging-log4j2
Updated Branches:
refs/heads/master aa5bc42bd -> 33ef3f81d
LOG4J2-1293 StringBuilderFormattable initial version
Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit:
http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/a2c9ba8e
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/a2c9ba8e
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/a2c9ba8e
Branch: refs/heads/master
Commit: a2c9ba8e2c859094df4d91b894302179e723f198
Parents: 7ff4c96
Author: rpopma <rp...@apache.org>
Authored: Mon Feb 22 14:58:08 2016 +0900
Committer: rpopma <rp...@apache.org>
Committed: Mon Feb 22 14:58:08 2016 +0900
----------------------------------------------------------------------
.../log4j/util/StringBuilderFormattable.java | 33 ++++++++++++++++++++
1 file changed, 33 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a2c9ba8e/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
----------------------------------------------------------------------
diff --git
a/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
b/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
new file mode 100644
index 0000000..5da9b61
--- /dev/null
+++
b/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
@@ -0,0 +1,33 @@
+/*
+ * 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.logging.log4j.util;
+
+/**
+ * Objects that implement this interface can be converted to text without
allocating temporary objects.
+ *
+ * @since 2.6s
+ */
+public interface StringBuilderFormattable {
+
+ /**
+ * Writes a text representation of this object into the specified
{@code StringBuilder}, ideally without allocating
+ * temporary objects.
+ *
+ * @param buffer the StringBuilder to write into
+ */
+ void formatTo(StringBuilder buffer);
+}
--
Matt Sicker <bo...@gmail.com>
Re: [1/2] logging-log4j2 git commit: LOG4J2-1293 StringBuilderFormattable
initial version
Posted by Matt Sicker <bo...@gmail.com>.
Alright, that makes sense. StringBuilder works fine for me as long as we
don't one day decide to use a CharBuffer instead or something. ;)
On 22 February 2016 at 17:24, Gary Gregory <ga...@gmail.com> wrote:
> Appendable is not rich enough IMO.
>
> Creating a custom interface and then a StringBuilder wrapper seems like a
> lot for perhaps no gain beyond the abstraction. Since there is no use case
> for this abstraction now, YAGNI, let's stick with StringBuilder IMO.
>
> Gary
> On Feb 22, 2016 2:35 PM, "Remko Popma" <re...@gmail.com> wrote:
>
>> I agree it is preferable to use an interface, but the API that Appendable
>> offers is not nearly as rich as StringBuilder's. :-(
>> Specifically, I want to leverage StringBuilder's excellent support for
>> primitives. It also has special support for classes known to hold char[]
>> data.
>>
>> Sent from my iPhone
>>
>> On 2016/02/23, at 2:42, Matt Sicker <bo...@gmail.com> wrote:
>>
>> Could this be weakened to use Appendable instead of StringBuilder?
>>
>> ---------- Forwarded message ----------
>> From: <rp...@apache.org>
>> Date: 21 February 2016 at 23:58
>> Subject: [1/2] logging-log4j2 git commit: LOG4J2-1293
>> StringBuilderFormattable initial version
>> To: commits@logging.apache.org
>>
>>
>> Repository: logging-log4j2
>> Updated Branches:
>> refs/heads/master aa5bc42bd -> 33ef3f81d
>>
>>
>> LOG4J2-1293 StringBuilderFormattable initial version
>>
>>
>> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
>> Commit:
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/a2c9ba8e
>> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/a2c9ba8e
>> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/a2c9ba8e
>>
>> Branch: refs/heads/master
>> Commit: a2c9ba8e2c859094df4d91b894302179e723f198
>> Parents: 7ff4c96
>> Author: rpopma <rp...@apache.org>
>> Authored: Mon Feb 22 14:58:08 2016 +0900
>> Committer: rpopma <rp...@apache.org>
>> Committed: Mon Feb 22 14:58:08 2016 +0900
>>
>> ----------------------------------------------------------------------
>> .../log4j/util/StringBuilderFormattable.java | 33 ++++++++++++++++++++
>> 1 file changed, 33 insertions(+)
>> ----------------------------------------------------------------------
>>
>>
>>
>> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a2c9ba8e/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
>> ----------------------------------------------------------------------
>> diff --git
>> a/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
>> b/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
>> new file mode 100644
>> index 0000000..5da9b61
>> --- /dev/null
>> +++
>> b/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
>> @@ -0,0 +1,33 @@
>> +/*
>> + * 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.logging.log4j.util;
>> +
>> +/**
>> + * Objects that implement this interface can be converted to text
>> without allocating temporary objects.
>> + *
>> + * @since 2.6s
>> + */
>> +public interface StringBuilderFormattable {
>> +
>> + /**
>> + * Writes a text representation of this object into the specified
>> {@code StringBuilder}, ideally without allocating
>> + * temporary objects.
>> + *
>> + * @param buffer the StringBuilder to write into
>> + */
>> + void formatTo(StringBuilder buffer);
>> +}
>>
>>
>>
>>
>> --
>> Matt Sicker <bo...@gmail.com>
>>
>>
--
Matt Sicker <bo...@gmail.com>
Re: [1/2] logging-log4j2 git commit: LOG4J2-1293 StringBuilderFormattable
initial version
Posted by Gary Gregory <ga...@gmail.com>.
Appendable is not rich enough IMO.
Creating a custom interface and then a StringBuilder wrapper seems like a
lot for perhaps no gain beyond the abstraction. Since there is no use case
for this abstraction now, YAGNI, let's stick with StringBuilder IMO.
Gary
On Feb 22, 2016 2:35 PM, "Remko Popma" <re...@gmail.com> wrote:
> I agree it is preferable to use an interface, but the API that Appendable
> offers is not nearly as rich as StringBuilder's. :-(
> Specifically, I want to leverage StringBuilder's excellent support for
> primitives. It also has special support for classes known to hold char[]
> data.
>
> Sent from my iPhone
>
> On 2016/02/23, at 2:42, Matt Sicker <bo...@gmail.com> wrote:
>
> Could this be weakened to use Appendable instead of StringBuilder?
>
> ---------- Forwarded message ----------
> From: <rp...@apache.org>
> Date: 21 February 2016 at 23:58
> Subject: [1/2] logging-log4j2 git commit: LOG4J2-1293
> StringBuilderFormattable initial version
> To: commits@logging.apache.org
>
>
> Repository: logging-log4j2
> Updated Branches:
> refs/heads/master aa5bc42bd -> 33ef3f81d
>
>
> LOG4J2-1293 StringBuilderFormattable initial version
>
>
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit:
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/a2c9ba8e
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/a2c9ba8e
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/a2c9ba8e
>
> Branch: refs/heads/master
> Commit: a2c9ba8e2c859094df4d91b894302179e723f198
> Parents: 7ff4c96
> Author: rpopma <rp...@apache.org>
> Authored: Mon Feb 22 14:58:08 2016 +0900
> Committer: rpopma <rp...@apache.org>
> Committed: Mon Feb 22 14:58:08 2016 +0900
>
> ----------------------------------------------------------------------
> .../log4j/util/StringBuilderFormattable.java | 33 ++++++++++++++++++++
> 1 file changed, 33 insertions(+)
> ----------------------------------------------------------------------
>
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a2c9ba8e/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
> ----------------------------------------------------------------------
> diff --git
> a/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
> b/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
> new file mode 100644
> index 0000000..5da9b61
> --- /dev/null
> +++
> b/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
> @@ -0,0 +1,33 @@
> +/*
> + * 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.logging.log4j.util;
> +
> +/**
> + * Objects that implement this interface can be converted to text without
> allocating temporary objects.
> + *
> + * @since 2.6s
> + */
> +public interface StringBuilderFormattable {
> +
> + /**
> + * Writes a text representation of this object into the specified
> {@code StringBuilder}, ideally without allocating
> + * temporary objects.
> + *
> + * @param buffer the StringBuilder to write into
> + */
> + void formatTo(StringBuilder buffer);
> +}
>
>
>
>
> --
> Matt Sicker <bo...@gmail.com>
>
>
Re: [1/2] logging-log4j2 git commit: LOG4J2-1293 StringBuilderFormattable initial version
Posted by Remko Popma <re...@gmail.com>.
I agree it is preferable to use an interface, but the API that Appendable offers is not nearly as rich as StringBuilder's. :-(
Specifically, I want to leverage StringBuilder's excellent support for primitives. It also has special support for classes known to hold char[] data.
Sent from my iPhone
> On 2016/02/23, at 2:42, Matt Sicker <bo...@gmail.com> wrote:
>
> Could this be weakened to use Appendable instead of StringBuilder?
>
> ---------- Forwarded message ----------
> From: <rp...@apache.org>
> Date: 21 February 2016 at 23:58
> Subject: [1/2] logging-log4j2 git commit: LOG4J2-1293 StringBuilderFormattable initial version
> To: commits@logging.apache.org
>
>
> Repository: logging-log4j2
> Updated Branches:
> refs/heads/master aa5bc42bd -> 33ef3f81d
>
>
> LOG4J2-1293 StringBuilderFormattable initial version
>
>
> Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
> Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/a2c9ba8e
> Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/a2c9ba8e
> Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/a2c9ba8e
>
> Branch: refs/heads/master
> Commit: a2c9ba8e2c859094df4d91b894302179e723f198
> Parents: 7ff4c96
> Author: rpopma <rp...@apache.org>
> Authored: Mon Feb 22 14:58:08 2016 +0900
> Committer: rpopma <rp...@apache.org>
> Committed: Mon Feb 22 14:58:08 2016 +0900
>
> ----------------------------------------------------------------------
> .../log4j/util/StringBuilderFormattable.java | 33 ++++++++++++++++++++
> 1 file changed, 33 insertions(+)
> ----------------------------------------------------------------------
>
>
> http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a2c9ba8e/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
> ----------------------------------------------------------------------
> diff --git a/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java b/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
> new file mode 100644
> index 0000000..5da9b61
> --- /dev/null
> +++ b/log4j-api/src/main/java/org/apache/logging/log4j/util/StringBuilderFormattable.java
> @@ -0,0 +1,33 @@
> +/*
> + * 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.logging.log4j.util;
> +
> +/**
> + * Objects that implement this interface can be converted to text without allocating temporary objects.
> + *
> + * @since 2.6s
> + */
> +public interface StringBuilderFormattable {
> +
> + /**
> + * Writes a text representation of this object into the specified {@code StringBuilder}, ideally without allocating
> + * temporary objects.
> + *
> + * @param buffer the StringBuilder to write into
> + */
> + void formatTo(StringBuilder buffer);
> +}
>
>
>
>
> --
> Matt Sicker <bo...@gmail.com>