Skip to content

Commit

Permalink
Refactoring of command-line arguments.
Browse files Browse the repository at this point in the history
  • Loading branch information
interkosmos committed Mar 5, 2024
1 parent 275c531 commit 587f777
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
4 changes: 2 additions & 2 deletions adoc/dmfeed.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dmfeed - creates Atom XML feed from log messages
*dmfeed* --version

*dmfeed* --*database* _file_ [--*output* _file_] [--*node* _id_]
[--*minlevel* _level_] [--*maxlevel* _level_] [--*nentries* _count_]
[--*minlevel* _level_] [--*maxlevel* _level_] [--*entries* _count_]
[--*author* _name_] [--*email* _address_] [--*id* _uuid_]
[--*title* _title_] [--*subtitle* _title_] [--*url* _url_] [--*xsl* _file_]
[--*force*]
Expand Down Expand Up @@ -72,7 +72,7 @@ file modification of the feed, the output file is not updated, unless argument
*--name*, *-n* _name_::
Name of instance and table in given configuration file (default is `dmfeed`).

*--nentries*, *-E* _count_::
*--entries*, *-E* _count_::
Maximum number of entries in feed (default is 50).

*--node*, *-N* _id_::
Expand Down
18 changes: 9 additions & 9 deletions app/dmfeed.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ program dmfeed
character(len=*), parameter :: APP_NAME = 'dmfeed'
integer, parameter :: APP_MAJOR = 0
integer, parameter :: APP_MINOR = 9
integer, parameter :: APP_PATCH = 2
integer, parameter :: APP_PATCH = 3

integer, parameter :: APP_MAX_NENTRIES = 500 !! Maximum number of feed entries.
integer, parameter :: APP_MAX_ENTRIES = 500 !! Maximum number of feed entries.

type :: app_type
!! Application settings.
Expand All @@ -24,7 +24,7 @@ program dmfeed
character(len=NODE_ID_LEN) :: node = ' ' !! Optional node id.
integer :: min_level = LVL_DEBUG !! Minimum log level
integer :: max_level = LVL_CRITICAL !! Maximum log level.
integer :: nentries = 50 !! Max. number of entries in feed.
integer :: entries = 50 !! Max. number of entries in feed.
logical :: force = .false. !! Force writing of output file.
type(atom_type) :: atom !! Atom type.
end type app_type
Expand Down Expand Up @@ -85,7 +85,7 @@ integer function read_args(app) result(rc)
arg_type('node', short='N', type=ARG_TYPE_ID), & ! -N, --node <string>
arg_type('minlevel', short='L', type=ARG_TYPE_INTEGER), & ! -L, --minlevel <n>
arg_type('maxlevel', short='K', type=ARG_TYPE_INTEGER), & ! -K, --maxlevel <n>
arg_type('nentries', short='E', type=ARG_TYPE_INTEGER), & ! -E, --nentries <n>
arg_type('entries', short='E', type=ARG_TYPE_INTEGER), & ! -E, --entries <n>
arg_type('force', short='F', type=ARG_TYPE_BOOL), & ! -F, --force
arg_type('author', short='A', type=ARG_TYPE_CHAR), & ! -A, --author <string>
arg_type('email', short='M', type=ARG_TYPE_CHAR), & ! -M, --email <string>
Expand Down Expand Up @@ -113,7 +113,7 @@ integer function read_args(app) result(rc)
rc = dm_arg_get(args( 5), app%node)
rc = dm_arg_get(args( 6), app%min_level)
rc = dm_arg_get(args( 7), app%max_level)
rc = dm_arg_get(args( 8), app%nentries)
rc = dm_arg_get(args( 8), app%entries)
rc = dm_arg_get(args( 9), app%force)
rc = dm_arg_get(args(10), app%atom%author)
rc = dm_arg_get(args(11), app%atom%email)
Expand Down Expand Up @@ -156,7 +156,7 @@ integer function read_args(app) result(rc)
return
end if

