[
  {iot, [
    {http_server, [
      {port, 18090},
      {acceptors, 5},
      {max_connections, 1024},
      {backlog, 1024}
    ]},

    {ssl_server, [
      {port, 1443},
      {acceptors, 5},
      {max_connections, 1024},
      {backlog, 1024}
    ]},

    {udp_server, [
      {port, 24000}
    ]},

    {ctrl_server, [
      {socket_path, "${IOT_CTRL_SOCKET_PATH:-/var/lib/iot/ctl.sock}"},
      {backlog, ${IOT_CTRL_SOCKET_BACKLOG:-128}}
    ]},

    {api_url, "${IOT_API_URL}"}
  ]},

  {endpoint, [
    %% 支持的协议
    {endpoints, [
      {root_dir, "${ENDPOINT_ROOT_DIR}"},
      {support_protocols, [
        http
      ]}
    ]},

    {endpoint_log, [
      {path, "${ENDPOINT_LOG_PATH}"},
      {max_bytes, ${ENDPOINT_LOG_MAX_BYTES:-10485760}},
      {max_files, ${ENDPOINT_LOG_MAX_FILES:-10}}
    ]}
  ]},

  %% 系统日志配置，使用 OTP logger
  {kernel, [
    %% 设置 Logger 的 primary log level
    {logger_level, ${IOT_LOG_LEVEL:-debug}},
    {logger, [
      {handler, default, logger_std_h,
        #{
          level => ${IOT_CONSOLE_LOG_LEVEL:-debug},
          filter_default => stop,
          filters => [
            {iot_domain, {fun logger_filters:domain/2, {log, sub, [iot]}}},
            {endpoint_domain, {fun logger_filters:domain/2, {log, sub, [endpoint]}}}
          ],
          formatter => {logger_formatter, #{template => [time, " [", level, "] ", msg, "\n"]}}
        }
      },

      {handler, disk, logger_disk_log_h,
        #{
          level => ${IOT_DISK_LOG_LEVEL:-debug},
          filter_default => stop,
          filters => [
            {iot_domain, {fun logger_filters:domain/2, {log, sub, [iot]}}},
            {endpoint_domain, {fun logger_filters:domain/2, {log, sub, [endpoint]}}}
          ],
          config => #{
            file => "${IOT_DISK_LOG_FILE:-log/debug.log}",
            max_no_files => ${IOT_DISK_LOG_MAX_FILES:-10},
            max_no_bytes => ${IOT_DISK_LOG_MAX_BYTES:-524288000}
          },
          formatter => {logger_formatter, #{template => [time, " [", level, "] ", msg, "\n"]}}
        }
      }

    ]}
  ]}

].
