Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to shutdown and restart in the same program? #216

Closed
KevinLucidyne opened this issue May 20, 2016 · 3 comments
Closed

How to shutdown and restart in the same program? #216

KevinLucidyne opened this issue May 20, 2016 · 3 comments

Comments

@KevinLucidyne
Copy link

KevinLucidyne commented May 20, 2016

I'm using spdlog to run logs for both managed and unmanaged code in Visual Studio. For that reason I've written shell classes that use spdlog under the hood.

However, I'm running into problems with my unit tests. My unit tests run in a single executable and so need to stop and restart spdlog loggers and logfiles multiple times.

How do I do this? I'm using this code in a class to currently start instances of spdlog in a Windows DLL:

             private:
        API static std::mutex _mutex;
        API static std::shared_ptr<spdlog::logger> _instance;

        static std::shared_ptr<spdlog::logger> Instance()
        {
            std::unique_lock<std::mutex> lck(_mutex, std::defer_lock);
            lck.lock();
            if (_instance == nullptr)
            {
                _instance = spdlog::rotating_logger_mt("Logger", "EXO", 1024 * 1024 * 5, 4, true);
            }
            lck.unlock();
            return _instance;
        }
@gabime
Copy link
Owner

gabime commented May 20, 2016

you should release it using spdlog::drop("Logger") and then you can just destruct it

@KevinLucidyne
Copy link
Author

Thanks! I was trying spdlog::dropall() but that didn't work.

On Fri, May 20, 2016 at 3:30 PM, Gabi Melman notifications@github.com
wrote:

you should release it using spdlog::drop("Logger") and then you can just
destruct it


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#216 (comment)

Kevin Johnsrude
Senior Software Engineer
Lucidyne Technologies, Inc.
155 SW Madison Ave.
Corvallis, Oregon 97330
541 753 5111
www.Lucidyne.com

@gabime
Copy link
Owner

gabime commented May 21, 2016

don't forget to delete the object itself too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants