NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Cli.Program Class Reference

Static Public Member Functions

static void Main (string[] args)
 

Static Private Member Functions

static void ShowUsage ()
 

Static Private Attributes

static bool usage
 

Detailed Description

Definition at line 33 of file Program.cs.

Member Function Documentation

static void Ntp.Analyzer.Cli.Program.Main ( string[]  args)
inlinestatic

Definition at line 37 of file Program.cs.

References Ntp.Common.Log.LogGroup.Add(), Ntp.Common.Log.LogFactory.CreateErrorLog(), Ntp.Common.Log.LogFactory.CreateSysLog(), e, Ntp.Common.System.ProcessInfo.ProcessId, and Ntp.Common.IO.ShellCommand.WorkingDirectory.

38  {
39  Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
40  string name = "ntpa";
41  string tempDir = Directory.GetCurrentDirectory();
42  string configFile = null;
43  string pidFile = null;
44 
45  var initlog = LogFactory.CreateErrorLog(name);
46  initlog.Add(LogFactory.CreateSysLog(name));
47 
48  var p = new OptionSet
49  {
50  {"h|?|help", v => { ShowUsage(); }},
51  {"daemon=", v => { name = v; }},
52  {"config=", v => { configFile = v; }},
53  {"writepid=", v => { pidFile = v; }},
54  {"temp=", v => { tempDir = v; }}
55  };
56 
57  var rem = p.Parse(args).ToArray();
58 
59  if (usage)
60  {
61  return;
62  }
63 
64  if (rem.Length > 0)
65  {
66  initlog.WriteLine("Unknown option: " + rem[0], Severity.Error);
67  return;
68  }
69 
70  if (configFile == null)
71  {
72  initlog.WriteLine("Please specify configuration file with option --config", Severity.Error);
73  return;
74  }
75 
77  int pid = ProcessInfo.ProcessId;
78 
79  try
80  {
81  var main = new Main(configFile, pid, pidFile, name, initlog);
82  main.Run();
83  }
84  catch (Exception e)
85  {
86  initlog.WriteLine("Unexpected error: " + e.Message, Severity.Error);
87  initlog.WriteLine(e.StackTrace, Severity.Error);
88  }
89  }
void Add(LogBase log)
Definition: LogGroup.cs:71
static bool usage
Definition: Program.cs:35
static void Main(string[] args)
Definition: Program.cs:37
static LogBase CreateSysLog(string name)
Definition: LogFactory.cs:89
static string WorkingDirectory
Definition: ShellCommand.cs:42
var e
Definition: bootstrap.min.js:6
static void ShowUsage()
Definition: Program.cs:91
static LogGroup CreateErrorLog(string name)
Definition: LogFactory.cs:50

Here is the call graph for this function:

static void Ntp.Analyzer.Cli.Program.ShowUsage ( )
inlinestaticprivate

Definition at line 91 of file Program.cs.

References Ntp.Common.Log.Console.

92  {
93  Console.WriteLine("NTP Analyzer v0.8.2");
94  Console.WriteLine("Usage: ntpa --config file [--temp dir] [--writepid file] [--daemon name]");
95  usage = true;
96  }
static bool usage
Definition: Program.cs:35

Member Data Documentation

bool Ntp.Analyzer.Cli.Program.usage
staticprivate

Definition at line 35 of file Program.cs.


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