NTP Analyzer  0.8.2
Analyze the operation of time servers
LogExtensions.cs
Go to the documentation of this file.
1 //
2 // Copyright (c) 2013-2017 Carsten Sonne Larsen <cs@innolan.net>
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to deal
6 // in the Software without restriction, including without limitation the rights
7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 // copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
10 //
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
13 //
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 // THE SOFTWARE.
21 
22 using System;
23 using Ntp.Common.Log;
24 
25 namespace Ntp.Analyzer.Import
26 {
27  internal static class LogMessage
28  {
29  internal const string ImportHostError = "Error while reading host statistics.";
30  internal const string ImportPeerError = "Error while reading peer statistics.";
31  internal const string ImportIoError = "Error while reading I/O statistics.";
32  }
33 
34  internal static class LogExtensions
35  {
36  internal static void DriftFileReadError(this LogBase log, string host, string file, Exception e)
37  {
38  log.WriteLine(
39  $"Could not read drift file {file} on host {host}: {e.Message}",
40  Severity.Warn);
41 
42  log.WriteLine(e, Severity.Trace);
43  }
44 
45  internal static void DriftReadError(this LogBase log, string host, string file)
46  {
47  log.WriteLine(
48  $"Could not read content of drift file {file} on host {host}.",
49  Severity.Warn);
50  }
51 
52  internal static void MultiplePeersFound(this LogBase log, string host, string peerIp)
53  {
54  log.WriteLine(
55  $"Could not import host stats from {host}. Found more than one peer with IP {peerIp} in database.",
56  Severity.Warn);
57  }
58 
59  internal static void NoSyncing(this LogBase log, string host)
60  {
61  log.WriteLine(
62  $"{host} is not syncing. Adjust clock to start sync.",
63  Severity.Warn);
64  }
65 
66  internal static void NtpValueError(this LogBase log, string name)
67  {
68  log.WriteLine(
69  $"Received an unknown value from NTP Daemon: {name}",
70  Severity.Warn);
71  }
72 
73  internal static void OpenNtpUnsynced(this LogBase log)
74  {
75  log.WriteLine(
76  "OpenNTP clock is unsynced.",
77  Severity.Info);
78  }
79 
80  internal static void PeerNotFound(this LogBase log, string host, string peerIp)
81  {
82  log.WriteLine(
83  $"Could not import host stats from {host}. Peer with IP {peerIp} was not found in database.",
84  Severity.Warn);
85  }
86 
87  internal static void Syncing(this LogBase log, string host, string peer)
88  {
89  log.WriteLine(
90  $"{host} is syncing to {peer}.",
91  Severity.Info);
92  }
93  }
94 }
abstract void WriteLine(string text, Severity severity)
static void MultiplePeersFound(this LogBase log, string host, string peerIp)
static void DriftFileReadError(this LogBase log, string host, string file, Exception e)
static void NoSyncing(this LogBase log, string host)
var e
Definition: bootstrap.min.js:6
static void DriftReadError(this LogBase log, string host, string file)
static void PeerNotFound(this LogBase log, string host, string peerIp)
static void NtpValueError(this LogBase log, string name)
static void Syncing(this LogBase log, string host, string peer)
static void OpenNtpUnsynced(this LogBase log)