The file, line and function information is now only printed for error and debug messages.
67 lines
1.9 KiB
C
67 lines
1.9 KiB
C
/*
|
|
* libdivecomputer
|
|
*
|
|
* Copyright (C) 2011 Jef Driesen
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, write to the Free Software
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
* MA 02110-1301 USA
|
|
*/
|
|
|
|
#include "common.h"
|
|
#include "utils.h"
|
|
|
|
const char *
|
|
errmsg (dc_status_t rc)
|
|
{
|
|
switch (rc) {
|
|
case DC_STATUS_SUCCESS:
|
|
return "Success";
|
|
case DC_STATUS_UNSUPPORTED:
|
|
return "Unsupported operation";
|
|
case DC_STATUS_INVALIDARGS:
|
|
return "Invalid arguments";
|
|
case DC_STATUS_NOMEMORY:
|
|
return "Out of memory";
|
|
case DC_STATUS_NODEVICE:
|
|
return "No device found";
|
|
case DC_STATUS_NOACCESS:
|
|
return "Access denied";
|
|
case DC_STATUS_IO:
|
|
return "Input/output error";
|
|
case DC_STATUS_TIMEOUT:
|
|
return "Timeout";
|
|
case DC_STATUS_PROTOCOL:
|
|
return "Protocol error";
|
|
case DC_STATUS_DATAFORMAT:
|
|
return "Data format error";
|
|
case DC_STATUS_CANCELLED:
|
|
return "Cancelled";
|
|
default:
|
|
return "Unknown error";
|
|
}
|
|
}
|
|
|
|
void
|
|
logfunc (dc_context_t *context, dc_loglevel_t loglevel, const char *file, unsigned int line, const char *function, const char *msg, void *userdata)
|
|
{
|
|
const char *loglevels[] = {"NONE", "ERROR", "WARNING", "INFO", "DEBUG", "ALL"};
|
|
|
|
if (loglevel == DC_LOGLEVEL_ERROR || loglevel == DC_LOGLEVEL_WARNING) {
|
|
message ("%s: %s [in %s:%d (%s)]\n", loglevels[loglevel], msg, file, line, function);
|
|
} else {
|
|
message ("%s: %s\n", loglevels[loglevel], msg);
|
|
}
|
|
}
|