Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Base
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
CoMISo
Base
Commits
d67726dd
Commit
d67726dd
authored
Jan 14, 2020
by
Martin Marinov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add configuration code that can be reused by components consuming Journal
parent
568ca53b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
195 additions
and
0 deletions
+195
-0
Journal/JournalConfig.inc.cc
Journal/JournalConfig.inc.cc
+112
-0
Journal/JournalConfig.inc.hh
Journal/JournalConfig.inc.hh
+83
-0
No files found.
Journal/JournalConfig.inc.cc
0 → 100644
View file @
d67726dd
// Copyright 2020 Autodesk, Inc. All rights reserved.
//
// This computer source code and related instructions and comments are the
// unpublished confidential and proprietary information of Autodesk, Inc.
// and are protected under applicable copyright and trade secret law. They
// may not be disclosed to, copied or used by any third party without the
// prior written consent of Autodesk, Inc.
/*!
This source file provides the implementation of common configuration options for
the journal system that can be exposed by the component providing journals. The
component should include this within a namespace, e.g.:
namespace COMPONENT
{
namespace Journal
{
// Also define this as the component name
#define COMPONENT_NAME_STRING
// Also define this as the component name in UPPER case
#define COMPONENT_NAME_STRING_UPPER
#include <Base/Journal/JournalConfig.inc.cc>
} // namespace Journal
} // namespace COMPONENT
*/
#ifndef BASE_JOURNAL_CONFIG_INC_HH_INCLUDED
#error Please #include the component journal config file
#endif//BASE_JOURNAL_CONFIG_INC_HH_INCLUDED
#ifndef BASE_JOURNAL_STREAM_HH_INCLUDED
#error Please #include <Base/Journal/JournalStream.hh>
#endif//BASE_JOURNAL_STREAM_HH_INCLUDED
#ifndef BASE_ENVIRONMENT_HH_INCLUDED
#error Please #include <Base/Utils/Environment.hh>
#endif//BASE_ENVIRONMENT_HH_INCLUDED
#ifndef COMPONENT_NAME_STRING
#error Please define the component name string when including this
#endif//COMPONENT_NAME_STRING
#ifndef COMPONENT_NAME_STRING_UPPER
#error Please define the component name string in upper case when including this
#endif//COMPONENT_NAME_STRING_UPPER
std
::
string
&
base_path_string
()
{
// make sure this constructor is called when the base_path_str is accessed
static
std
::
string
base_path_str
=
"."
;
return
base_path_str
;
}
void
set_base_path
(
const
char
*
const
_base_path
)
{
base_path_string
()
=
_base_path
==
nullptr
?
"."
:
_base_path
;
}
const
char
*
base_path
()
{
return
base_path_string
().
c_str
();
}
#ifdef JOURNAL_ON
struct
Setup
{
Setup
()
{
const
char
*
const
vrbl_name
=
COMPONENT_NAME_STRING_UPPER
"_JOURNAL_BASE"
;
if
(
System
::
Environment
::
variable
(
vrbl_name
,
base_path_string
()))
{
set_on
(
true
);
// ... turn on Journal by default
}
}
};
static
Setup
setup__
;
void
set_on
(
const
bool
_on
)
{
if
(
on
()
==
_on
)
return
;
::
Journal
::
set_on
(
_on
,
"ReForm"
,
base_path
());
if
(
!
on
())
return
;
output_journal_header
();
// define this function to output a journal header
}
bool
on
()
{
return
::
Journal
::
on
();
}
const
char
*
output_path
()
{
static
::
Journal
::
String
otpt_path
;
otpt_path
=
::
Journal
::
output_path
();
return
otpt_path
.
empty
()
?
nullptr
:
otpt_path
.
c_str
();
}
#else
void
set_on
(
const
bool
)
{}
bool
on
()
{
return
false
;
}
const
char
*
output_path
()
{
return
nullptr
;
}
#endif//JOURNAL_ON
Journal/JournalConfig.inc.hh
0 → 100644
View file @
d67726dd
// Copyright 2020 Autodesk, Inc. All rights reserved.
//
// This computer source code and related instructions and comments are the
// unpublished confidential and proprietary information of Autodesk, Inc.
// and are protected under applicable copyright and trade secret law. They
// may not be disclosed to, copied or used by any third party without the
// prior written consent of Autodesk, Inc.
/*!
This header provides common configuration options for the journal system that
can be exposed by the component providing journals.The component should
include this within a namespace, e.g.:
namespace COMPONENT
{
namespace Journal
{
// Also define this either as an empty macro (if the component is a static lib
// or as an alias to the default export declaration macro.
#define DECL_JOURNAL_ALIAS DECL_COMPONENT
#include <Base/Journal/JournalConfig.inc.hh>
} // namespace Journal
} // namespace COMPONENT
The same approach should be used for the corresponding unit file implementing
the configuration options, see documentation in JournalConfig.inc.cc.
*/
#ifndef DECL_JOURNAL_ALIAS
#error Please define the declaration alias for the component, even if left empty
#endif//DECL_MODULE_CONFIG
#ifndef BASE_JOURNAL_CONFIG_INC_HH_INCLUDED
#define BASE_JOURNAL_CONFIG_INC_HH_INCLUDED
/*!
Journal is a system for logging the calls into the SDK, so that the
operations can be replayed by a component independently of the client
application that consumes it. It is very useful for reporting bugs.
Journal can be turned on by calling set_on(true), or by defining a path with an
environment variable [COMPONENT]_JOURNAl_BASE.
*/
/*!
Set the base path to use in future journals.
Pass nullptr (or ".") to use the current app execution folder as base.
The current app execution folder (".") is the default base path.
\note This will not affect any currently running journal.
*/
DECL_JOURNAL_ALIAS
void
set_base_path
(
const
char
*
const
_base_path
=
nullptr
);
/*!
Get the base path of any future journal.
\note This is *not* the path of any currently running journal, see \ref
output_path() to retrive the current journal path.
*/
DECL_JOURNAL_ALIAS
const
char
*
base_path
();
/*!
Turn on/off the journal: this does nothing if the journal is already in the
desired state.
*/
DECL_JOURNAL_ALIAS
void
set_on
(
const
bool
_on
);
/*!
Get if the journal is turned on/off.
*/
DECL_JOURNAL_ALIAS
bool
on
();
/*!
Get the journal output path, or a nullptr if the journal is off.
*/
DECL_JOURNAL_ALIAS
const
char
*
output_path
();
#undef DECL_JOURNAL_ALIAS // end of scope for this macro
#endif//BASE_JOURNAL_CONFIG_INC_HH_INCLUDED
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment