-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.cpp
More file actions
28 lines (25 loc) · 754 Bytes
/
Copy pathlog.cpp
File metadata and controls
28 lines (25 loc) · 754 Bytes
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
#include "log.h"
//void logCon(string s)
//fa il logging su console
//@param[in] prende in ingresso la stringa da inserire.
//@param[out] scrive la stringa ricevuta su console.
void logCon(string s)
{
cout<<s;
}
//void logFile(string s)
//fa il logger su file
//@param[in] prende in ingresso la stringa da inserire.
//@param[out] scrive s sul file in modalità append.
//@param[out] scrive anche su console.
void logFile(string s)
{
ofstream f("log.txt", ios::app); //apre il file in modalità append, lasciando intatto quello che c'è e scrivendo alla fine
if(!f) {//controlla che f sia stato creato nel modo giusto.
cout<<"Errore nell'apertura del file!";
return ;
}
f<<s;
logCon(s);
f.close();
}