Skip to content

Commit

Permalink
Cleanup for issue #131.
Browse files Browse the repository at this point in the history
  • Loading branch information
ahlstromcj committed Nov 7, 2024
1 parent 7d36fc8 commit cec5145
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 177 deletions.
8 changes: 0 additions & 8 deletions Seq66qt5/seq66qt5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,6 @@ main (int argc, char * argv [])
#endif

int exit_status = EXIT_SUCCESS; /* versus EXIT_FAILURE */

#if defined SEQ66_IMMEDIATE_LOG_FILE
(void) seq66::reroute_stdio("session.log");
#endif

for (;;)
{
seq66::qt5nsmanager sm(app);
Expand Down Expand Up @@ -187,9 +182,6 @@ main (int argc, char * argv [])
break;
}
}
#if defined SEQ66_IMMEDIATE_LOG_FILE
(void) seq66::close_stdio();
#endif
return exit_status;
}

Expand Down
9 changes: 0 additions & 9 deletions libseq66/include/seq66_features.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,6 @@

#include "seq66_features.h" /* the C-compatible definitions */

/*
* Define this to produce an immediate log file in the current directory.
* Useful in debugging NSM support. The 'usr'-specified log-file will not
* be opened. It happens too late anyway. Normally this macro should be
* *undefined*.
*/

#undef SEQ66_IMMEDIATE_LOG_FILE

/*
* This is the main namespace of Seq66. Do not attempt to
* Doxygenate the documentation here; it breaks Doxygen.
Expand Down
13 changes: 12 additions & 1 deletion libseq66/src/os/daemonize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* \library seq66 application (from PSXC library)
* \author Chris Ahlstrom
* \date 2005-07-03 to 2007-08-21 (pre-Sequencer24/64)
* \updates 2024-11-05
* \updates 2024-11-07
* \license GNU GPLv2 or above
*
* Daemonization module of the POSIX C Wrapper (PSXC) library
Expand Down Expand Up @@ -457,6 +457,17 @@ close_stdio ()
return result;
}

/**
* Reroute stdout and stderr to the same log file. This is allowed
* only once.
*
* \param logfile
* Provides the full path to the log file.
*
* \return
* Returns true if the rerouting worked or was already done.
*/

bool
reroute_stdio (const std::string & logfile)
{
Expand Down
6 changes: 0 additions & 6 deletions libseq66/src/sessions/clinsmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ clinsmanager::detect_session (std::string & url)
url.clear();

#if defined SEQ66_NSM_SUPPORT

std::string tenturl = nsm::get_url(); /* a tentative URL */
session_message("Checking for NSM_URL");
if (! tenturl.empty())
Expand Down Expand Up @@ -185,11 +184,6 @@ bool
clinsmanager::create_session (int argc, char * argv [])
{
#if defined SEQ66_NSM_SUPPORT

#if defined SEQ66_IMMEDIATE_LOG_FILE
session_message("create_session");
#endif

std::string url;
bool ok = detect_session(url); /* side-effect */
if (! ok)
Expand Down
66 changes: 17 additions & 49 deletions libseq66/src/sessions/smanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* \library seq66 application
* \author Chris Ahlstrom
* \date 2020-03-22
* \updates 2023-12-13
* \updates 2024-11-07
* \license GNU GPLv2 or above
*
* Note that this module is part of the libseq66 library, not the libsessions
Expand Down Expand Up @@ -215,10 +215,6 @@ smanager::main_settings (int argc, char * argv [])
std::string parentname = get_parent_process_name();
bool in_nsm = contains(parentname, s_nsm_name); /* this is tentative! */

#if defined SEQ66_IMMEDIATE_LOG_FILE
session_message("main_settings");
#endif

/*
* Call app_info() above in main() instead of this.
*
Expand Down Expand Up @@ -285,26 +281,13 @@ smanager::main_settings (int argc, char * argv [])
{
int optionindex = (-1);
bool sessionmodified = false;
if (rc().alt_session()) // issue #131
{

/*
* Check for a session, either defined by the environment variable
* "SEQ66_SESSION_TAG" or by the "--session-tag tag" option. The
* latter can override the first.
*/

#if 0 // commented out for issue #131
if (! rc().alt_session())
{
std::string sesstag = cmdlineopts::env_session_tag();
if (! sesstag.empty())
rc().session_tag(sesstag);
}
if (rc().alt_session())
if (rc().alt_session()) /* issue #131 */
{
#endif
/*
* Check for a session, either defined by the environment
* variable "SEQ66_SESSION_TAG" or by the "--session-tag tag"
* option. The latter can override the first.
*
* The name 'sessions.rc' is a bit more accurate.
*/

Expand Down Expand Up @@ -333,9 +316,12 @@ smanager::main_settings (int argc, char * argv [])
return false;
}
}
#if 0 // comment out for issue #131
}
#endif
else
{
std::string sesstag = cmdlineopts::env_session_tag();
if (! sesstag.empty())
rc().session_tag(sesstag);
}

/*
Expand Down Expand Up @@ -377,13 +363,15 @@ smanager::main_settings (int argc, char * argv [])
{
/*
* The 'usr' file might not specify a log-file. Check again
* here.
* here. But do we really want to not do this for a verbose
* CLI run?
*
* bool uselog = ! (seq_app_cli() && rc().verbose()) &&
* usr().option_use_logfile();
*/

(void) cmdlineopts::parse_o_options(argc, argv);
bool uselog = ! (seq_app_cli() && rc().verbose()) &&
usr().option_use_logfile();

bool uselog = usr().option_use_logfile();

/*
* The user migh specify -o options that are also set up in
Expand Down Expand Up @@ -492,11 +480,6 @@ smanager::create_performer ()
int cols = usr().mainwnd_cols();
pointer p(new (std::nothrow) performer(ppqn, rows, cols));
result = bool(p);

#if defined SEQ66_IMMEDIATE_LOG_FILE
session_message("main_settings");
#endif

if (result)
{
m_perf_pointer = std::move(p); /* change the ownership */
Expand Down Expand Up @@ -653,11 +636,6 @@ smanager::open_midi_file (const std::string & fname)
bool
smanager::create_session (int /*argc*/, char * /*argv*/ [])
{

#if defined SEQ66_IMMEDIATE_LOG_FILE
session_message("create_session");
#endif

session_setup(); /* daemonize: set basic signal handlers */
return true;
}
Expand All @@ -684,11 +662,6 @@ smanager::create_session (int /*argc*/, char * /*argv*/ [])
bool
smanager::close_session (std::string & msg, bool ok)
{

#if defined SEQ66_IMMEDIATE_LOG_FILE
session_message("close_session");
#endif

bool result = not_nullptr(perf());
if (result)
{
Expand Down Expand Up @@ -1137,11 +1110,6 @@ smanager::create_configuration
const std::string & midifilepath
)
{

#if defined SEQ66_IMMEDIATE_LOG_FILE
session_message("create_configuration");
#endif

bool result = ! cfgfilepath.empty();
if (result)
{
Expand Down
Loading

0 comments on commit cec5145

Please sign in to comment.