Skip to content

Commit

Permalink
deploy: a818d55
Browse files Browse the repository at this point in the history
  • Loading branch information
bengeisler committed Sep 17, 2023
1 parent 758755c commit d90a08d
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 115 deletions.
18 changes: 9 additions & 9 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"output": {
".html": {
"relative_path": "reference/TcLog/Logger/TcLog.html",
"hash": "Hsc16PcssUpB0u4qogyTc29JAf9SO/YR3Duf59hq4qM="
"hash": "CdJguhizAKF5XVzsToP0inyHBZ40/jM63YGhdnSgu/A="
}
},
"is_incremental": false,
Expand Down Expand Up @@ -275,7 +275,7 @@
"output": {
".html": {
"relative_path": "userguide/configuration.html",
"hash": "cpNQnS2lXJlrcsrazfwQgD0b8sDpixxCFSFFMefLGaM="
"hash": "pwbbiewwLNtLH0c1S2luuNBPnoQ/sfx5rH+EiVdoaHk="
}
},
"is_incremental": false,
Expand All @@ -287,7 +287,7 @@
"output": {
".html": {
"relative_path": "userguide/customization.html",
"hash": "BcJLLPCsqBOwuTUds8cQmaNq1byPhU2+iLBWIuSxOZg="
"hash": "ppkAz36PQhyT6ghKthQVOxsWePw9IQu3gYFJtp9CYbA="
}
},
"is_incremental": false,
Expand All @@ -299,7 +299,7 @@
"output": {
".html": {
"relative_path": "userguide/getting_started.html",
"hash": "hLJaQkOwPFGV7o6GnaFN0FK9F6ln9pyFyPSZQQMURYg="
"hash": "9f2lJnz+DDYo8cA0+EjiZrnyY7L9TUO2p2TWXRwF3GA="
}
},
"is_incremental": false,
Expand All @@ -311,7 +311,7 @@
"output": {
".html": {
"relative_path": "userguide/installation.html",
"hash": "jPLwm2fAVOXD3HjvpohdTOYFHpcMY+JVOF9sKIlpI+g="
"hash": "1tPJ5P2a5rEO+mCNcVUMYdxdI/V2zYSAvxj18D2KAVQ="
}
},
"is_incremental": false,
Expand All @@ -323,7 +323,7 @@
"output": {
".html": {
"relative_path": "userguide/introduction.html",
"hash": "8wUWv5iFtBORench9D50I8aU9PwOsbDdVUu+OSXNHs4="
"hash": "cVuaDDhWJG1mT6kXQy1TX+gz1U9quS8bBIwGZrTLeK0="
}
},
"is_incremental": false,
Expand All @@ -335,7 +335,7 @@
"output": {
".html": {
"relative_path": "userguide/license.html",
"hash": "9HFud/U9euuZFjY4txBca6rKLTwtBl8JbxRbnNkhmHs="
"hash": "Kou359aQXJIGJ5PVnQ87jzJp4eEDWpWzeoish7JYCVw="
}
},
"is_incremental": false,
Expand All @@ -347,7 +347,7 @@
"output": {
".html": {
"relative_path": "userguide/logging.html",
"hash": "OvRiz4d0BT1+OivK9zyUDLSrFXmwYlb//49JSS9aQhk="
"hash": "mNdTcAyJ1O4crj/ScIMnDQmKzTz0wkbQI8uC3KCuIDQ="
}
},
"is_incremental": false,
Expand All @@ -359,7 +359,7 @@
"output": {
".html": {
"relative_path": "userguide/performance.html",
"hash": "nuiR10dxBIEYdp8xzdg5Q6CAb6VlQGXzDw04sZ9bjoA="
"hash": "FC0URvWJjHoUHyWTkTQruVbBeXyvzFOUCi5OuC36dPE="
}
},
"is_incremental": false,
Expand Down
2 changes: 1 addition & 1 deletion reference/TcLog/Logger/TcLog.html
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ <h4 id="TcLog.TcLog.AppendVariable" data-uid="TcLog.TcLog.AppendVariable">Append
Example:</p>
<pre><code>VAR
Logger: TcLog;
myInt : INT := 10;
myInt : INT := 10;
myVarInfo : __SYSTEM.VAR_INFO := __VARINFO(myInt);
END_VAR
Logger.AppendVariable(myVarInfo, myInt);
Expand Down
27 changes: 12 additions & 15 deletions userguide/configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@
<li class="">
<a href="installation.html" title="Installation" class="">Installation</a>
</li>
<li class="">
<a href="getting_started.html" title="User Guide" class="">User Guide</a>
</li>
<li class="">
<span class="expand-stub"></span>
<a class="">User guide</a>
Expand Down Expand Up @@ -126,11 +123,11 @@ <h3 id="delimiter">Delimiter</h3>
<h3 id="including-the-instance-path-in-the-log-message">Including the instance path in the log message</h3>
<p>TcLog offers with <code>.IncludeInstancePath()</code> the possibility to include the location where the message was triggered into the message text:</p>
<pre><code>_coreLogger
.WriteToAds()
.IncludeInstancePath()
.MinimumLevel(LogLevels.Warning)
.RunLogger();
.WriteToAds()
.IncludeInstancePath()
.MinimumLevel(LogLevels.Warning)
.RunLogger();
_logger.Error('This is an error message.');
</code></pre>
<p><img src="https://benediktgeisler.de/InstancePath.png" alt="Including the instance path" title="Including the instance path"></p>
Expand All @@ -143,14 +140,14 @@ <h2 id="log-to-ads-output">Log to ADS output</h2>
<h2 id="log-to-file-system">Log to file system</h2>
<p>TcLog brings the option to store logs in the file system in the form of text files. This option can be applied to <code>TcLogCore</code> via the method <code>.WriteToFile(path, filename)</code>:</p>
<pre><code>_coreLogger
.IncludeInstancePath()
.MinimumLevel(LogLevels.Warning)
.WriteToFile('c:\logs\', 'test.txt')
.RunLogger();
.IncludeInstancePath()
.MinimumLevel(LogLevels.Warning)
.WriteToFile('c:\logs\', 'test.txt')
.RunLogger();
_loggerTrig
.OnRisingEdge(_log)
.Error('rTrig Test');
.OnRisingEdge(_log)
.Error('rTrig Test');
</code></pre>
<p><img src="https://benediktgeisler.de/LogMessageInFiileSystem.png" alt="Logging to the file system" title="Logging to the file system"></p>
<h3 id="timestamp">Timestamp</h3>
Expand Down
77 changes: 37 additions & 40 deletions userguide/customization.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@
<li class="">
<a href="installation.html" title="Installation" class="">Installation</a>
</li>
<li class="">
<a href="getting_started.html" title="User Guide" class="">User Guide</a>
</li>
<li class="">
<span class="expand-stub"></span>
<a class="">User guide</a>
Expand Down Expand Up @@ -130,76 +127,76 @@ <h3 id="wrapper-around-tclog">Wrapper around <code>TcLog</code></h3>
<p>As wrapper we use an function block that encapsulates <code>TcLog</code> and enforces the data input with the help of the inputs. Furthermore it implements the interface <code>ILog</code> which establishes the link between logger and base logger.</p>
<pre><code>FUNCTION_BLOCK UserLog IMPLEMENTS ILog
VAR_INPUT
Condition: BOOL;
Identification: STRING;
Value: REAL;
Unit: STRING;
Condition: BOOL;
Identification: STRING;
Value: REAL;
Unit: STRING;
END_VAR
VAR
_getTimeData: DateTime;
_timestamp: STRING;
_getTimeData: DateTime;
_timestamp: STRING;
END_VAR
VAR_STAT
_logger: TcLog;
_logger: TcLog;
END_VAR

_getTimeData();
_timestamp := _getTimeData.ToString('hh:mm:ss');

_logger
.OnCondition(Condition)
.AppendString(_timestamp)
.AppendString(';')
.AppendString(Identification)
.AppendString(';')
.AppendAny(Value)
.AppendString(';')
.AppendString(Unit)
.ToCustomFormat('');
.OnCondition(Condition)
.AppendString(_timestamp)
.AppendString(';')
.AppendString(Identification)
.AppendString(';')
.AppendAny(Value)
.AppendString(';')
.AppendString(Unit)
.ToCustomFormat('');
</code></pre>
<p>We can use the helper function <code>GenerateTimeData</code>, which returns the current date and time formatted via the <code>.ToString(Format)</code> method. With its help we generate the timestamp of the sensor data.</p>
<p>The <code>.ToCustomFormat('')</code> method at the end of the chain causes the message to be logged unchanged. No additional information like further timestamps or instance path will be appended.</p>
<h3 id="the-interface-ilog">The interface <code>ILog</code></h3>
<p>The interface is implemented by passing the logger reference to the <code>TcLog</code> instance:</p>
<pre><code>METHOD SetLogger : BOOL
VAR_INPUT
ref2Core : REFERENCE TO TcLogCore;
ref2Core : REFERENCE TO TcLogCore;
END_VAR

_logger.SetLogger(ref2Core);
</code></pre>
<h3 id="calling-the-wrapper">Calling the wrapper</h3>
<p>Somewhere in our program <code>TcLogCore</code> is called cyclically. If there is more than one instance of it, we can tell our logger which instance we want via <code>.SetLogger(Instance)</code>. Otherwise the configuration of the logger singleton is used.</p>
<pre><code>VAR
_newLogger: TcLogCore;
_rTrigLog : R_TRIG;
_log : BOOL;
_myLog : UserLog;
_myValue: REAL := 1.0;
_myValue2: REAL := 2.0;
_newLogger: TcLogCore;
_rTrigLog : R_TRIG;
_log : BOOL;
_myLog : UserLog;
_myValue: REAL := 1.0;
_myValue2: REAL := 2.0;
END_VAR

_newLogger
.MinimumLevel(LogLevels.Information)
.SetRollingInterval(RollingIntervals.Hourly)
.WriteToFile('c:\logs\', 'sensor.csv')
.DeleteLogFilesAfterDays(1)
.RunLogger();
.MinimumLevel(LogLevels.Information)
.SetRollingInterval(RollingIntervals.Hourly)
.WriteToFile('c:\logs\', 'sensor.csv')
.DeleteLogFilesAfterDays(1)
.RunLogger();
_myLog.SetLogger(_newLogger);
_rTrigLog(CLK := _log);

_myLog(
Condition := _rTrigLog.Q,
Condition := _rTrigLog.Q,
Identification := '+CC1-B31',
Value := _myValue,
Unit := '°C');
Value := _myValue,
Unit := '°C');
_myLog(
Condition := _rTrigLog.Q,
Identification := '+CC1-B32',
Value := _myValue2,
Unit := '°C');
Condition := _rTrigLog.Q,
Identification := '+CC1-B32',
Value := _myValue2,
Unit := '°C');
</code></pre>
<p>As soon as logging is triggered via <code>_log</code>, the csv file and the entries in it are created:</p>
<p><img src="https://benediktgeisler.de/CustomLogging.png" alt="Custom logging" title="Custom logging"></p>
Expand Down
17 changes: 7 additions & 10 deletions userguide/getting_started.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@
<li class="">
<a href="installation.html" title="Installation" class="">Installation</a>
</li>
<li class="active">
<a href="getting_started.html" title="User Guide" class="active">User Guide</a>
</li>
<li class="">
<span class="expand-stub"></span>
<a class="">User guide</a>
Expand Down Expand Up @@ -127,22 +124,22 @@ <h1 id="getting-started">Getting started</h1>
<h2 id="example-usage">Example usage</h2>
<p>Configure the core logger in your project:</p>
<pre><code>VAR
_coreLogger : TcLogCore(bufferSize := 100 * SIZEOF(BYTE) * MAX_STRINGLENGTH);
_coreLogger : TcLogCore(bufferSize := 100 * SIZEOF(BYTE) * MAX_STRINGLENGTH);
END_VAR

_coreLogger
.WriteToAds()
.WriteToAds()
.WriteToFile('c:\logs\', 'sensor_data.txt')
.MinimumLevel(LogLevels.Debug)
.RunLogger();
.MinimumLevel(LogLevels.Debug)
.RunLogger();
</code></pre>
<p>Then, maybe in a different POU, use <code>TcLog</code> to log messages:</p>
<pre><code>VAR
_logger : TcLog;
_logger : TcLog;
END_VAR

_logger.Debug('This is a debug message.');
_logger.Error('This is an error message.');
_logger.Debug('This is a debug message.');
_logger.Error('This is an error message.');
</code></pre>
<p>This will log both messages to both the ADS output and the file system.</p>
<p>Next, see how to <a href="configuration.html">configure TcLog</a> and how to <a href="logging.html">use TcLog in detail</a>.</p>
Expand Down
3 changes: 0 additions & 3 deletions userguide/installation.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@
<li class="active">
<a href="installation.html" title="Installation" class="active">Installation</a>
</li>
<li class="">
<a href="getting_started.html" title="User Guide" class="">User Guide</a>
</li>
<li class="">
<span class="expand-stub"></span>
<a class="">User guide</a>
Expand Down
3 changes: 0 additions & 3 deletions userguide/introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@
<li class="">
<a href="installation.html" title="Installation" class="">Installation</a>
</li>
<li class="">
<a href="getting_started.html" title="User Guide" class="">User Guide</a>
</li>
<li class="">
<span class="expand-stub"></span>
<a class="">User guide</a>
Expand Down
3 changes: 0 additions & 3 deletions userguide/license.html
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@
<li class="">
<a href="installation.html" title="Installation" class="">Installation</a>
</li>
<li class="">
<a href="getting_started.html" title="User Guide" class="">User Guide</a>
</li>
<li class="">
<span class="expand-stub"></span>
<a class="">User guide</a>
Expand Down
Loading

0 comments on commit d90a08d

Please sign in to comment.