Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
04394f90
Commit
04394f90
authored
5 years ago
by
Michael Davis
Browse files
Options
Downloads
Patches
Plain Diff
[cta-admin] Implements header highlighting for stream output
parent
271825ff
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmdline/CtaAdminTextFormatter.cpp
+21
-3
21 additions, 3 deletions
cmdline/CtaAdminTextFormatter.cpp
cmdline/CtaAdminTextFormatter.hpp
+6
-5
6 additions, 5 deletions
cmdline/CtaAdminTextFormatter.hpp
with
27 additions
and
8 deletions
cmdline/CtaAdminTextFormatter.cpp
+
21
−
3
View file @
04394f90
...
...
@@ -24,9 +24,6 @@
namespace
cta
{
namespace
admin
{
const
std
::
string
TextFormatter
::
TEXT_RED
=
"
\x1b
[31;1m"
;
const
std
::
string
TextFormatter
::
TEXT_NORMAL
=
"
\x1b
[0m"
;
/*
* Convert time to string
*
...
...
@@ -43,6 +40,14 @@ std::string timeToString(const time_t &time)
void
TextFormatter
::
flush
()
{
if
(
m_outputBuffer
.
empty
())
return
;
// Check if first line is a header requiring special formatting
bool
is_header
=
false
;
if
(
m_outputBuffer
.
front
().
size
()
==
1
&&
m_outputBuffer
.
front
().
front
()
==
"HEADER"
)
{
is_header
=
true
;
m_outputBuffer
.
erase
(
m_outputBuffer
.
begin
());
if
(
m_outputBuffer
.
empty
())
return
;
}
auto
numCols
=
m_outputBuffer
.
front
().
size
();
std
::
vector
<
unsigned
int
>
colSize
(
numCols
);
...
...
@@ -56,12 +61,14 @@ void TextFormatter::flush() {
// Output columns
for
(
auto
&
l
:
m_outputBuffer
)
{
if
(
is_header
)
{
std
::
cout
<<
TEXT_RED
;
}
for
(
size_t
c
=
0
;
c
<
l
.
size
();
++
c
)
{
std
::
cout
<<
std
::
setfill
(
' '
)
<<
std
::
setw
(
colSize
.
at
(
c
)
+
1
)
<<
std
::
right
<<
l
.
at
(
c
)
<<
' '
;
}
if
(
is_header
)
{
std
::
cout
<<
TEXT_NORMAL
;
is_header
=
false
;
}
std
::
cout
<<
std
::
endl
;
}
...
...
@@ -71,6 +78,7 @@ void TextFormatter::flush() {
void
TextFormatter
::
printAfLsHeader
()
{
push_back
(
"HEADER"
);
push_back
(
"archive id"
,
"copy no"
,
...
...
@@ -115,6 +123,7 @@ void TextFormatter::print(const cta::admin::ArchiveFileLsItem &afls_item) {
}
void
TextFormatter
::
printAfLsSummaryHeader
()
{
push_back
(
"HEADER"
);
push_back
(
"total files"
,
"total size"
...
...
@@ -130,6 +139,7 @@ void TextFormatter::print(const cta::admin::ArchiveFileLsSummary &afls_summary)
}
void
TextFormatter
::
printFrLsHeader
()
{
push_back
(
"HEADER"
);
push_back
(
"request type"
,
"copy no"
,
...
...
@@ -174,6 +184,7 @@ void TextFormatter::print(const cta::admin::FailedRequestLsItem &frls_item) {
}
void
TextFormatter
::
printFrLsSummaryHeader
()
{
push_back
(
"HEADER"
);
push_back
(
"request type"
,
"total files"
,
...
...
@@ -194,6 +205,7 @@ void TextFormatter::print(const cta::admin::FailedRequestLsSummary &frls_summary
}
void
TextFormatter
::
printLpaHeader
()
{
push_back
(
"HEADER"
);
push_back
(
"tapepool"
,
"archive id"
,
...
...
@@ -228,6 +240,7 @@ void TextFormatter::print(const cta::admin::ListPendingArchivesItem &lpa_item) {
}
void
TextFormatter
::
printLpaSummaryHeader
()
{
push_back
(
"HEADER"
);
push_back
(
"tapepool"
,
"total files"
,
...
...
@@ -244,6 +257,7 @@ void TextFormatter::print(const cta::admin::ListPendingArchivesSummary &lpa_summ
}
void
TextFormatter
::
printLprHeader
()
{
push_back
(
"HEADER"
);
push_back
(
"vid"
,
"archive id"
,
...
...
@@ -272,6 +286,7 @@ void TextFormatter::print(const cta::admin::ListPendingRetrievesItem &lpr_item)
}
void
TextFormatter
::
printLprSummaryHeader
()
{
push_back
(
"HEADER"
);
push_back
(
"vid"
,
"total files"
,
...
...
@@ -288,6 +303,7 @@ void TextFormatter::print(const cta::admin::ListPendingRetrievesSummary &lpr_sum
}
void
TextFormatter
::
printTapeLsHeader
()
{
push_back
(
"HEADER"
);
push_back
(
"vid"
,
"media type"
,
...
...
@@ -346,6 +362,7 @@ void TextFormatter::print(const cta::admin::TapeLsItem &tals_item) {
}
void
TextFormatter
::
printRepackLsHeader
()
{
push_back
(
"HEADER"
);
push_back
(
"vid"
,
"repackBufferURL"
,
...
...
@@ -385,6 +402,7 @@ void TextFormatter::print(const cta::admin::RepackLsItem &rels_item) {
}
void
TextFormatter
::
printTapePoolLsHeader
()
{
push_back
(
"HEADER"
);
push_back
(
"name"
,
"vo"
,
...
...
This diff is collapsed.
Click to expand it.
cmdline/CtaAdminTextFormatter.hpp
+
6
−
5
View file @
04394f90
...
...
@@ -100,13 +100,14 @@ private:
line
.
push_back
(
std
::
string
(
item
));
}
void
flush
();
//!< Flush buffer to stdout
//! Flush buffer to stdout
void
flush
();
unsigned
int
m_bufLines
;
//!< Number of text lines to buffer before flushing formatted output
std
::
vector
<
std
::
vector
<
std
::
string
>>
m_outputBuffer
;
//!< Buffer for text output (not used for JSON)
unsigned
int
m_bufLines
;
//!< Number of text lines to buffer before flushing formatted output
std
::
vector
<
std
::
vector
<
std
::
string
>>
m_outputBuffer
;
//!< Buffer for text output (not used for JSON)
static
const
std
::
string
TEXT_RED
;
//!< Terminal formatting code for red text
static
const
std
::
string
TEXT_NORMAL
;
//!< Terminal formatting code for normal text
static
const
expr
const
char
*
const
TEXT_RED
=
"
\x1b
[31;1m"
;
//!< Terminal formatting code for red text
static
const
expr
const
char
*
const
TEXT_NORMAL
=
"
\x1b
[0m"
;
//!< Terminal formatting code for normal text
};
}}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment