On 08/15/2013 10:03 AM, Colin Grogan wrote:
I've done this a million times (I thought!) but I'm getting a strange
error I cant figure out.
The code:
void writeMsg(string msg){
logFile.writeln(msg);
What is logFile?
}
is failing with this error:
Hi Ali,
Heres my full Logger class.
module utils.log;
import std.stdio;
import std.string;
import std.datetime;
public enum LogLevel {Fatal=0, Severe=1, Info=2, Debug=3,
Verbose=4};
public class Logger{
public:
this(LogLevel minLevel = LogLevel.Info, string
fileName=logfile.log){
I should have put this here too:
My main function.
import std.stdio;
import utils.log;
void main()
{
Logger log = new Logger(LogLevel.Info, somefile.log);
log.logDebug(Test);
}
When creating the log file, it prints the text in the constructor
as expected, but the call to log.logDebug()
On Thursday, 15 August 2013 at 17:41:00 UTC, Colin Grogan wrote:
this(LogLevel minLevel = LogLevel.Info, string
fileName=logfile.log)
{
this.minLevel = minLevel;
logFile = File(fileName, w);
this.writeMsg(format(Opened file for writing at [%s],
On Thursday, 15 August 2013 at 18:09:21 UTC, monarch_dodra wrote:
This doesn't fix everything though, and you should also rework
your logLevel functions to not allocate: For example, by
making log accept two strings.
Another issue is that printing a time will always allocate a
string, so