NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Data.Log.LogExtensions Class Reference

Static Public Member Functions

static void SqlExecute (this LogBase log, string sql)
 
static void SqlExecute (this LogBase log, string sql, IDataParameterCollection parameters)
 

Static Package Functions

static void ApplySchemaChanges (this LogBase log)
 
static void AwaitingDbLink (this LogBase log, IDbConnection connection)
 
static void DbLinkDown (this LogBase log)
 
static void DbLinkError (this LogBase log, Exception e)
 
static void DbLinkUp (this LogBase log)
 
static void SchemaChangesApplied (this LogBase log, string version)
 
static void SchemaUpdated (this LogBase log, string version)
 
static void SchemaUpdateError (this LogBase log, Exception e)
 
static void SchemaUpToDate (this LogBase log)
 
static void SchemaVersionError (this LogBase log, int database, int application)
 
static void VersionTableCreated (this LogBase log)
 
static void VersionTableCreateError (this LogBase log, Exception e)
 
static void VersionTableFetchError (this LogBase log, Exception e)
 
static void VersionTableInsertError (this LogBase log, Exception e)
 
static void VersionTableParamError (this LogBase log)
 
static void VersionTableUpdateError (this LogBase log, Exception e)
 

Static Private Member Functions

static string GetDbDataParameterValue (IDataParameter p)
 

Detailed Description

Definition at line 27 of file LogExtensions.cs.

Member Function Documentation

static void Ntp.Data.Log.LogExtensions.ApplySchemaChanges ( this LogBase  log)
inlinestaticpackage

Definition at line 48 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

49  {
50  log.WriteLine(
51  "Applying database changes...",
52  Severity.Notice);
53  }

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.AwaitingDbLink ( this LogBase  log,
IDbConnection  connection 
)
inlinestaticpackage

Definition at line 55 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

56  {
57  log.WriteLine(
58  "Waiting for database link.",
59  Severity.Info);
60 
61  log.WriteLine(
62  $"Database connection timeout is {connection.ConnectionTimeout} seconds.",
63  Severity.Debug);
64 
65  log.WriteLine(
66  "DATABASE CONNECTION STRING COULD CONTAIN SENSITIVE INFORMATION.",
67  Severity.Trace);
68 
69  log.WriteLine(
70  $"DATABASE CONNECTION STRING IS [{connection.ConnectionString}]",
71  Severity.Trace);
72  }

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.DbLinkDown ( this LogBase  log)
inlinestaticpackage

Definition at line 74 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

75  {
76  log.WriteLine("Database link is down.", Severity.Notice);
77  }

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.DbLinkError ( this LogBase  log,
Exception  e 
)
inlinestaticpackage

Definition at line 79 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

80  {
81  log.WriteLine(e.Message, Severity.Info);
82  }
var e
Definition: bootstrap.min.js:6

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.DbLinkUp ( this LogBase  log)
inlinestaticpackage

Definition at line 84 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

85  {
86  log.WriteLine("Database link is up.", Severity.Notice);
87  }

Here is the call graph for this function:

static string Ntp.Data.Log.LogExtensions.GetDbDataParameterValue ( IDataParameter  p)
inlinestaticprivate

Definition at line 165 of file LogExtensions.cs.

166  {
167  switch (p.DbType)
168  {
169  case DbType.AnsiString:
170  case DbType.AnsiStringFixedLength:
171  case DbType.Guid:
172  case DbType.String:
173  case DbType.StringFixedLength:
174  case DbType.Xml:
175  return $"\'{p.Value.ToString().Replace("'", "''")}\'";
176  case DbType.Time:
177  return p.Value.ToString();
178  case DbType.Date:
179  case DbType.DateTime:
180  return $"\'{Convert.ToDateTime(p.Value).ToString("yyyy-MM-dd HH:mm:ss")}\'";
181  case DbType.DateTime2:
182  case DbType.DateTimeOffset:
183  return p.Value.ToString();
184  case DbType.Object:
185  return p.Value.ToString();
186  case DbType.Binary:
187  return "{binary}";
188  case DbType.Boolean:
189  return Convert.ToBoolean(p.Value) ? "1" : "0";
190  case DbType.Byte:
191  case DbType.SByte:
192  case DbType.Int16:
193  case DbType.Int32:
194  case DbType.Int64:
195  case DbType.UInt16:
196  case DbType.UInt32:
197  case DbType.UInt64:
198  return p.Value.ToString();
199  case DbType.Single:
200  case DbType.Double:
201  case DbType.Decimal:
202  case DbType.Currency:
203  case DbType.VarNumeric:
204  return p.Value.ToString();
205  default:
206  return p.Value.ToString();
207  }
208  }
static void Ntp.Data.Log.LogExtensions.SchemaChangesApplied ( this LogBase  log,
string  version 
)
inlinestaticpackage

