
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include "utils.h"
#include "Log.h"

void print(const string &s) {
    g_log.log(LL_INFO, "%s", s.c_str() );
}

float rnd()
{
    return rand() / (float)RAND_MAX;
}

string currentTime(bool showDate)
{
    const char* dateAndTime = "%y%m%d %H:%M:%S";
    const char* timeOnly = "%H:%M:%S";
    const char* fmt = showDate ? dateAndTime : timeOnly;
    time_t t;
    time(&t);
    char buf[64];
    strftime(buf, 64, fmt, localtime(&t));
    string s(buf);
    return s;
}

