﻿/*
 * 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.
 */

using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging;
using System;
using System.Threading.Tasks;

namespace Apache.IoTDB.Samples
{
    public static class Program
    {
        public static async Task Main(string[] args)
        {
            var utilsTest = new UtilsTest();
            utilsTest.TestParseEndPoint();
            var sessionPoolTest = new SessionPoolTest("iotdb");
            await sessionPoolTest.Test();
        }

        public static void OpenDebugMode(this SessionPool session)
        {
            session.OpenDebugMode(builder =>
            {
                builder.AddConsole();
                builder.AddNLog();
            });
        }
    }
}
