提示コードですがライブラリ側のif
文の中なのですがエラーログとして適切な実装方法
が知りたいです。例えばどんなやり方がいいのでしょうか?
考えた事
std::cout<<"Error " <<std::endl;
とういう方法を考えましたが場所がわからないのでちょっと違うと思うのですが
実装していること
テキストファイルにログ書き込む
Main.cpp
cpp
1#include "../lib_src/Console.hpp" 2#include "../lib_src/Help.hpp" 3#include <ncurses.h> 4#include <iostream> 5 6int main() 7{ 8 9 Console::Init(); 10 11 Console::NoDispInput(); 12 Console::NoInputBuffer(); 13 14 WINDOW *win = newwin(30,30,10,10); 15 16 refresh(); 17 while(true) 18 { 19 Console::ClearBuffer(NULL); 20 21 22 23 Console::Draw(Console::ColorCode::Black,Console::ColorCode::White,NULL,"Hello World"); 24 25 26 27 28 29 Console::DrawBuffer(NULL); 30 if(getch() == 27) 31 { 32 break; 33 } 34 35 } 36 37 Console::Close(); 38 39 40 return 0; 41} 42
実装側
cpp
1 2/*##################################################### 3# 文字描画 座標指定 4#######################################################*/ 5 6void Console::Draw(ColorCode fg,ColorCode bg,WINDOW *win,glm::ivec2 pos,const char* fmt,...) 7{ 8 va_list ap; 9 char str[10000] = {'\0'}; 10 va_start(ap, fmt); 11 vsprintf(str,fmt,ap); 12 va_end(ap); 13 14 Render::Draw(fg,bg,win,pos,str); 15}
ライブラリ側
cpp
1 2void Console::Render::Draw(ColorCode fg,ColorCode bg,WINDOW *win,glm::ivec2 pos,const char* fmt) 3{ 4 5 SetColor(glm::ivec2((int)fg,(int)bg)); 6 7 if(win != nullptr) 8 { 9 if(mvwprintw(win,pos.y,pos.x,"%s",fmt) == ERR) 10 { 11 12 } 13 14 } 15 else 16 { 17 if(mvwprintw(stdscr,pos.y,pos.x,"%s",fmt) == ERR) 18 { 19 20 } 21 } 22 23 UnSetColor(glm::ivec2((int)fg,(int)bg)); 24 25}
あなたの回答
tips
プレビュー