Logging to a mySQL database: Difference between revisions

From MidasWiki
Jump to navigation Jump to search
(Created page with "The MIDAS logger (mlogger) is able to store information in a mySQL database. This option is an alternative to the '''runlog.txt''' file handled by the MIDAS Analyzer ....")
 
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The MIDAS logger ([[mlogger]]) is able to store information in a mySQL database. This option is an alternative to the '''runlog.txt''' file handled by the [[MIDAS Analyzer]] . The two main advantages using the SQL are:
{{Pagelinks}}
 
==== Links ====
<div style="column-count:3;-moz-column-count:3;-webkit-column-count:3">
* [[keys in the ODB /Logger tree | ODB /Logger tree ]]
* [[keys in the ODB /Logger/Runlog/SQL subtree |ODB /Logger/Runlog/SQL subtree]]
* [[keys in the ODB /Logger/Runlog/ASCII subtree |ODB /Logger/Runlog/ASCII subtree]]
* [[mlogger]]
</div>
 
-------
<br>
The MIDAS logger ([[mlogger]]) is able to store information in a mySQL database. This option is an alternative to the '''runlog.log''' file handled by the [[MIDAS Analyzer]]. The two main advantages of using the SQL are:


*    The recording is done by the logger and therefore is independent of the user analyzer.
*    The recording is done by the logger and therefore is independent of the user analyzer.
*    The definition of the parameters to be recorded in the database is entirely setup in the ODB under the [[/Logger/SQL]] tree.
*    The definition of the parameters to be recorded in the database is entirely setup in the ODB under the [[Keys in the ODB /Logger/Runlog/SQL subtree |/Logger/Runlog/SQL subtree]].
 
The SQL option is enabled by the preprocessor flag [[Compilation & Build#NEED_MYSQL|NEED_MYSQL]] at [[Compilation & Build|Build time]]. This option, when enabled, will cause the MIDAS logger ([[mlogger]]) to create a subtree SQL under the
[[/Logger ODB tree]] . This tree contains information for mySQL access with the predefined mySQL database name '''Midas''' and table '''Runlog'''.
 
Under two dedicated subdirectories
[[Keys in the ODB /Logger/Runlog/SQL subtree #/Logger/Runlog/SQL/Links BOR | Links BOR ]] and
[[Keys in the ODB /Logger/Runlog/SQL subtree #/Logger/Runlog/SQL/Links EOR | Links EOR ]],
predefined links exist which will be used at begin-of-run (BOR) and end-of-run (EOR) respectively for storing parameter values into the database. These elements are [[ODB Page#symbolic link|ODB links]] allowing the user to extend the list with any parameter in the ODB database. This logger mySQL option may replace or complement the '''runlog.txt''' functionality of the [http://ladd00.triumf.ca/~daqweb/doc/midas/doc/html/analyzer_8c.html#a8e03cbe2637bd6f4488a659c9f23d29e ana_end_of_run()] function from the
[http://ladd00.triumf.ca/~daqweb/doc/midas/doc/html/analyzer_8c_source.html  analyzer.c].
 
The following example shows a <span style="color: purple;">''/Logger/Runlog/SQL''</span> tree as created by [[mlogger]]. See [[keys in the ODB /Logger/Runlog/SQL subtree |ODB /Logger/Runlog/SQL subtree]] for an explanation of the meaning of each key.
 
=== Example /Logger/Runlog/SQL subtree ===
 
[local:midas:S]/Runlog>ls -lr SQL
Key name                        Type    #Val  Size  Last Opn Mode Value
---------------------------------------------------------------------------
SQL                        DIR
    Create database            BOOL    1    4    27s  0  RWD  n
    Write data                  BOOL    1    4    27s  0  RWD  n
    Hostname                    STRING  1    80    27s  0  RWD  localhost
    Username                    STRING  1    80    27s  0  RWD  root
    Password                    STRING  1    80    27s  0  RWD
    Database                    STRING  1    32    27s  0  RWD  midas
    Table                      STRING  1    80    27s  0  RWD  Runlog
    Logfile                    STRING  1    80    27s  0  RWD  sql.log
    Links BOR                  DIR
        Run number              LINK    1    20    58s  0  RWD  /Runinfo/Run number
        Start time              LINK    1    20    58s  0  RWD  /Runinfo/Start time
    Links EOR                  DIR
        Stop time              LINK    1    19    4m  0  RWD  /Runinfo/Stop time


The SQL option is enabled by the preprocessor flag NEED_MYSQL at build time. This option, when enabled, will cause mlogger to create a subtree SQL under the /Logger ODB tree . This tree contains information for mySQL access with the predefined mySQL database name "Midas" and table "Runlog". Under two dedicated subdirectories Link_BOR and Link_EOR, predefined links exists which will be used at BOR and EOR respectively for storing parameter values into the database. These elements are ODB links allowing the user to extend the list with any parameter in the ODB database. This logger mySQL option may replace or complement the runlog.txt functionality of the ana_end_of_run() function from the analyzer.c.
[[Category: Logger Tree]] [[Category:Data Logging]]

Latest revision as of 06:03, 11 November 2022


Links



The MIDAS logger (mlogger) is able to store information in a mySQL database. This option is an alternative to the runlog.log file handled by the MIDAS Analyzer. The two main advantages of using the SQL are:

  • The recording is done by the logger and therefore is independent of the user analyzer.
  • The definition of the parameters to be recorded in the database is entirely setup in the ODB under the /Logger/Runlog/SQL subtree.

The SQL option is enabled by the preprocessor flag NEED_MYSQL at Build time. This option, when enabled, will cause the MIDAS logger (mlogger) to create a subtree SQL under the /Logger ODB tree . This tree contains information for mySQL access with the predefined mySQL database name Midas and table Runlog.

Under two dedicated subdirectories Links BOR and Links EOR , predefined links exist which will be used at begin-of-run (BOR) and end-of-run (EOR) respectively for storing parameter values into the database. These elements are ODB links allowing the user to extend the list with any parameter in the ODB database. This logger mySQL option may replace or complement the runlog.txt functionality of the ana_end_of_run() function from the analyzer.c.

The following example shows a /Logger/Runlog/SQL tree as created by mlogger. See ODB /Logger/Runlog/SQL subtree for an explanation of the meaning of each key.

Example /Logger/Runlog/SQL subtree

[local:midas:S]/Runlog>ls -lr SQL
Key name                        Type    #Val  Size  Last Opn Mode Value
---------------------------------------------------------------------------
SQL                         DIR
   Create database             BOOL    1     4     27s  0   RWD  n
   Write data                  BOOL    1     4     27s  0   RWD  n
   Hostname                    STRING  1     80    27s  0   RWD  localhost
   Username                    STRING  1     80    27s  0   RWD  root
   Password                    STRING  1     80    27s  0   RWD
   Database                    STRING  1     32    27s  0   RWD  midas
   Table                       STRING  1     80    27s  0   RWD  Runlog
   Logfile                     STRING  1     80    27s  0   RWD  sql.log
   Links BOR                   DIR
       Run number              LINK    1     20    58s  0   RWD  /Runinfo/Run number
       Start time              LINK    1     20    58s  0   RWD  /Runinfo/Start time
   Links EOR                   DIR
       Stop time               LINK    1     19    4m   0   RWD  /Runinfo/Stop time