equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "logger.h" |
|
20 #include <iostream> |
|
21 |
|
22 |
|
23 struct LoggerImpl |
|
24 { |
|
25 bool SetLevel(WarnLevel aLev) { iLev = aLev; return true; } |
|
26 bool SetStream(std::wostream& aOs) { iWos = &aOs; return true; } |
|
27 |
|
28 std::wostream& Stream() { return *iWos; } |
|
29 bool ShouldPrint(WarnLevel aLev) { return iLev >= aLev; } |
|
30 |
|
31 WarnLevel iLev; |
|
32 std::wostream *iWos; |
|
33 }; |
|
34 |
|
35 |
|
36 LoggerImpl* Logger::iLogger = 0; |
|
37 |
|
38 LoggerImpl& Logger::Impl() |
|
39 { |
|
40 if (!iLogger) |
|
41 { |
|
42 iLogger = new LoggerImpl(); |
|
43 iLogger->SetStream(std::wcout); |
|
44 iLogger->SetLevel(WARN_WARN); |
|
45 } |
|
46 return *iLogger; |
|
47 } |
|
48 |
|
49 |
|
50 bool Logger::SetLevel(WarnLevel aLev) |
|
51 { |
|
52 return Impl().SetLevel(aLev); |
|
53 } |
|
54 bool Logger::SetStream(std::wostream& aOs) |
|
55 { |
|
56 return Impl().SetStream(aOs); |
|
57 } |
|
58 |
|
59 std::wostream& Logger::Stream() |
|
60 { |
|
61 return Impl().Stream(); |
|
62 } |
|
63 |
|
64 bool Logger::ShouldPrint(WarnLevel aLev) |
|
65 { |
|
66 return Impl().ShouldPrint(aLev); |
|
67 } |