~vladh/peony

peony/src/logs.cpp -rw-r--r-- 1.9 KiB
7fc9922bVlad-Stefan Harbuz changes shaders namespace into class a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
  Peony Game Engine
  Copyright (C) 2020 Vlad-Stefan Harbuz <vlad@vladh.net>
  All rights reserved.
*/

#include <signal.h>
#include "logs.hpp"


void logs::fatal(const char *format, ...) {
  va_list vargs;
  fprintf(stderr, "fatal | ");
  va_start(vargs, format);
  vfprintf(stderr, format, vargs);
  fprintf(stderr, "\n");
  va_end(vargs);
  #if defined(PLATFORM_WINDOWS)
    __debugbreak();
  #elif defined(PLATFORM_POSIX)
    raise(SIGABRT);
  #endif
}


void logs::error(const char *format, ...) {
  va_list vargs;
  fprintf(stderr, "error | ");
  va_start(vargs, format);
  vfprintf(stderr, format, vargs);
  fprintf(stderr, "\n");
  va_end(vargs);
}


void logs::warning(const char *format, ...) {
  va_list vargs;
  fprintf(stderr, "warn  | ");
  va_start(vargs, format);
  vfprintf(stderr, format, vargs);
  fprintf(stderr, "\n");
  va_end(vargs);
}


void logs::info(const char *format, ...) {
  va_list vargs;
  fprintf(stdout, "info  | ");
  va_start(vargs, format);
  vfprintf(stdout, format, vargs);
  fprintf(stdout, "\n");
  va_end(vargs);
}


void logs::print_newline() {
  fprintf(stdout, "\n");
}


void logs::print_aimatrix4x4(aiMatrix4x4 *t) {
  info("(%f, %f, %f, %f)", t->a1, t->b1, t->c1, t->d1);
  info("(%f, %f, %f, %f)", t->a2, t->b2, t->c2, t->d2);
  info("(%f, %f, %f, %f)", t->a3, t->b3, t->c3, t->d3);
  info("(%f, %f, %f, %f)", t->a4, t->b4, t->c4, t->d4);
}


void logs::print_m4(m4 *t) {
  info("(%f, %f, %f, %f)", (*t)[0][0], (*t)[1][0], (*t)[2][0], (*t)[3][0]);
  info("(%f, %f, %f, %f)", (*t)[0][1], (*t)[1][1], (*t)[2][1], (*t)[3][1]);
  info("(%f, %f, %f, %f)", (*t)[0][2], (*t)[1][2], (*t)[2][2], (*t)[3][2]);
  info("(%f, %f, %f, %f)", (*t)[0][3], (*t)[1][3], (*t)[2][3], (*t)[3][3]);
}


void logs::print_v2(v2 *t) {
  info("(%f, %f)", (*t)[0], (*t)[1]);
}


void logs::print_v3(v3 *t) {
  info("(%f, %f, %f)", (*t)[0], (*t)[1], (*t)[2]);
}


void logs::print_v4(v4 *t) {
  info("(%f, %f, %f, %f)", (*t)[0], (*t)[1], (*t)[2], (*t)[3]);
}