Panda3D
 All Classes Functions Variables Enumerations
androidLogStream.h
1 // Filename: androidLogStream.h
2 // Created by: rdb (12Jan13)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef ANDROIDLOGSTREAM_H
16 #define ANDROIDLOGSTREAM_H
17 
18 #ifdef ANDROID
19 
20 #include "dtoolbase.h"
21 #include "notifySeverity.h"
22 
23 #include <string>
24 #include <iostream>
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : AndroidLogStream
28 // Description : This is a type of ostream that writes each line
29 // to the Android log.
30 ///////////////////////////////////////////////////////////////////
31 class AndroidLogStream : public ostream {
32 private:
33  class AndroidLogStreamBuf : public streambuf {
34  public:
35  AndroidLogStreamBuf(int priority);
36  virtual ~AndroidLogStreamBuf();
37 
38  protected:
39  virtual int overflow(int c);
40  virtual int sync();
41 
42  private:
43  void write_char(char c);
44 
45  int _priority;
46  string _tag;
47  string _data;
48  };
49 
50  AndroidLogStream(int priority);
51 
52 public:
53  virtual ~AndroidLogStream();
54  static ostream &out(NotifySeverity severity);
55 };
56 
57 #endif // ANDROID
58 
59 #endif