if (app%nentries < 1 .or. app%nentries > APP_MAX_NENTRIES) then
if (app%entries < 1 .or. app%entries > APP_MAX_ENTRIES) then
call dm_error_out(rc, 'invalid number of entries')
return
end if
Expand All @@ -180,7 +180,7 @@ integer function read_config(app) result(rc)
rc = dm_config_get(config, 'node', app%node)
rc = dm_config_get(config, 'minlevel', app%min_level)
rc = dm_config_get(config, 'maxlevel', app%max_level)
rc = dm_config_get(config, 'nentries', app%nentries)
rc = dm_config_get(config, 'entries', app%entries)
rc = dm_config_get(config, 'force', app%force)
rc = dm_config_get(config, 'author', app%atom%author)
rc = dm_config_get(config, 'email', app%atom%email)
Expand Down Expand Up @@ -225,14 +225,14 @@ subroutine create_feed(app, error)
min_level = app%min_level, &
max_level = app%max_level, &
desc = .true., &
limit = int(app%nentries, kind=i8))
limit = int(app%entries, kind=i8))
else
rc = dm_db_select(db = db, &
logs = logs, &
min_level = app%min_level, &
max_level = app%max_level, &
desc = .true., &
limit = int(app%nentries, kind=i8))
limit = int(app%entries, kind=i8))
end if

if (dm_is_error(rc) .and. rc /= E_DB_NO_ROWS) then
Expand Down
11 changes: 10 additions & 1 deletion guide/guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ the web server. An example style sheet `feed.xsl` is located in
| `--maxlevel _level_` | `-K` | 5 | Select log messages of the given maximum <<data-log-level,log level>> (between 1 and 5). Must be greater or equal the minimum level.
| `--minlevel _level_` | `-L` | 1 | Select log messages of the given minimum <<data-log-level,log level>> (between 1 and 5).
| `--name _name_` | `-n` | `dmfeed` | Name of instance and table in given configuration file.
| `--nentries _count_` | `-E` | 50 | Maximum number of entries in feed (max. 500).
| `--entries _count_` | `-E` | 50 | Maximum number of entries in feed (max. 500).
| `--node _id_` | `-N` | – | Select log messages of the given node id.
| `--output _file_` | `-o` | _stdout_ | Path of the output file. If empty or `-`, the Atom feed will be printed to standard output.
| `--subtitle _string_` | `-G` | – | Sub-title of feed.
Expand Down Expand Up @@ -4579,6 +4579,15 @@ MAILTO=/dev/null
The shell script `mkreport.sh` must have the execution bits set. Update the
script to your configuration.

Furthermore, we can update an Atom XML feed of logs with <<dmfeed>>:

[source,crontab]
....
*/5 * * * * -q /usr/local/bin/dmfeed --config /usr/local/etc/dmpack/dmfeed.conf
....

The feed is updated every five minutes if new logs have arrived.

== GeoCOM API

The official GeoCOM API is divided into the following sub-systems:
Expand Down
8 changes: 4 additions & 4 deletions man/dmfeed.1
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
.\" Title: dmfeed
.\" Author: Philipp Engel
.\" Generator: Asciidoctor 2.0.20
.\" Date: 2024-02-28
.\" Date: 2024-03-05
.\" Manual: User Commands
.\" Source: DMFEED
.\" Language: English
.\"
.TH "DMFEED" "1" "2024-02-28" "DMFEED" "User Commands"
.TH "DMFEED" "1" "2024-03-05" "DMFEED" "User Commands"
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.ss \n[.ss] 0
Expand Down Expand Up @@ -36,7 +36,7 @@ dmfeed \- creates Atom XML feed from log messages
\fBdmfeed\fP \-\-version
.sp
\fBdmfeed\fP \-\-\fBdatabase\fP \fIfile\fP [\-\-\fBoutput\fP \fIfile\fP] [\-\-\fBnode\fP \fIid\fP]
[\-\-\fBminlevel\fP \fIlevel\fP] [\-\-\fBmaxlevel\fP \fIlevel\fP] [\-\-\fBnentries\fP \fIcount\fP]
[\-\-\fBminlevel\fP \fIlevel\fP] [\-\-\fBmaxlevel\fP \fIlevel\fP] [\-\-\fBentries\fP \fIcount\fP]
[\-\-\fBauthor\fP \fIname\fP] [\-\-\fBemail\fP \fIaddress\fP] [\-\-\fBid\fP \fIuuid\fP]
[\-\-\fBtitle\fP \fItitle\fP] [\-\-\fBsubtitle\fP \fItitle\fP] [\-\-\fBurl\fP \fIurl\fP] [\-\-\fBxsl\fP \fIfile\fP]
[\-\-\fBforce\fP]
Expand Down Expand Up @@ -110,7 +110,7 @@ Select log messages of the given minimum log level (from 1 to 5).
Name of instance and table in given configuration file (default is \f(CRdmfeed\fP).
.RE
.sp
\fB\-\-nentries\fP, \fB\-E\fP \fIcount\fP
\fB\-\-entries\fP, \fB\-E\fP \fIcount\fP
.RS 4
Maximum number of entries in feed (default is 50).
.RE
Expand Down

0 comments on commit 587f777

Please sign in to comment.