Explorar o código

Include sensor name when sensor is added

With sensor name aliasing on master there should be a self contained way
to determine the sensor id for a given name, as relying on users running
LibreHardwareMonitor would be too inconvenient.

This commit modifies the "Sensor added" log line, which already prints
out the sensor's id to include the sensor name.

Now if someone wants to update the "Fan #2" sensor they can open the
OhmGraphite.log and search for "Fan #2" and see the following line:

```
Sensor added: /lpc/nct6792d/fan/1 "Fan #2"
```

Then the this line can be used to add the alias line to
`OhmGraphite.exe.config`

```xml
<add key="/lpc/nct6792d/fan/1/name" value="superfan" />
```
Nick Babcock %!s(int64=5) %!d(string=hai) anos
pai
achega
7c94eee194
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      OhmGraphite/SensorCollector.cs

+ 3 - 2
OhmGraphite/SensorCollector.cs

@@ -89,8 +89,9 @@ namespace OhmGraphite
 
         private void SensorAdded(ISensor sensor)
         {
-            Logger.Debug(!_ids.TryAdd(sensor.Identifier, sensor) ?
-                    "Sensor previously added: {0}" : "Sensor added: {0}", sensor.Identifier);
+            var added = _ids.TryAdd(sensor.Identifier, sensor);
+            var msg = added ? "Sensor added: {0} \"{1}\"" : "Sensor previously added: {0} \"{1}\"";
+            Logger.Info(msg, sensor.Identifier, sensor.Name);
         }
 
         private void SensorRemoved(ISensor sensor)