1/*
2 * Copyright (c) 2023 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15package ohos;
16
17import java.text.DateFormat;
18import java.text.SimpleDateFormat;
19import java.util.Date;
20import java.util.logging.Formatter;
21import java.util.logging.LogRecord;
22
23/**
24 * Pack for matter
25 *
26 */
27public class PackFormatter extends Formatter {
28    private static final int LOG_MAX_LIMIT = 1000;
29    private static final DateFormat DF = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss.SSS");
30
31    @Override
32
33    /**
34     * format builder
35     *
36     * @param Log limit size
37     * @return string builder
38     */
39    public String format(LogRecord record) {
40        StringBuilder builder = new StringBuilder(LOG_MAX_LIMIT);
41        builder.append(DF.format(new Date(record.getMillis()))).append(" - ");
42        builder.append(formatMessage(record));
43        builder.append(System.lineSeparator());
44        return builder.toString();
45    }
46}