Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7649129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:53:11+00:00 2026-05-31T10:53:11+00:00

I am trying to get my client which works with Linux and Windows to

  • 0

I am trying to get my client which works with Linux and Windows to work with Mac. I have a log class so I can see what is going on and catch errors but my logfile isn’t even outputting. The logfile is declared globally so it should at least output the logfile header regardless. I am using the terminal version C++ with Xcode.

Here is my log code:

log.h

#ifndef LOG_H
#define LOG_H

#include <fstream>

using namespace std;

class Log
{
public:

        // Constructor / Destructor
        Log();
        ~Log();

        // Class functions
        void writeNewline();
        void writeError(char * text,...);
        void writeSuccess(char * text,...);


private:

        ofstream logfile;
};

#endif

log.cpp

#include <ctime>
#include <stdarg.h>

#include "log.h"

const int BUFFER_SIZE = 1024;

using namespace std;

Log::Log()
{
    // Create a log file for output
    logfile.open ("lanternlog.txt", ios::out);

    // Grab the current system time
    time_t t = time(0);
    struct tm * now = localtime( & t );

    // TODO: Format the time correctly

    // Insert the time and date at the top
    logfile << "<---> Logfile Initialized on " << now->tm_mon + 1 << "-" << 
            now->tm_mday << "-" << now->tm_year + 1900 << " at " << now->tm_hour <<
            ":" << now->tm_min << ":" << now->tm_sec << endl;
}

// Destructor
Log::~Log()
{
    // Close the logfile
    logfile.close();
}

void Log::writeError(char * text,...)
{
    // Grab the variables and insert them
    va_list ap;
    va_start(ap, text);
    char buff[BUFFER_SIZE];
    vsnprintf(buff, sizeof(buff), text, ap);

    // Output to the log
    logfile << "<-!-> " << buff << endl;
}

void Log::writeSuccess(char * text,...)
{
    // Grab the variables and insert them
    va_list ap;
    va_start(ap, text);
    char buff[BUFFER_SIZE];
    vsnprintf(buff, sizeof(buff), text, ap);

    // Output to the log
    logfile << "<---> " << buff << endl;
}

void Log::writeNewline()
{
    // Create a new line in the logfile
    logfile << endl;
}

When the application shuts down, and I have dropped a breakpoint, the logfile should have already output something. There is also a warning with all of my log commands. For instance:

errorLog.writeSuccess("Fatal Error: Unable to initialize Lantern!");

yields: Conversion from string literal to ‘char *’ is deprecated

Still, the main initialization of the logfile does not use this method and should output the file.

First question was solved! Check below for other error:

Edit: It seems I have gotten a tiny bit further. The logfile is created, but is created in the harddrive/users/ folder. How would I have it simply output to the Xcode project folder like with Visual Studio.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:53:12+00:00Added an answer on May 31, 2026 at 10:53 am

    I think you can deal with the

    Conversion from string literal to ‘char *’ is deprecated

    by changing the methods from ones which take char * parameters:

    void writeError(char * text,...);
    void writeSuccess(char * text,...);
    

    to ones which take const char * parameters

    void writeError(const char * text,...);
    void writeSuccess(const char * text,...);
    

    The compiler should be worried about passing string literals as parameters to functions which could try to change them.

    Is the logfile being created?
    I’d try removing everything (using #if 0 … #endif) from the constructor except for a dumb

    logfile << "logfile constructed";
    

    to reduce the number of ways it can break.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SOAP client in Ruby that I'm trying to get working with
I have written an application which collects windows logs from linux, via the Zenoss
I'm trying to get client-side javascript objects saved as a file locally. I'm not
I'm trying to get a certain cookie in a java client by creating a
Trying to get comfortable with jQuery and I have encountered some sample code that
Trying to get this to work, with no luck: [DataMember] public Type ParameterType {
I have a website which uses SVG for an interactive client side thingamabob. I
I have a subversion repository hosted on Linux but only ever accessed via windows
Im trying to get my head around MySQL. I have learnt a great deal
I'm trying to get an auth token for a user using OAuth. Everything works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.