Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scord
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
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
eu
ADMIRE
scord
Commits
d2db2db2
Verified
Commit
d2db2db2
authored
2 years ago
by
Alberto Miranda
Browse files
Options
Downloads
Patches
Plain Diff
Add environment variables to control library logging
Closes
#23
parent
310729cf
No related branches found
No related tags found
1 merge request
!31
Resolve "Add tests to verify RPC arguments."
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/common/logger/logger.hpp
+1
-1
1 addition, 1 deletion
src/common/logger/logger.hpp
src/lib/CMakeLists.txt
+1
-1
1 addition, 1 deletion
src/lib/CMakeLists.txt
src/lib/admire.cpp
+22
-4
22 additions, 4 deletions
src/lib/admire.cpp
src/lib/env.hpp
+39
-0
39 additions, 0 deletions
src/lib/env.hpp
with
63 additions
and
6 deletions
src/common/logger/logger.hpp
+
1
−
1
View file @
d2db2db2
...
...
@@ -66,7 +66,7 @@ public:
}
else
if
(
type
==
"file"
)
{
m_internal_logger
=
spdlog
::
basic_logger_mt
<
spdlog
::
async_factory
>
(
ident
,
log_file
.
string
());
ident
,
log_file
.
string
()
,
true
);
}
#ifdef SPDLOG_ENABLE_SYSLOG
...
...
This diff is collapsed.
Click to expand it.
src/lib/CMakeLists.txt
+
1
−
1
View file @
d2db2db2
...
...
@@ -26,7 +26,7 @@ add_library(adm_iosched SHARED)
target_sources
(
adm_iosched
PUBLIC admire.h admire.hpp
PRIVATE admire.cpp c_wrapper.cpp detail/impl.hpp detail/impl.cpp errors.c
)
PRIVATE admire.cpp c_wrapper.cpp detail/impl.hpp detail/impl.cpp errors.c
env.hpp
)
set_target_properties
(
adm_iosched PROPERTIES PUBLIC_HEADER
"admire.h;admire.hpp"
)
...
...
This diff is collapsed.
Click to expand it.
src/lib/admire.cpp
+
22
−
4
View file @
d2db2db2
...
...
@@ -27,18 +27,20 @@
#include
<net/proto/rpc_types.h>
#include
<logger/logger.hpp>
#include
<utils/ctype_ptr.hpp>
#include
<env.hpp>
#include
<iostream>
#include
"detail/impl.hpp"
namespace
{
void
[[
maybe_unused
]]
void
init_library
()
__attribute__
((
constructor
));
void
init_logger
();
void
[[
maybe_unused
]]
void
init_library
()
{
init_logger
();
}
...
...
@@ -46,8 +48,24 @@ init_library() {
/** Logging for the library */
void
init_logger
()
{
// for now, just create a simple console logger
scord
::
logger
::
create_global_logger
(
"libadm_iosched"
,
"console color"
);
try
{
if
(
const
auto
p
=
std
::
getenv
(
admire
::
env
::
LOG
);
p
&&
!
std
::
string
{
p
}.
empty
()
&&
std
::
string
{
p
}
!=
"0"
)
{
if
(
const
auto
log_file
=
std
::
getenv
(
admire
::
env
::
LOG_OUTPUT
))
{
scord
::
logger
::
create_global_logger
(
"libadm_iosched"
,
"file"
,
log_file
);
}
else
{
scord
::
logger
::
create_global_logger
(
"libadm_iosched"
,
"console color"
);
}
}
}
catch
(
const
std
::
exception
&
ex
)
{
std
::
cerr
<<
fmt
::
format
(
"WARNING: Error initializing logger: {}"
,
ex
.
what
());
}
}
void
...
...
This diff is collapsed.
Click to expand it.
src/lib/env.hpp
0 → 100644
+
39
−
0
View file @
d2db2db2
/******************************************************************************
* Copyright 2021-2022, Barcelona Supercomputing Center (BSC), Spain
*
* This software was partially supported by the EuroHPC-funded project ADMIRE
* (Project ID: 956748, https://www.admire-eurohpc.eu).
*
* This file is part of scord.
*
* scord is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* scord is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with scord. If not, see <https://www.gnu.org/licenses/>.
*
* SPDX-License-Identifier: GPL-3.0-or-later
*****************************************************************************/
#ifndef LIBSCORD_ENV_HPP
#define LIBSCORD_ENV_HPP
#define LIBSCORD_ENV_PREFIX "LIBSCORD_"
#define ADD_PREFIX(str) LIBSCORD_ENV_PREFIX str
namespace
admire
::
env
{
static
constexpr
auto
LOG
=
ADD_PREFIX
(
"LOG"
);
static
constexpr
auto
LOG_OUTPUT
=
ADD_PREFIX
(
"LOG_OUTPUT"
);
}
// namespace admire::env
#endif // LIBSCORD_ENV_HPP
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