~ubuntu-branches/ubuntu/precise/ceph/precise-proposed

« back to all changes in this revision

Viewing changes to src/test/TestDoutStreambuf.cc

  • Committer: Bazaar Package Importer
  • Author(s): Laszlo Boszormenyi (GCS)
  • Date: 2011-04-25 10:09:05 UTC
  • mfrom: (1.1.3 upstream) (0.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20110425100905-exm7dfvi2v5ick02
Tags: 0.27-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 
2
// vim: ts=8 sw=2 smarttab
 
3
/*
 
4
 * Ceph - scalable distributed file system
 
5
 *
 
6
 * Copyright (C) 2010 Dreamhost
 
7
 *
 
8
 * This is free software; you can redistribute it and/or
 
9
 * modify it under the terms of the GNU Lesser General Public
 
10
 * License version 2.1, as published by the Free Software
 
11
 * Foundation.  See file COPYING.
 
12
 *
 
13
 */
 
14
 
 
15
/*
 
16
 * TestDoutStreambuf
 
17
 *
 
18
 * Puts some output into the DoutStreambuf class.
 
19
 * Check your syslog to see what it did.
 
20
 */
 
21
#include "common/DoutStreambuf.h"
 
22
#include "common/ceph_argparse.h"
 
23
#include "common/common_init.h"
 
24
#include "common/config.h"
 
25
 
 
26
#include <iostream>
 
27
#include <sstream>
 
28
#include <string>
 
29
#include <syslog.h>
 
30
 
 
31
using std::string;
 
32
 
 
33
int main(int argc, const char **argv)
 
34
{
 
35
  vector<const char*> args;
 
36
  argv_to_vec(argc, argv, args);
 
37
  env_to_vec(args);
 
38
 
 
39
  common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_UTILITY, 0);
 
40
 
 
41
  DoutStreambuf<char> *dos = new DoutStreambuf<char>();
 
42
 
 
43
  {
 
44
    DoutLocker _dout_locker;
 
45
    dos->read_global_config();
 
46
  }
 
47
  derr << "using configuration: " << dos->config_to_str() << dendl;
 
48
 
 
49
  std::ostream oss(dos);
 
50
  syslog(LOG_USER | LOG_NOTICE, "TestDoutStreambuf: starting test\n");
 
51
 
 
52
  dos->set_prio(1);
 
53
  oss << "1. I am logging to dout now!" << std::endl;
 
54
 
 
55
  dos->set_prio(2);
 
56
  oss << "2. And here is another line!" << std::endl;
 
57
 
 
58
  oss.flush();
 
59
 
 
60
  dos->set_prio(3);
 
61
  oss << "3. And here is another line!" << std::endl;
 
62
 
 
63
  dos->set_prio(16);
 
64
  oss << "4. Stuff ";
 
65
  oss << "that ";
 
66
  oss << "will ";
 
67
  oss << "all ";
 
68
  oss << "be ";
 
69
  oss << "on ";
 
70
  oss << "one ";
 
71
  oss << "line.\n";
 
72
  oss.flush();
 
73
 
 
74
  dos->set_prio(10);
 
75
  oss << "5. There will be no blank lines here.\n" << std::endl;
 
76
  oss.flush();
 
77
  oss.flush();
 
78
  oss.flush();
 
79
 
 
80
  syslog(LOG_USER | LOG_NOTICE, "TestDoutStreambuf: ending test\n");
 
81
 
 
82
  return 0;
 
83
}