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.Log
26 {
27  internal static class LogExtensions
28  {
29  internal static void DestinationFileError(this LogBase log, string file, Exception e)
30  {
31  log.WriteLine(
32  $"Could not write file {file}",
33  e != null ? Severity.Warn : Severity.Notice);
34 
35  if (e != null)
36  {
37  log.WriteLine(e, Severity.Trace);
38  }
39  }
40 
41  internal static void DestinationNewDirectory(this LogBase log, string created)
42  {
43  log.WriteLine(
44  $"Created new directory {created}",
45  Severity.Notice);
46  }
47 
48  internal static void DestinationOwnerError(this LogBase log, string file, Exception e = null)
49  {
50  log.WriteLine(
51  $"Could not change ownership of file {file}",
52  e != null ? Severity.Warn : Severity.Notice);
53 
54  if (e != null)
55  {
56  log.WriteLine(e, Severity.Trace);
57  }
58  }
59 
60  internal static void DestinationPathError(this LogBase log, string file, Exception e)
61  {
62  log.WriteLine(
63  $"Could not create path for file {file}",
64  e != null ? Severity.Warn : Severity.Notice);
65 
66  if (e != null)
67  {
68  log.WriteLine(e, Severity.Trace);
69  }
70  }
71 
72  internal static void DestinationPermissionError(this LogBase log, string file, Exception e = null)
73  {
74  log.WriteLine(
75  $"Could not change permission on file {file}",
76  e != null ? Severity.Warn : Severity.Notice);
77 
78  if (e != null)
79  {
80  log.WriteLine(e, Severity.Trace);
81  }
82  }
83 
84  internal static void WroteFile(this LogBase log, string file)
85  {
86  log.WriteLine(
87  $"Wrote new file {file}",
88  Severity.Debug);
89  }
90  }
91 }
abstract void WriteLine(string text, Severity severity)
static void WroteFile(this LogBase log, string file)
static void DestinationNewDirectory(this LogBase log, string created)
var e
Definition: bootstrap.min.js:6
static void DestinationPathError(this LogBase log, string file, Exception e)
static void DestinationPermissionError(this LogBase log, string file, Exception e=null)
static void DestinationFileError(this LogBase log, string file, Exception e)
static void DestinationOwnerError(this LogBase log, string file, Exception e=null)