bmcweb icon indicating copy to clipboard operation
bmcweb copied to clipboard

can not print log in lamba

Open jack206 opened this issue 1 year ago • 1 comments

Is this the right place to submit this?

  • [X] This is not a security vulnerability or a crashing bug
  • [X] This is not a question about how to use OpenBMC
  • [X] This is not a bug in an OpenBMC fork or a bug in code still under code review.
  • [X] This is not a request for a new feature.

Bug Description

I cannot print log in lamba

Version

v1.00.0-2.14.0-bb8df459

Additional Information

        std::ofstream logfile("/var/log/log1.txt");
        if (logfile.is_open()) {
            logfile << "start requestRoutesJournalEventLogEntryCollection " << std::endl;
            logfile.flush();
        }
        logfile.close();
        system("echo Hello, this is a testzzz > /var/log/log1.txt");
        std::cout << "setup redfish route start\n" << std::endl;
        if (!redfish::setUpRedfishRouteWithDelegation(
                app, req, asyncResp, delegatedQuery, capabilities))
        {
            return;
        }
        BMCWEB_LOG_DEBUG << "setup redfish route done";

None of the three printing methods can print log。

jack206 avatar Apr 23 '24 02:04 jack206

BMCWEB_ROUTE(app, "/redfish/v1/Systems/<str>/LogServices/EventLog/Entries/")
        .privileges(redfish::privileges::getLogEntryCollection)
        .methods(boost::beast::http::verb::get)(
            [&app](const crow::Request& req,
                   const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
                   const std::string& systemName) {
        query_param::QueryCapabilities capabilities = {
            .canDelegateTop = true,
            .canDelegateSkip = true,
        };
        query_param::Query delegatedQuery;
        std::ofstream logfile("/var/log/log1.txt");
        if (logfile.is_open()) {
            logfile << "start requestRoutesJournalEventLogEntryCollection " << std::endl;
            logfile.flush();
        }
        logfile.close();
        system("echo Hello, this is a testzzz > /var/log/log1.txt");
        std::cout << "setup redfish route start\n" << std::endl;
        if (!redfish::setUpRedfishRouteWithDelegation(
                app, req, asyncResp, delegatedQuery, capabilities))
        {
            return;
        }
        BMCWEB_LOG_DEBUG << "setup redfish route done";
        if (systemName != "system")
        {
            messages::resourceNotFound(asyncResp->res, "ComputerSystem",
                                       systemName);
            return;
        }

jack206 avatar Apr 23 '24 02:04 jack206

This is not a bug in an OpenBMC fork or a bug in code still under code review.

You check the box, then you post code that looks like it is from a fork. Please ask questions in the appropriate forums, as the bug template directs.

edtanous avatar May 07 '24 03:05 edtanous