Definition at line 89 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

90  {
91  log.WriteLine($"Changes for version {version} applied.", Severity.Notice);
92  }

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.SchemaUpdated ( this LogBase  log,
string  version 
)
inlinestaticpackage

Definition at line 94 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

95  {
96  log.WriteLine($"Database schema updated to version {version}", Severity.Notice);
97  }

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.SchemaUpdateError ( this LogBase  log,
Exception  e 
)
inlinestaticpackage

Definition at line 99 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

100  {
101  log.WriteLine("Failed to apply database change script.", Severity.Error);
102  log.WriteLine(e);
103  }
var e
Definition: bootstrap.min.js:6

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.SchemaUpToDate ( this LogBase  log)
inlinestaticpackage

Definition at line 105 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

106  {
107  log.WriteLine("Database schema is latest version.", Severity.Info);
108  }

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.SchemaVersionError ( this LogBase  log,
int  database,
int  application 
)
inlinestaticpackage

Definition at line 110 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

111  {
112  if (database == -1)
113  {
114  log.WriteLine("Database version is -1. Did you set 'Create Yes' in configuration ?", Severity.Notice);
115  }
116 
117  log.WriteLine(
118  $"Application version is {application} but database version is {database}.",
119  Severity.Error);
120 
121  if (database > application)
122  {
123  log.WriteLine("Update NTP Analyzer to resolve this problem.", Severity.Info);
124  }
125  else if (database < application)
126  {
127  log.WriteLine("Upgrade your database to resolve this problem.", Severity.Info);
128  }
129  }

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.SqlExecute ( this LogBase  log,
string  sql 
)
inlinestatic

Definition at line 29 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

30  {
31  log.WriteLine(sql.Trim(), Severity.Trace);
32  }

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.SqlExecute ( this LogBase  log,
string  sql,
IDataParameterCollection  parameters 
)
inlinestatic

Definition at line 34 of file LogExtensions.cs.

35  {
36  string query = $"{sql} ";
37  foreach (IDataParameter parameter in parameters)
38  {
39  query = query.Replace($"{parameter.ParameterName} ", $"{GetDbDataParameterValue(parameter)} ");
40  query = query.Replace($"{parameter.ParameterName},", $"{GetDbDataParameterValue(parameter)},");
41  query = query.Replace($"{parameter.ParameterName};", $"{GetDbDataParameterValue(parameter)};");
42  query = query.Replace($"{parameter.ParameterName})", $"{GetDbDataParameterValue(parameter)})");
43  }
44 
45  log.WriteLine(query.Trim(), Severity.Trace);
46  }
static void Ntp.Data.Log.LogExtensions.VersionTableCreated ( this LogBase  log)
inlinestaticpackage

Definition at line 131 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

132  {
133  log.WriteLine("Created new version table.", Severity.Notice);
134  }

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.VersionTableCreateError ( this LogBase  log,
Exception  e 
)
inlinestaticpackage

Definition at line 136 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

137  {
138  log.WriteLine("Failed to create version table.", Severity.Error);
139  log.WriteLine(e);
140  }
var e
Definition: bootstrap.min.js:6

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.VersionTableFetchError ( this LogBase  log,
Exception  e 
)
inlinestaticpackage

Definition at line 142 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

143  {
144  log.WriteLine("Failed to fetch version number from database.", Severity.Error);
145  log.WriteLine(e);
146  }
var e
Definition: bootstrap.min.js:6

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.VersionTableInsertError ( this LogBase  log,
Exception  e 
)
inlinestaticpackage

Definition at line 148 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

149  {
150  log.WriteLine("Failed to insert into version table.", Severity.Error);
151  log.WriteLine(e);
152  }
var e
Definition: bootstrap.min.js:6

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.VersionTableParamError ( this LogBase  log)
inlinestaticpackage

Definition at line 154 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

155  {
156  log.WriteLine("Internal error: Version cannot be null.", Severity.Error);
157  }

Here is the call graph for this function:

static void Ntp.Data.Log.LogExtensions.VersionTableUpdateError ( this LogBase  log,
Exception  e 
)
inlinestaticpackage

Definition at line 159 of file LogExtensions.cs.

References Ntp.Common.Log.LogBase.WriteLine().

160  {
161  log.WriteLine("Failed to update version table.", Severity.Error);
162  log.WriteLine(e);
163  }
var e
Definition: bootstrap.min.js:6

Here is the call graph for this function:


The documentation for this class was generated from the following file: