Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
VisualDL
提交
04e3f0fc
V
VisualDL
项目概览
PaddlePaddle
/
VisualDL
大约 1 年 前同步成功
通知
88
Star
4655
Fork
642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
10
列表
看板
标记
里程碑
合并请求
2
Wiki
5
Wiki
分析
仓库
DevOps
项目成员
Pages
V
VisualDL
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
10
Issue
10
列表
看板
标记
里程碑
合并请求
2
合并请求
2
Pages
分析
分析
仓库分析
DevOps
Wiki
5
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
04e3f0fc
编写于
1月 09, 2018
作者:
Y
Yan Chunwei
提交者:
GitHub
1月 09, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "feature/glog to exception" (#72)
上级
1dce8d1c
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
32 addition
and
181 deletion
+32
-181
CMakeLists.txt
CMakeLists.txt
+0
-1
visualdl/logic/histogram.h
visualdl/logic/histogram.h
+1
-2
visualdl/logic/im.cc
visualdl/logic/im.cc
+1
-0
visualdl/logic/im.h
visualdl/logic/im.h
+1
-1
visualdl/storage/storage.h
visualdl/storage/storage.h
+1
-0
visualdl/storage/tablet.h
visualdl/storage/tablet.h
+2
-0
visualdl/test.cc
visualdl/test.cc
+1
-4
visualdl/utils/concurrency.h
visualdl/utils/concurrency.h
+1
-2
visualdl/utils/filesystem.h
visualdl/utils/filesystem.h
+3
-0
visualdl/utils/image.h
visualdl/utils/image.h
+1
-2
visualdl/utils/log.h
visualdl/utils/log.h
+19
-0
visualdl/utils/logging.h
visualdl/utils/logging.h
+0
-145
visualdl/utils/test_concurrency.cc
visualdl/utils/test_concurrency.cc
+1
-2
visualdl/utils/test_logging.cc
visualdl/utils/test_logging.cc
+0
-22
未找到文件。
CMakeLists.txt
浏览文件 @
04e3f0fc
...
...
@@ -41,7 +41,6 @@ add_executable(vl_test
${
PROJECT_SOURCE_DIR
}
/visualdl/logic/histogram_test.cc
${
PROJECT_SOURCE_DIR
}
/visualdl/storage/storage_test.cc
${
PROJECT_SOURCE_DIR
}
/visualdl/utils/test_concurrency.cc
${
PROJECT_SOURCE_DIR
}
/visualdl/utils/test_logging.cc
${
PROJECT_SOURCE_DIR
}
/visualdl/utils/test_image.cc
${
PROJECT_SOURCE_DIR
}
/visualdl/utils/concurrency.h
${
PROJECT_SOURCE_DIR
}
/visualdl/utils/filesystem.h
...
...
visualdl/logic/histogram.h
浏览文件 @
04e3f0fc
#ifndef VISUALDL_LOGIC_HISTOGRAM_H
#define VISUALDL_LOGIC_HISTOGRAM_H
#include <glog/logging.h>
#include <cstdlib>
#include <limits>
#include <vector>
#include "visualdl/utils/logging.h"
namespace
visualdl
{
// An interface to retrieve records of a histogram.
...
...
visualdl/logic/im.cc
浏览文件 @
04e3f0fc
#include <glog/logging.h>
#include <ctime>
#include "visualdl/logic/im.h"
...
...
visualdl/logic/im.h
浏览文件 @
04e3f0fc
#ifndef VISUALDL_LOGIC_IM_H
#define VISUALDL_LOGIC_IM_H
#include <glog/logging.h>
#include <memory>
#include <mutex>
#include <string>
#include "visualdl/utils/concurrency.h"
#include "visualdl/utils/guard.h"
#include "visualdl/utils/logging.h"
namespace
visualdl
{
...
...
visualdl/storage/storage.h
浏览文件 @
04e3f0fc
#ifndef VISUALDL_STORAGE_STORAGE_H
#define VISUALDL_STORAGE_STORAGE_H
#include <glog/logging.h>
#include <algorithm>
#include <set>
#include <vector>
...
...
visualdl/storage/tablet.h
浏览文件 @
04e3f0fc
#ifndef VISUALDL_TABLET_H
#define VISUALDL_TABLET_H
#include <glog/logging.h>
#include "visualdl/logic/im.h"
#include "visualdl/storage/record.h"
#include "visualdl/storage/storage.pb.h"
...
...
visualdl/test.cc
浏览文件 @
04e3f0fc
#include "gtest/gtest.h"
#include "visualdl/utils/logging.h"
int
main
(
int
argc
,
char
**
argv
)
{
::
testing
::
InitGoogleTest
(
&
argc
,
argv
);
std
::
signal
(
SIGINT
,
visualdl
::
log
::
SignalHandler
);
return
RUN_ALL_TESTS
();
}
}
\ No newline at end of file
visualdl/utils/concurrency.h
浏览文件 @
04e3f0fc
#ifndef VISUALDL_UTILS_CONCURRENCY_H
#define VISUALDL_UTILS_CONCURRENCY_H
#include <glog/logging.h>
#include <chrono>
#include <memory>
#include <thread>
#include <vector>
#include "visualdl/utils/logging.h"
namespace
visualdl
{
namespace
cc
{
...
...
visualdl/utils/filesystem.h
浏览文件 @
04e3f0fc
...
...
@@ -44,6 +44,7 @@ bool DeSerializeFromFile(T* proto, const std::string& path) {
}
static
void
TryMkdir
(
const
std
::
string
&
dir
)
{
VLOG
(
1
)
<<
"try to mkdir "
<<
dir
;
struct
stat
st
=
{
0
};
if
(
stat
(
dir
.
c_str
(),
&
st
)
==
-
1
)
{
::
mkdir
(
dir
.
c_str
(),
0700
);
...
...
@@ -66,6 +67,7 @@ static void TryRecurMkdir(const std::string& path) {
inline
void
Write
(
const
std
::
string
&
path
,
const
std
::
string
&
buffer
,
std
::
ios
::
openmode
open_mode
=
std
::
ios
::
binary
)
{
VLOG
(
1
)
<<
"write to path "
<<
path
;
std
::
ofstream
file
(
path
,
open_mode
);
CHECK
(
file
.
is_open
())
<<
"failed to open "
<<
path
;
file
.
write
(
buffer
.
c_str
(),
buffer
.
size
());
...
...
@@ -74,6 +76,7 @@ inline void Write(const std::string& path,
inline
std
::
string
Read
(
const
std
::
string
&
path
,
std
::
ios
::
openmode
open_mode
=
std
::
ios
::
binary
)
{
VLOG
(
1
)
<<
"read from path "
<<
path
;
std
::
string
buffer
;
std
::
ifstream
file
(
path
,
open_mode
|
std
::
ios
::
ate
);
CHECK
(
file
.
is_open
())
<<
"failed to open "
<<
path
;
...
...
visualdl/utils/image.h
浏览文件 @
04e3f0fc
#ifndef VISUALDL_UTILS_IMAGE_H
#define VISUALDL_UTILS_IMAGE_H
#include <glog/logging.h>
#include <Eigen/Core>
#include <unsupported/Eigen/CXX11/Tensor>
#include "visualdl/utils/logging.h"
namespace
visualdl
{
using
uint8_t
=
unsigned
char
;
...
...
visualdl/utils/log.h
0 → 100644
浏览文件 @
04e3f0fc
#ifndef VISUALDL_UTILS_LOG_H
#define VISUALDL_UTILS_LOG_H
#include <stdexcept>
namespace
visualdl
{
namespace
log
{
class
NotImplementedException
:
public
std
::
logic_error
{
public:
NotImplementedException
()
:
std
::
logic_error
{
"Function not implemented"
}
{}
};
}
// namespace log
}
// namespace visualdl
#endif
visualdl/utils/logging.h
已删除
100644 → 0
浏览文件 @
1dce8d1c
#ifndef VISUALDL_UTILS_LOGGING_H
#define VISUALDL_UTILS_LOGGING_H
#include <csignal>
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <string>
#if defined(VISUALDL_WITH_GLOG)
#include <glog/logging.h>
#endif
namespace
visualdl
{
namespace
logging
{
#if !defined(VISUALDL_WITH_GLOG)
// basic log stream for INFO, ERROR, WARNING
struct
LogStream
{
LogStream
(
const
char
*
file
,
int
line
)
:
os_
(
std
::
cerr
)
{
os_
<<
"["
<<
file
<<
":"
<<
line
<<
"] "
;
}
~
LogStream
()
{
os_
<<
"
\n
"
;
}
std
::
ostream
&
stream
()
{
return
os_
;
}
void
operator
=
(
const
LogStream
&
)
=
delete
;
LogStream
(
const
LogStream
&
)
=
delete
;
private:
std
::
ostream
&
os_
;
};
#endif
#if !defined(VISUALDL_WITH_GLOG)
#if defined(VISUALDL_FATAL_ABORT)
// log stream for FATAL
struct
LogStreamFatal
:
public
LogStream
{
LogStreamFatal
(
const
char
*
file
,
int
line
)
:
LogStream
(
file
,
line
)
{}
~
LogStreamFatal
()
{
abort
();
}
LogStreamFatal
(
const
LogStreamFatal
&
)
=
delete
;
void
operator
=
(
const
LogStreamFatal
&
)
=
delete
;
};
#else
struct
Error
:
public
std
::
runtime_error
{
explicit
Error
(
const
std
::
string
&
s
)
:
std
::
runtime_error
(
s
)
{}
};
// With exception.
struct
LogStreamFatal
:
public
std
::
basic_ostream
<
char
,
std
::
char_traits
<
char
>>
{
LogStreamFatal
(
const
char
*
file
,
int
line
)
{
ss
<<
"["
<<
file
<<
":"
<<
line
<<
"] "
;
throw
Error
(
ss
.
str
());
}
LogStreamFatal
&
operator
<<
(
std
::
basic_streambuf
<
char
,
std
::
char_traits
<
char
>>*
sb
)
{
*
this
<<
sb
;
if
(
sb
->
sgetc
()
==
'\n'
)
{
std
::
cout
<<
"end get"
;
}
return
*
this
;
}
friend
LogStreamFatal
&
operator
<<
(
LogStreamFatal
&
os
,
const
char
*
msg
)
{
std
::
cout
<<
"msg: '"
<<
msg
<<
"'"
<<
std
::
endl
;
os
.
stream
()
<<
msg
;
if
(
msg
==
"
\n
"
)
{
os
.
has_throw_
=
true
;
throw
Error
(
os
.
stream
().
str
());
}
return
os
;
}
std
::
stringstream
&
stream
()
{
return
ss
;
}
~
LogStreamFatal
()
{
if
(
!
has_throw_
)
{
std
::
cerr
<<
"throw exception"
<<
std
::
endl
;
throw
Error
(
ss
.
str
());
}
}
private:
bool
has_throw_
{
false
};
mutable
std
::
stringstream
ss
;
};
#endif // VISUALDL_FATAL_ABORT
#endif // VISUALDL_WITH_GLOG
#ifndef VISUALDL_WITH_GLOG
#define LOG(severity) LOG_##severity
#define LOG_INFO visualdl::logging::LogStream(__FILE__, __LINE__).stream()
#define LOG_WARNING LOG_INFO
#define LOG_ERROR LOG_INFO
#define LOG_FATAL visualdl::logging::LogStreamFatal(__FILE__, __LINE__)
// basic version without support for debug level.
#define VLOG(x) LOG_INFO
#define CHECK(cond) \
if (!(cond)) \
visualdl::logging::LogStreamFatal(__FILE__, __LINE__) \
<< "Check failed: " << #cond << " "
#define CHECK_EQ(v0, v1) CHECK_BINARY(v0, v1, ==)
#define CHECK_GE(v0, v1) CHECK_BINARY(v0, v1, >=)
#define CHECK_GT(v0, v1) CHECK_BINARY(v0, v1, >)
#define CHECK_LE(v0, v1) CHECK_BINARY(v0, v1, <=)
#define CHECK_LT(v0, v1) CHECK_BINARY(v0, v1, <)
#define CHECK_BINARY(v0, v1, op) \
if (!(v0 op v1)) LOG_FATAL << " Check failed: " << v0 << #op << v1 << " "
#endif // ifndef VISUALDL_WITH_GLOG
}
// namespace logging
}
// namespace visualdl
namespace
visualdl
{
namespace
log
{
class
NotImplementedException
:
public
std
::
logic_error
{
public:
NotImplementedException
()
:
std
::
logic_error
{
"Function not implemented"
}
{}
};
static
void
SignalHandler
(
int
sig
)
{
LOG
(
INFO
)
<<
"get signal "
<<
sig
;
exit
(
sig
);
}
struct
__once_caller__
{
__once_caller__
()
{
std
::
signal
(
SIGINT
,
SignalHandler
);
}
};
}
// namespace log
}
// namespace visualdl
#endif
visualdl/utils/test_concurrency.cc
浏览文件 @
04e3f0fc
#include "visualdl/utils/concurrency.h"
#include <glog/logging.h>
#include <gtest/gtest.h>
#include "visualdl/utils/logging.h"
namespace
visualdl
{
int
counter
=
0
;
...
...
visualdl/utils/test_logging.cc
已删除
100644 → 0
浏览文件 @
1dce8d1c
#ifdef VISUALDL_WITH_GLOG
#undef VISUALDL_WITH_GLOG
#endif
#include "visualdl/utils/logging.h"
#include <gtest/gtest.h>
TEST
(
Log
,
LOG
)
{
LOG
(
INFO
)
<<
"hello world"
;
}
TEST
(
Log
,
CHECK
)
{
CHECK_EQ
(
1
,
1
)
<<
"yes this works"
;
}
TEST
(
Log
,
CHECK_FAIL
)
{
try
{
{
CHECK_LE
(
3
,
2
)
<<
"this is wrong"
<<
"
\n
"
;
}
// throw std::runtime_error("some error");
}
catch
(
const
visualdl
::
logging
::
Error
&
e
)
{
LOG
(
INFO
)
<<
"in exception"
;
}
catch
(...)
{
LOG
(
INFO
)
<<
"catch something"
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录