forked from maccasoft/lora3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlog.cpp
More file actions
102 lines (84 loc) · 2.12 KB
/
log.cpp
File metadata and controls
102 lines (84 loc) · 2.12 KB
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
90
91
92
93
94
95
96
97
98
99
100
// LoraBBS Version 2.99 Free Edition
// Copyright (C) 1987-98 Marco Maccaferri
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program 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 General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#include "_ldefs.h"
#include "lora_api.h"
TLog::TLog ()
{
fp = NULL;
Months[0] = "Jan";
Months[1] = "Feb";
Months[2] = "Mar";
Months[3] = "Apr";
Months[4] = "May";
Months[5] = "Jun";
Months[6] = "Jul";
Months[7] = "Aug";
Months[8] = "Sep";
Months[9] = "Oct";
Months[10] = "Nov";
Months[11] = "Dec";
}
TLog::~TLog ()
{
if (fp != NULL)
fclose (fp);
}
USHORT TLog::Open (PSZ pszName)
{
USHORT RetVal = FALSE;
if (fp != NULL)
fclose (fp);
strcpy (FileName, pszName);
if ((fp = fopen (FileName, "a+t")) != NULL)
RetVal = TRUE;
return (RetVal);
}
VOID TLog::Suspend ()
{
if (fp != NULL) {
fclose (fp);
fp = NULL;
}
}
VOID TLog::Resume ()
{
if (fp == NULL)
fp = fopen (FileName, "a+t");
}
VOID TLog::Write (PSZ pszFormat, ...)
{
va_list arglist;
time_t t;
struct tm *timep;
va_start (arglist, pszFormat);
vsprintf (Buffer, pszFormat, arglist);
va_end (arglist);
t = time (NULL);
timep = localtime (&t);
sprintf (Temp, "%c %02d %3s %02d:%02d:%02d %s %s", Buffer[0], timep->tm_mday, Months[timep->tm_mon], timep->tm_hour, timep->tm_min, timep->tm_sec, "LORA", &Buffer[1]);
if (fp != NULL) {
fprintf (fp, "%s\n", Temp);
fflush (fp);
}
}
VOID TLog::WriteBlank ()
{
if (fp != NULL) {
fprintf (fp, "\n");
fflush (fp);
}
}