This repository has been archived by the owner on Jun 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RustApiOptions.cs
49 lines (44 loc) · 1.47 KB
/
RustApiOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Oxide.Ext.RustApi.Primitives.Enums;
using System;
using System.ComponentModel;
namespace Oxide.Ext.RustApi.Primitives.Models
{
/// <summary>
/// Api server options.
/// </summary>
internal class RustApiOptions
{
public RustApiOptions(
string endpoint,
bool logToFile = false,
MinimumLogLevel logLevel = MinimumLogLevel.Information
)
{
if (!Enum.IsDefined(typeof(MinimumLogLevel), logLevel))
throw new InvalidEnumArgumentException(nameof(logLevel), (int)logLevel, typeof(MinimumLogLevel));
Endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint));
LogToFile = logToFile;
LogLevel = logLevel;
}
/// <summary>
/// Endpoint string. (e.g. http://localhost:6667).
/// </summary>
public string Endpoint { get; }
/// <summary>
/// Enable logs storing into file
/// </summary>
public bool LogToFile { get; }
/// <summary>
/// Log level
/// Disable - Disable (no logs)
/// Error - Errors only (default value)
/// Warning - Warnings and previous
/// Information - Info and previous
/// Debug - Debug and previous (all logs)
/// </summary>
[JsonConverter(typeof(StringEnumConverter))]
public MinimumLogLevel LogLevel { get; }
}
}